• 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("//build/ohos.gni")
15import("//build/ohos/ace/ace.gni")
16import("//build/ohos_var.gni")
17import("//foundation/arkui/ace_engine/ace_config.gni")
18if (sdk_build_public) {
19  import("//out/sdk-public/public_interface/sdk-js/interface_config.gni")
20} else {
21  import("//interface/sdk-js/interface_config.gni")
22}
23
24ets_loader_lib_dir =
25    get_label_info(":build_ets_loader_library", "target_out_dir") + "/lib"
26ets_loader_declarations_dir = get_label_info(":build_ets_loader_library",
27                                             "target_out_dir") + "/declarations"
28ets_loader_component_config_file =
29    get_label_info(":build_ets_loader_library", "target_out_dir") +
30    "/component_config.json"
31ets_loader_form_config_file =
32    get_label_info(":build_ets_loader_library", "target_out_dir") +
33    "/form_config.json"
34ets_sysResource = get_label_info(":build_ets_sysResource", "target_out_dir") +
35                  "/sysResource.js"
36
37action("build_ets_loader_library") {
38  deps = [
39    ":components",
40    ":form_components",
41    ":server",
42  ]
43  script = "build_ets_loader_library.py"
44  depfile = "$target_gen_dir/$target_name.d"
45  outputs = [
46    ets_loader_lib_dir,
47    ets_loader_declarations_dir,
48    ets_loader_component_config_file,
49    ets_loader_form_config_file,
50  ]
51
52  _ets_loader_dir = "compiler"
53  if (is_standard_system) {
54    _ace_config_dir = "compiler"
55  } else {
56    _ace_config_dir = "//prebuilts/ace-toolkit/ets-loader/compiler"
57  }
58  _declarations_file_dir = "//interface/sdk-js/api/@internal/component/ets"
59  if (sdk_build_public) {
60    _declarations_file_dir =
61        "//out/sdk-public/public_interface/sdk-js/api/@internal/component/ets"
62  }
63
64  _babel_js = _ace_config_dir + "/node_modules/@babel/cli/bin/babel.js"
65  _babel_config_js = _ace_config_dir + "/babel.config.js"
66  _uglify_source_js = _ace_config_dir + "/uglify-source.js"
67  _build_declarations_file_js = _ace_config_dir + "/build_declarations_file.js"
68
69  inputs = [
70    _babel_config_js,
71    _babel_js,
72    _uglify_source_js,
73    _build_declarations_file_js,
74  ]
75
76  # different host platform nodejs tool directory
77  if (host_os == "linux") {
78    if (is_standard_system) {
79      nodejs_path = "//prebuilts/build-tools/common/nodejs/node-v12.18.4-linux-x64/bin/node"
80    } else {
81      nodejs_path =
82          "//prebuilts/ace-toolkit/nodejs/node-v12.18.4-linux-x64/bin/node"
83    }
84  } else if (host_os == "mac") {
85    if (is_standard_system) {
86      nodejs_path = "//prebuilts/build-tools/common/nodejs/node-v12.18.4-darwin-x64/bin/node"
87    } else {
88      nodejs_path =
89          "//prebuilts/ace-toolkit/nodejs/node-v12.18.4-darwin-x64/bin/node"
90    }
91  } else {
92    assert(false, "Unsupported host_os: $host_os")
93  }
94
95  args = [
96    "--depfile",
97    rebase_path(depfile, root_build_dir),
98    "--node",
99    rebase_path(nodejs_path, root_build_dir),
100    "--babel-js",
101    rebase_path(_babel_js, root_build_dir),
102    "--ets-loader-src-dir",
103    rebase_path(_ets_loader_dir + "/src", root_build_dir),
104    "--babel-config-js",
105    rebase_path(_babel_config_js, root_build_dir),
106    "--uglify-source-js",
107    rebase_path(_uglify_source_js, root_build_dir),
108    "--output-dir",
109    rebase_path(ets_loader_lib_dir, root_build_dir),
110    "--declarations-file-dir",
111    rebase_path(_declarations_file_dir, root_build_dir),
112    "--build-declarations-file-js",
113    rebase_path(_build_declarations_file_js, root_build_dir),
114    "--output-declarations-dir",
115    rebase_path(ets_loader_declarations_dir, root_build_dir),
116    "--output-component-config-file",
117    rebase_path(ets_loader_component_config_file, root_build_dir),
118    "--output-form-config-file",
119    rebase_path(ets_loader_form_config_file, root_build_dir),
120  ]
121}
122
123action("build_ets_sysResource") {
124  if (is_standard_system) {
125    script = "//developtools/ace_ets2bundle/generateSysResource.py"
126  } else {
127    script = "//foundation/ace/huawei_proprietary/tools/ets-loader/generateSysResource.py"
128  }
129  outputs = [ ets_sysResource ]
130
131  _id_defined_json = "//base/global/system_resources/systemres/main/resources/base/element/id_defined.json"
132  inputs = [ _id_defined_json ]
133
134  args = [
135    "--input-json",
136    rebase_path(_id_defined_json, root_build_dir),
137    "--output-js",
138    rebase_path(ets_sysResource, root_build_dir),
139  ]
140}
141
142ets_loader_sources = [
143  "compiler/compile_plugin.js",
144  "compiler/main.js",
145  "compiler/node_modules",
146  "compiler/npm-install.js",
147  "compiler/package-lock.json",
148  "compiler/package.json",
149  "compiler/rollup.config.js",
150  "compiler/tsconfig.esm.json",
151  "compiler/tsconfig.json",
152  "compiler/webpack.config.js",
153]
154
155ohos_copy("ets_loader_deps") {
156  sources =
157      [ "//third_party/typescript/build_package/ohos-typescript-4.2.3-r2.tgz" ]
158  outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ]
159  module_source_dir = target_out_dir + "/$target_name"
160  module_install_name = ""
161  license_file = "//third_party/typescript/LICENSE"
162}
163
164ohos_copy("ets_loader") {
165  deps = [
166    ":build_ets_loader_library",
167    ":ets_loader_deps",
168  ]
169  sources = ets_loader_sources
170  deps += [ ":build_ets_sysResource" ]
171  sources += [ ets_sysResource ]
172
173  outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ]
174  module_source_dir = target_out_dir + "/$target_name"
175  module_install_name = ""
176}
177
178ohos_copy("ets_loader_component_config") {
179  deps = [ ":build_ets_loader_library" ]
180  sources = [ ets_loader_component_config_file ]
181
182  outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ]
183  module_source_dir = target_out_dir + "/$target_name"
184  module_install_name = ""
185}
186
187ohos_copy("ets_loader_form_config") {
188  deps = [ ":build_ets_loader_library" ]
189  sources = [ ets_loader_form_config_file ]
190
191  outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ]
192  module_source_dir = target_out_dir + "/$target_name"
193  module_install_name = ""
194}
195
196ohos_copy("ets_loader_library") {
197  deps = [ ":build_ets_loader_library" ]
198  sources = [ ets_loader_lib_dir ]
199  outputs = [ target_out_dir + "/$target_name" ]
200  module_source_dir = target_out_dir + "/$target_name"
201  module_install_name = ""
202}
203
204ohos_copy("components") {
205  sources = [ "compiler/components" ]
206  outputs = [ target_out_dir + "/$target_name" ]
207  module_source_dir = target_out_dir + "/$target_name"
208  module_install_name = ""
209}
210
211ohos_copy("form_components") {
212  sources = [ "compiler/form_components" ]
213  outputs = [ target_out_dir + "/$target_name" ]
214  module_source_dir = target_out_dir + "/$target_name"
215  module_install_name = ""
216}
217
218ohos_copy("server") {
219  sources = [ "compiler/server" ]
220  outputs = [ target_out_dir + "/$target_name" ]
221  module_source_dir = target_out_dir + "/$target_name"
222  module_install_name = ""
223}
224
225ohos_copy("codegen") {
226  sources = [ "compiler/codegen" ]
227  outputs = [ target_out_dir + "/$target_name" ]
228  module_source_dir = target_out_dir + "/$target_name"
229  module_install_name = ""
230}
231
232ohos_copy("ets_loader_declaration") {
233  deps = [ ":build_ets_loader_library" ]
234  sources = [ ets_loader_declarations_dir ]
235  outputs = [ target_out_dir + "/$target_name" ]
236  module_source_dir = target_out_dir + "/$target_name"
237  module_install_name = ""
238}
239
240ohos_copy("ets_loader_ark") {
241  deps = [ ":build_ets_loader_library" ]
242  sources = ets_loader_sources
243  deps += [ ":build_ets_sysResource" ]
244  sources += [ ets_sysResource ]
245  outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ]
246}
247
248ohos_copy("ets_loader_ark_lib") {
249  deps = [
250    ":build_ets_loader_library",
251    ":ets_loader_ark",
252  ]
253  sources = [ ets_loader_lib_dir ]
254  outputs = [ target_out_dir + "/ets_loader_ark/lib" ]
255}
256
257ohos_copy("ets_loader_ark_declaration") {
258  deps = [
259    ":build_ets_loader_library",
260    ":ets_loader_ark",
261  ]
262  sources = [ ets_loader_declarations_dir ]
263  outputs = [ target_out_dir + "/ets_loader_ark/declarations" ]
264}
265
266ohos_copy("ets_loader_ark_components") {
267  deps = [
268    ":build_ets_loader_library",
269    ":ets_loader_ark",
270  ]
271  sources = [ "compiler/components" ]
272  outputs = [ target_out_dir + "/ets_loader_ark/components" ]
273}
274
275ohos_copy("ets_loader_ark_form_components") {
276  deps = [
277    ":build_ets_loader_library",
278    ":ets_loader_ark",
279  ]
280  sources = [ "compiler/form_components" ]
281  outputs = [ target_out_dir + "/ets_loader_ark/form_components" ]
282}
283
284ohos_copy("ets_loader_ark_server") {
285  deps = [
286    ":build_ets_loader_library",
287    ":ets_loader_ark",
288  ]
289  sources = [ "compiler/server" ]
290  outputs = [ target_out_dir + "/ets_loader_ark/server" ]
291}
292
293ohos_copy("ets_loader_ark_codegen") {
294  deps = [
295    ":build_ets_loader_library",
296    ":ets_loader_ark",
297  ]
298  sources = [ "compiler/codegen" ]
299  outputs = [ target_out_dir + "/ets_loader_ark/codegen" ]
300}
301
302ohos_copy("ohos_declaration_ets_ark") {
303  deps = []
304  if (sdk_build_public) {
305    deps += [ "//out/sdk-public/public_interface/sdk-js:ohos_declaration_ets" ]
306  } else {
307    deps += [ "//interface/sdk-js:ohos_declaration_ets" ]
308  }
309
310  sources = [ root_out_dir + "/ohos_declaration/ohos_declaration_ets" ]
311
312  outputs = [ target_out_dir + "/../api" ]
313}
314
315ohos_copy("ets_loader_ark_hap") {
316  sources = common_api_src
317  deps = [
318    ":ets_loader_ark",
319    ":ets_loader_ark_codegen",
320    ":ets_loader_ark_components",
321    ":ets_loader_ark_declaration",
322    ":ets_loader_ark_form_components",
323    ":ets_loader_ark_lib",
324    ":ets_loader_ark_server",
325    ":ohos_declaration_ets_ark",
326  ]
327  outputs = [ target_out_dir + "/../../developtools/api/{{source_file_part}}" ]
328  module_install_name = ""
329}
330