1# Copyright (c) 2021 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import("//build/ohos.gni")
15import("//foundation/arkui/ace_engine/ace_config.gni")
16
17config("ace_base_i18n_config") {
18  defines = [ "ACEL10N" ]
19}
20
21template("ace_base_i18n") {
22  forward_variables_from(invoker, "*")
23  ohos_source_set(target_name) {
24    defines += invoker.defines
25    cflags_cc += invoker.cflags_cc
26    if (current_os == "ohos") {
27      sanitize = {
28        integer_overflow = true
29        boundary_sanitize = true
30        debug = ace_sanitize_debug
31      }
32    }
33    configs = [
34      ":ace_base_i18n_config",
35      "$ace_root:ace_config",
36    ]
37    deps = [ "$ace_root/frameworks/base/resource:ace_resource" ]
38    external_deps = []
39
40    if (defined(config.use_external_icu) &&
41        config.use_external_icu == "static") {
42      if (is_arkui_x) {
43        deps += [
44          "//third_party/icu/icu4c:static_icui18n",
45          "//third_party/icu/icu4c:static_icuuc",
46        ]
47      } else {
48        external_deps += [
49          "icu:static_icui18n",
50          "icu:static_icuuc",
51        ]
52      }
53    } else {
54      external_deps += [
55        "icu:shared_icui18n",
56        "icu:shared_icuuc",
57      ]
58    }
59
60    if (!is_arkui_x) {
61      external_deps += [ "i18n:intl_util" ]
62    }
63
64    # add base source file here
65    sources = [
66      "date_time_sequence.cpp",
67      "localization.cpp",
68    ]
69
70    if (use_hilog) {
71      external_deps += [ "hilog:libhilog" ]
72    }
73
74    subsystem_name = ace_engine_subsystem
75    part_name = ace_engine_part
76  }
77}
78
79foreach(item, ace_platforms) {
80  ace_base_i18n("ace_base_i18n_" + item.name) {
81    defines = []
82    cflags_cc = []
83    config = {
84    }
85
86    if (defined(item.config)) {
87      config = item.config
88    }
89
90    if (defined(config.defines)) {
91      defines = config.defines
92    }
93
94    if (defined(config.cflags_cc)) {
95      cflags_cc = config.cflags_cc
96    }
97  }
98}
99