12e5b6d6dSopenharmony_ci# Copyright (c) 2024 Huawei Device Co., Ltd.
22e5b6d6dSopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
32e5b6d6dSopenharmony_ci# you may not use this file except in compliance with the License.
42e5b6d6dSopenharmony_ci# You may obtain a copy of the License at
52e5b6d6dSopenharmony_ci#
62e5b6d6dSopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
72e5b6d6dSopenharmony_ci#
82e5b6d6dSopenharmony_ci# Unless required by applicable law or agreed to in writing, software
92e5b6d6dSopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
102e5b6d6dSopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
112e5b6d6dSopenharmony_ci# See the License for the specific language governing permissions and
122e5b6d6dSopenharmony_ci# limitations under the License.
132e5b6d6dSopenharmony_ci
142e5b6d6dSopenharmony_ciimport("//build/ohos.gni")
152e5b6d6dSopenharmony_ciimport("//build/ohos/ndk/ndk.gni")
162e5b6d6dSopenharmony_ciimport("//third_party/icu/icu.gni")
172e5b6d6dSopenharmony_ci
182e5b6d6dSopenharmony_ciohos_shared_library("icundk") {
192e5b6d6dSopenharmony_ci  ldflags = [
202e5b6d6dSopenharmony_ci    "-shared",
212e5b6d6dSopenharmony_ci    "-lm",
222e5b6d6dSopenharmony_ci  ]
232e5b6d6dSopenharmony_ci  configs = [
242e5b6d6dSopenharmony_ci    "//third_party/icu/icu4c:icu_config",
252e5b6d6dSopenharmony_ci    "//build/config/compiler:rtti",
262e5b6d6dSopenharmony_ci  ]
272e5b6d6dSopenharmony_ci  include_dirs = [ "//third_party/icu/icu4c/source/common" ]
282e5b6d6dSopenharmony_ci
292e5b6d6dSopenharmony_ci  sources = [ "src/icu_addon.cpp" ]
302e5b6d6dSopenharmony_ci
312e5b6d6dSopenharmony_ci  deps = [
322e5b6d6dSopenharmony_ci    ":ohos_icudat",
332e5b6d6dSopenharmony_ci    "//third_party/icu/icu4c:shared_icui18n",
342e5b6d6dSopenharmony_ci    "//third_party/icu/icu4c:shared_icuuc",
352e5b6d6dSopenharmony_ci  ]
362e5b6d6dSopenharmony_ci  external_deps = []
372e5b6d6dSopenharmony_ci  defines = []
382e5b6d6dSopenharmony_ci  if (icu_support_libbegetutil && is_ohos) {
392e5b6d6dSopenharmony_ci    defines += [ "ICU_SUPPORT_LIBBEGETUTIL" ]
402e5b6d6dSopenharmony_ci    external_deps += [ "init:libbegetutil" ]
412e5b6d6dSopenharmony_ci  }
422e5b6d6dSopenharmony_ci
432e5b6d6dSopenharmony_ci  version_script = "libicu.map"
442e5b6d6dSopenharmony_ci  output_name = "icu"
452e5b6d6dSopenharmony_ci  output_extension = "so"
462e5b6d6dSopenharmony_ci  relative_install_dir = "ndk"
472e5b6d6dSopenharmony_ci  subsystem_name = "thirdparty"
482e5b6d6dSopenharmony_ci  part_name = "icu"
492e5b6d6dSopenharmony_ci}
502e5b6d6dSopenharmony_ci
512e5b6d6dSopenharmony_ciaction("pkg_icudata") {
522e5b6d6dSopenharmony_ci  script = "build_data/pkgdata.sh"
532e5b6d6dSopenharmony_ci  sources = [ "//third_party/icu/ohos_icu4c/build_data/pkgdata.sh" ]
542e5b6d6dSopenharmony_ci  deps = [ "//third_party/icu/icu4c/source:bin_host" ]
552e5b6d6dSopenharmony_ci
562e5b6d6dSopenharmony_ci  icu_bin_root_out_dir =
572e5b6d6dSopenharmony_ci      get_label_info(
582e5b6d6dSopenharmony_ci          "//third_party/icu/icu4c/source:bin_host(${host_toolchain})",
592e5b6d6dSopenharmony_ci          "root_out_dir")
602e5b6d6dSopenharmony_ci  if ("${build_feature}" == "lite") {
612e5b6d6dSopenharmony_ci    icu_data_filter_dir = "lite"
622e5b6d6dSopenharmony_ci  }
632e5b6d6dSopenharmony_ci  args = [
642e5b6d6dSopenharmony_ci    "-o",
652e5b6d6dSopenharmony_ci    "$root_out_dir",
662e5b6d6dSopenharmony_ci    "-b",
672e5b6d6dSopenharmony_ci    "$icu_bin_root_out_dir",
682e5b6d6dSopenharmony_ci    "-f",
692e5b6d6dSopenharmony_ci    "$icu_data_filter_dir",
702e5b6d6dSopenharmony_ci    "-v",
712e5b6d6dSopenharmony_ci    "$icu_dat_name",
722e5b6d6dSopenharmony_ci  ]
732e5b6d6dSopenharmony_ci  outputs = [ "$root_out_dir/thirdparty/icu/out/$icu_dat_name.dat" ]
742e5b6d6dSopenharmony_ci}
752e5b6d6dSopenharmony_ci
762e5b6d6dSopenharmony_ciohos_prebuilt_etc("ohos_icudat") {
772e5b6d6dSopenharmony_ci  source = "$root_out_dir/thirdparty/icu/out/$icu_dat_name.dat"
782e5b6d6dSopenharmony_ci
792e5b6d6dSopenharmony_ci  deps = [ ":pkg_icudata" ]
802e5b6d6dSopenharmony_ci  module_install_dir = "usr/ohos_icu/"
812e5b6d6dSopenharmony_ci  part_name = "icu"
822e5b6d6dSopenharmony_ci  subsystem_name = "thirdparty"
832e5b6d6dSopenharmony_ci}
84