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