• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni")
15import("//build/ohos.gni")
16import("//build/ohos/ace/ace.gni")
17import("//commonlibrary/ets_utils/ets_utils_config.gni")
18import("//foundation/arkui/ace_engine/ace_config.gni")
19import("//foundation/arkui/ace_engine/build/ace_gen_obj.gni")
20
21# compile .ts to .js.
22action("build_ts_js") {
23  script = "$util_module/build_ts_js.py"
24  outFile_Path = target_out_dir + "/" + current_cpu
25  args = [
26    "--dst-file",
27    rebase_path(target_out_dir + "/util_js.js"),
28    "--module-path",
29    rebase_path("/commonlibrary/ets_utils/js_util_module/util"),
30    "--out-file",
31    rebase_path(outFile_Path + "/util_js.js"),
32    "--out-filePath",
33    rebase_path(outFile_Path),
34    "--relative-path",
35    rebase_path("//", root_build_dir),
36  ]
37  outputs = [ target_out_dir + "/util_js.js" ]
38}
39
40# compile .js to .abc.
41es2abc_gen_abc("gen_util_abc") {
42  extra_visibility = [ ":*" ]
43  src_js = rebase_path(target_out_dir + "/util_js.js")
44  dst_file = rebase_path(target_out_dir + "/util.abc")
45  in_puts = [ target_out_dir + "/util_js.js" ]
46  out_puts = [ target_out_dir + "/util.abc" ]
47  extra_args = [ "--module" ]
48  extra_dependencies = [ ":build_ts_js" ]
49}
50
51abc_output_path = get_label_info(":util_abc", "target_out_dir")
52
53gen_obj("util_js") {
54  input = "$target_out_dir/util_js.js"
55  if (use_mac || use_mingw_win || use_ios || use_linux) {
56    util_obj_path = abc_output_path + "/util.c"
57  } else {
58    util_obj_path = abc_output_path + "/util.o"
59  }
60  output = util_obj_path
61  snapshot_dep = [ ":build_ts_js" ]
62}
63
64gen_obj("util_abc") {
65  input = "$target_out_dir/util.abc"
66  if (use_mac || use_mingw_win || use_ios || use_linux) {
67    util_obj_path = abc_output_path + "/util_abc.c"
68  } else {
69    util_obj_path = abc_output_path + "/util_abc.o"
70  }
71  output = util_obj_path
72  snapshot_dep = [ ":gen_util_abc" ]
73}
74
75util_sources = [
76  "js_base64.cpp",
77  "js_textdecoder.cpp",
78  "js_textencoder.cpp",
79  "js_types.cpp",
80  "js_uuid.cpp",
81  "native_module_util.cpp",
82]
83
84if (is_arkui_x) {
85  util_sources += [ "$platform_root/default/util_helper.cpp" ]
86  if (target_os == "android") {
87    util_sources += [ "$platform_root/android/jni_helper.cpp" ]
88  } else {
89    util_sources += [ "$platform_root/default/jni_helper.cpp" ]
90  }
91} else {
92  util_sources += [ "$platform_root/ohos/util_helper.cpp" ]
93  util_sources += [ "$platform_root/default/jni_helper.cpp" ]
94}
95
96ohos_shared_library("util") {
97  deps = [ ":util_static" ]
98  subsystem_name = "commonlibrary"
99  part_name = "ets_utils"
100  relative_install_dir = "module"
101}
102
103ohos_source_set("util_static") {
104  include_dirs = [
105    "//third_party/icu/icu4c/source/common",
106    "//third_party/icu/icu4c/source",
107    "//third_party/node/src",
108    "//third_party/openssl",
109    "//third_party/openssl/include",
110    platform_root,
111  ]
112  configs = [
113    "$icu_root:icu_config",
114    "$napi_root:ace_napi_config",
115  ]
116  sources = util_sources
117
118  deps = [
119    ":gen_obj_src_util_abc",
120    ":gen_obj_src_util_js",
121    "//third_party/icu/icu4c:shared_icuuc",
122    "//third_party/openssl:libcrypto_shared",
123  ]
124
125  if (is_arkui_x) {
126    include_dirs += [
127      "$plugins_root/hilog/include",
128      "$plugins_root/interfaces",
129    ]
130
131    configs += [ "$plugins_root/util:util_plugin_config" ]
132
133    defines = [ "__ARKUI_CROSS__" ]
134
135    deps -= [ "//third_party/icu/icu4c:shared_icuuc" ]
136
137    if (target_os == "android") {
138      defines += [ "ANDROID_PLATFORM" ]
139    }
140    if (target_os == "ios") {
141      defines += [ "IOS_PLATFORM" ]
142    }
143    deps += [
144      "$plugins_root/interfaces/native:ace_plugin_util_${target_os}",
145      "$plugins_root/libs/icu:icu_${target_os}",
146      "$plugins_root/libs/napi:napi_${target_os}",
147      "$plugins_root/libs/securec:sec_${target_os}",
148    ]
149  } else {
150    external_deps = [ "napi:ace_napi" ]
151    if (is_standard_system) {
152      external_deps += [ "hilog:libhilog" ]
153    } else {
154      external_deps += [
155        "c_utils:utils",
156        "hilog:libhilog",
157      ]
158    }
159  }
160
161  subsystem_name = "commonlibrary"
162  part_name = "ets_utils"
163}
164
165group("util_packages") {
166  deps = [ ":util" ]
167}
168