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