1# Copyright (c) 2022 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("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni")
15import("//build/ohos.gni")
16import("//commonlibrary/ets_utils/ets_utils_config.gni")
17import("//foundation/arkui/ace_engine/ace_config.gni")
18import("//foundation/arkui/ace_engine/build/ace_gen_obj.gni")
19
20# compile .ts to .js.
21action("build_ts_js") {
22  script = "${ets_util_path}/js_api_module/build_ts_js.py"
23
24  outFile_Path = target_out_dir + "/" + current_cpu
25  args = [
26    "--dst-file",
27    rebase_path(target_out_dir + "/js_xml.js"),
28    "--module-path",
29    rebase_path("/commonlibrary/ets_utils/js_api_module/xml"),
30    "--out-file",
31    rebase_path(outFile_Path + "/js_xml.js"),
32    "--out-filePath",
33    rebase_path(outFile_Path),
34    "--relative-path",
35    rebase_path("//", root_build_dir),
36  ]
37  outputs = [ target_out_dir + "/js_xml.js" ]
38}
39
40# compile .js to .abc.
41es2abc_gen_abc("gen_xml_abc") {
42  extra_visibility = [ ":*" ]
43  src_js = rebase_path(target_out_dir + "/js_xml.js")
44  dst_file = rebase_path(target_out_dir + "/xml.abc")
45  in_puts = [ target_out_dir + "/js_xml.js" ]
46  out_puts = [ target_out_dir + "/xml.abc" ]
47  extra_args = [ "--module" ]
48  extra_dependencies = [ ":build_ts_js" ]
49}
50
51abc_output_path = get_label_info(":xml_abc", "target_out_dir")
52
53gen_obj("xml_js") {
54  input = "$target_out_dir/js_xml.js"
55  if (use_mac || use_mingw_win || use_ios || use_linux) {
56    xml_obj_path = abc_output_path + "/xml.c"
57  } else {
58    xml_obj_path = abc_output_path + "/xml.o"
59  }
60  output = xml_obj_path
61  snapshot_dep = [ ":build_ts_js" ]
62}
63
64gen_obj("xml_abc") {
65  input = "$target_out_dir/xml.abc"
66  if (use_mac || use_mingw_win || use_ios || use_linux) {
67    xml_obj_path = abc_output_path + "/xml_abc.c"
68  } else {
69    xml_obj_path = abc_output_path + "/xml_abc.o"
70  }
71  output = xml_obj_path
72  snapshot_dep = [ ":gen_xml_abc" ]
73}
74
75xml_sources = [
76  "js_xml.cpp",
77  "native_module_xml.cpp",
78]
79
80ohos_shared_library("xml") {
81  branch_protector_ret = "pac_ret"
82  sanitize = {
83    cfi = true
84    cfi_cross_dso = true
85    debug = false
86  }
87  deps = [ ":xml_static" ]
88  external_deps = [ "hilog:libhilog" ]
89  subsystem_name = "commonlibrary"
90  part_name = "ets_utils"
91  relative_install_dir = "module"
92}
93
94ohos_source_set("xml_static") {
95  branch_protector_ret = "pac_ret"
96  sanitize = {
97    cfi = true
98    cfi_cross_dso = true
99    debug = false
100  }
101  include_dirs = [
102    "include",
103    "//third_party/icu/icu4c/source/common",
104    "//third_party/node/src",
105    ets_util_path,
106  ]
107
108  sources = xml_sources
109
110  deps = [
111    ":gen_obj_src_xml_abc",
112    ":gen_obj_src_xml_js",
113  ]
114
115  if (is_arkui_x) {
116    include_dirs += [
117      "$plugins_root/hilog/include",
118      "$plugins_root/interfaces",
119      "//base/hiviewdfx/hilog/interfaces/native/innerkits/include",
120    ]
121    if (target_os == "android") {
122      defines = [ "ANDROID_PLATFORM" ]
123    }
124    deps += [
125      "$plugins_root/libs/icu:icu_${target_os}",
126      "$plugins_root/libs/napi:napi_${target_os}",
127      "$plugins_root/libs/securec:sec_${target_os}",
128    ]
129  } else {
130    if (is_standard_system) {
131      external_deps = [ "hilog:libhilog" ]
132    } else {
133      external_deps = [
134        "c_utils:utils",
135        "hilog:libhilog",
136      ]
137    }
138    external_deps += [
139      "bounds_checking_function:libsec_shared",
140      "napi:ace_napi",
141    ]
142    deps += [ "//third_party/icu/icu4c:shared_icuuc" ]
143  }
144  subsystem_name = "commonlibrary"
145  part_name = "ets_utils"
146}
147
148group("xml_packages") {
149  deps = [ ":xml" ]
150}
151