• 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
21container_names = [
22  "arraylist",
23  "deque",
24  "queue",
25  "vector",
26  "linkedlist",
27  "list",
28  "stack",
29  "struct",
30  "treemap",
31  "treeset",
32  "hashmap",
33  "hashset",
34  "lightweightmap",
35  "lightweightset",
36  "plainarray",
37]
38
39# compile .ts to .js.
40action("build_js_ts") {
41  script = "${ets_util_path}/js_util_module/container/build_ts_js.py"
42  outFile_Path = target_out_dir + "/" + current_cpu
43  args = [
44    "--dst-file",
45    rebase_path(target_out_dir + "/"),
46    "--out-filePath",
47    rebase_path(outFile_Path),
48    "--relative-path",
49    rebase_path("//", root_build_dir),
50  ]
51
52  outputs = []
53  foreach(item, container_names) {
54    dep = target_out_dir + "/js_" + item + ".js"
55    outputs += [ dep ]
56  }
57}
58
59config("container_config") {
60  cflags_cc = [
61    "-std=c++17",
62    "-Wno-deprecated-declarations",
63  ]
64}
65
66# libs
67template("container_lib") {
68  forward_variables_from(invoker, "*")
69
70  name = target_name
71  base_output_path = get_label_info(":js_" + name, "target_out_dir")
72  gen_obj("js_" + name) {
73    input = "$target_out_dir/js_" + name + ".js"
74    if (use_mac || use_mingw_win || use_ios || use_linux) {
75      js_container_obj_path = base_output_path + name + ".c"
76    } else {
77      js_container_obj_path = base_output_path + name + ".o"
78    }
79    output = js_container_obj_path
80    snapshot_dep = [ ":build_js_ts" ]
81  }
82
83  # compile .js to .abc.
84  es2abc_gen_abc("gen_" + name + "_abc") {
85    extra_visibility = [ ":*" ]
86    src_js = rebase_path(target_out_dir + "/js_" + name + ".js")
87    dst_file = rebase_path(target_out_dir + "/" + name + ".abc")
88    in_puts = [ target_out_dir + "/js_" + name + ".js" ]
89    out_puts = [ target_out_dir + "/" + name + ".abc" ]
90    extra_args = [ "--module" ]
91    extra_dependencies = [ ":build_js_ts" ]
92  }
93
94  abc_output_path = get_label_info(":" + name + "_abc", "target_out_dir")
95  gen_obj(name + "_abc") {
96    input = "$target_out_dir/" + name + ".abc"
97    if (use_mac || use_mingw_win || use_ios || use_linux) {
98      arraylist_abc_obj_path = abc_output_path + "/" + name + "_abc.c"
99    } else {
100      arraylist_abc_obj_path = abc_output_path + "/" + name + "_abc.o"
101    }
102    output = arraylist_abc_obj_path
103    snapshot_dep = [ ":gen_" + target_name ]
104  }
105
106  ohos_source_set(name + "_static") {
107    include_dirs = [
108      "//third_party/node/src",
109      "//commonlibrary/ets_utils/js_util_module/container/" + name,
110    ]
111
112    sources = [ name + "/native_module_" + name + ".cpp" ]
113
114    dep_abc = ":gen_obj_src_" + name + "_abc"
115    dep_js = ":gen_obj_src_js_" + name
116    deps = [ "$container_root:gen_obj_src_js_" + name ]
117    deps += [ dep_abc ]
118    deps += [ dep_js ]
119
120    if (is_cross_platform_build) {
121      include_dirs += [
122        "$napi_root/interfaces/kits",
123        "$plugins_root/hilog/include",
124        "$plugins_root/interfaces",
125      ]
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
133      if (target_os == "android") {
134        defines = [ "ANDROID_PLATFORM" ]
135      }
136    } else {
137      external_deps = [
138        "hilog:libhilog",
139        "napi:ace_napi",
140      ]
141    }
142
143    configs = [ ":container_config" ]
144
145    subsystem_name = "commonlibrary"
146    part_name = "ets_utils"
147  }
148  ohos_shared_library(name) {
149    deps = [ ":${name}_static" ]
150    subsystem_name = "commonlibrary"
151    part_name = "ets_utils"
152    relative_install_dir = "module/util"
153  }
154}
155
156container_libs = []
157foreach(item, container_names) {
158  container_lib(item) {
159  }
160  if (is_cross_platform_build) {
161    dep = ":" + item + "_static"
162  } else {
163    dep = ":" + item
164  }
165  container_libs += [ dep ]
166}
167
168group("container_packages") {
169  public_deps = container_libs
170}
171
172foreach(name, container_names) {
173  group(name + "_packages") {
174    if (is_cross_platform_build) {
175      deps = [ ":" + name + "_static" ]
176    } else {
177      deps = [ ":" + name ]
178    }
179  }
180}
181