• 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
19container_names = [
20  "arraylist",
21  "deque",
22  "queue",
23  "vector",
24  "linkedlist",
25  "list",
26  "stack",
27  "struct",
28  "treemap",
29  "treeset",
30  "hashmap",
31  "hashset",
32  "lightweightmap",
33  "lightweightset",
34  "plainarray",
35]
36
37# compile .ts to .js.
38action("build_js_ts") {
39  script = "//commonlibrary/ets_utils/js_util_module/container/build_ts_js.py"
40  args = [
41    "--dst-file",
42    rebase_path(target_out_dir + "/"),
43    "--relative-path",
44    rebase_path("//", root_build_dir),
45  ]
46  outputs = []
47  foreach(item, container_names) {
48    dep = target_out_dir + "/js_" + item + ".js"
49    outputs += [ dep ]
50  }
51}
52
53config("container_config") {
54  cflags = [ "-fstack-protector-all" ]
55}
56
57# libs
58template("container_lib") {
59  forward_variables_from(invoker, "*")
60
61  name = target_name
62  base_output_path = get_label_info(":js_" + name, "target_out_dir")
63  js_container_obj_path = base_output_path + name + ".o"
64  gen_js_obj("js_" + name) {
65    input = "$target_out_dir/js_" + name + ".js"
66    output = js_container_obj_path
67    dep = ":build_js_ts"
68  }
69
70  # compile .js to .abc.
71  action("gen_" + name + "_abc") {
72    visibility = [ ":*" ]
73    script =
74        "//arkcompiler/ets_frontend/ts2panda/scripts/generate_js_bytecode.py"
75
76    args = [
77      "--src-js",
78      rebase_path(target_out_dir + "/js_" + name + ".js"),
79      "--dst-file",
80      rebase_path(target_out_dir + "/" + name + ".abc"),
81      "--node",
82      rebase_path("${node_path}"),
83      "--frontend-tool-path",
84      rebase_path("${ts2abc_build_path}"),
85      "--node-modules",
86      rebase_path("${node_modules}"),
87      "--module",
88    ]
89    deps = [
90      ":build_js_ts",
91      "//arkcompiler/ets_frontend/ts2panda:ark_ts2abc_build",
92    ]
93
94    inputs = [ target_out_dir + "/js_" + name + ".js" ]
95    outputs = [ target_out_dir + "/" + name + ".abc" ]
96  }
97
98  abc_output_path = get_label_info(":" + name + "_abc", "target_out_dir")
99  arraylist_abc_obj_path = abc_output_path + "/" + name + "_abc.o"
100  gen_js_obj(name + "_abc") {
101    input = "$target_out_dir/" + name + ".abc"
102    output = arraylist_abc_obj_path
103    dep = ":gen_" + target_name
104  }
105
106  ohos_shared_library(name) {
107    include_dirs = [
108      "//third_party/node/src",
109      "//foundation/arkui/napi/interfaces/kits",
110      "//commonlibrary/ets_utils/js_util_module/container/" + name,
111    ]
112
113    sources = [ name + "/native_module_" + name + ".cpp" ]
114
115    dep_abc = ":" + name + "_abc"
116    dep_js = ":js_" + name
117    deps = [
118      "//commonlibrary/ets_utils/js_util_module/container/:js_" + name,
119      "//foundation/arkui/napi/:ace_napi",
120    ]
121    deps += [ dep_abc ]
122    deps += [ dep_js ]
123
124    configs = [ ":container_config" ]
125    if (is_standard_system) {
126      external_deps = [
127        "c_utils:utils",
128        "hiviewdfx_hilog_native:libhilog",
129      ]
130    } else {
131      external_deps = [
132        "c_utils:utils",
133        "hilog:libhilog",
134      ]
135    }
136    subsystem_name = "commonlibrary"
137    part_name = "ets_utils"
138
139    relative_install_dir = "module/util"
140  }
141}
142
143container_libs = []
144foreach(item, container_names) {
145  container_lib(item) {
146  }
147  dep = ":" + item
148  container_libs += [ dep ]
149}
150
151group("container_packages") {
152  deps = container_libs
153}
154