• 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/ts2panda/ts2abc_config.gni")
15import("//build/ohos.gni")
16import("//build/ohos/ace/ace.gni")
17import("//foundation/arkui/ace_engine/ace_config.gni")
18
19# compile .ts to .js.
20action("build_ts_js") {
21  script = "//commonlibrary/ets_utils/js_util_module/build_ts_js.py"
22  args = [
23    "--dst-file",
24    rebase_path(target_out_dir + "/util_js.js"),
25    "--module-path",
26    rebase_path("/commonlibrary/ets_utils/js_util_module/util"),
27    "--out-file",
28    rebase_path("./out/util_js.js"),
29    "--relative-path",
30    rebase_path("//", root_build_dir),
31  ]
32  outputs = [ target_out_dir + "/util_js.js" ]
33}
34base_output_path = get_label_info(":util_js", "target_out_dir")
35util_js_obj_path = base_output_path + "/util.o"
36gen_js_obj("util_js") {
37  input = "$target_out_dir/util_js.js"
38  output = util_js_obj_path
39  dep = ":build_ts_js"
40}
41
42# compile .js to .abc.
43action("gen_util_abc") {
44  visibility = [ ":*" ]
45  script = "//arkcompiler/ets_frontend/ts2panda/scripts/generate_js_bytecode.py"
46
47  args = [
48    "--src-js",
49    rebase_path(target_out_dir + "/util_js.js"),
50    "--dst-file",
51    rebase_path(target_out_dir + "/util.abc"),
52    "--node",
53    rebase_path("${node_path}"),
54    "--frontend-tool-path",
55    rebase_path("${ts2abc_build_path}"),
56    "--node-modules",
57    rebase_path("${node_modules}"),
58    "--module",
59  ]
60  deps = [
61    ":build_ts_js",
62    "//arkcompiler/ets_frontend/ts2panda:ark_ts2abc_build",
63  ]
64
65  inputs = [ target_out_dir + "/util_js.js" ]
66  outputs = [ target_out_dir + "/util.abc" ]
67}
68
69abc_output_path = get_label_info(":util_abc", "target_out_dir")
70util_abc_obj_path = abc_output_path + "/util_abc.o"
71gen_js_obj("util_abc") {
72  input = "$target_out_dir/util.abc"
73  output = util_abc_obj_path
74  dep = ":gen_util_abc"
75}
76
77ohos_shared_library("util") {
78  include_dirs = [
79    "//foundation/arkui/napi",
80    "//foundation/arkui/napi/native_engine",
81    "//third_party/icu/icu4c/source/common",
82    "//third_party/icu/icu4c/source",
83    "//third_party/node/src",
84    "//third_party/openssl",
85    "//third_party/openssl/include",
86    "//foundation/arkui/napi/interfaces/kits",
87    "//commonlibrary/ets_utils/js_util_module/util",
88  ]
89
90  sources = [
91    "js_base64.cpp",
92    "js_textdecoder.cpp",
93    "js_textencoder.cpp",
94    "js_types.cpp",
95    "js_uuid.cpp",
96    "native_module_util.cpp",
97  ]
98
99  deps = [
100    ":util_abc",
101    ":util_js",
102    "//commonlibrary/ets_utils/js_util_module/util/:util_js",
103    "//foundation/arkui/napi/:ace_napi",
104    "//third_party/icu/icu4c:shared_icuuc",
105    "//third_party/openssl:libcrypto_shared",
106  ]
107
108  if (is_standard_system) {
109    external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
110  } else {
111    external_deps = [
112      "c_utils:utils",
113      "hilog:libhilog",
114    ]
115  }
116  subsystem_name = "commonlibrary"
117  part_name = "ets_utils"
118
119  relative_install_dir = "module"
120}
121
122group("util_packages") {
123  deps = [ ":util" ]
124}
125