• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2022 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("//arkcompiler/runtime_core/ark_config.gni")
16
17src_dir = target_out_dir + "/src"
18src_dir_full_path = rebase_path("${ts2abc_root}/src")
19arguments = [ "-c" ]
20arguments += [ "ls ${src_dir_full_path} " ]
21src_files = exec_script("/bin/sh", arguments, "list lines")
22
23foreach(file, src_files) {
24  ohos_copy("ts2abc_src_${file}") {
25    sources = [ "${ts2abc_root}/src/${file}" ]
26    outputs = [ "${src_dir}/${file}" ]
27    module_install_name = ""
28  }
29}
30
31group("ts2abc_src") {
32  deps = []
33  foreach(file, src_files) {
34    deps += [ ":ts2abc_src_${file}" ]
35  }
36}
37
38ohos_copy("node_modules") {
39  sources = [ rebase_path("${node_modules}") ]
40  outputs = [ target_out_dir + "/node_modules" ]
41  module_install_name = ""
42}
43
44ohos_prebuilt_etc("js_node_modules_ts2abc_linux") {
45  source = rebase_path("${node_modules}")
46  output = target_out_dir + "/js_linux/${source}"
47  part_name = "ets_frontend"
48  subsystem_name = "arkcompiler"
49}
50
51ohos_prebuilt_etc("js_node_modules_ts2abc_win") {
52  source = rebase_path("${node_modules}")
53  output = target_out_dir + "/js_win/${source}"
54  part_name = "ets_frontend"
55  subsystem_name = "arkcompiler"
56}
57
58ohos_prebuilt_etc("js_node_modules_ts2abc_mac") {
59  source = rebase_path("${node_modules}")
60  output = target_out_dir + "/js_mac/${source}"
61  part_name = "ets_frontend"
62  subsystem_name = "arkcompiler"
63}
64
65ohos_prebuilt_etc("ets_node_modules_ts2abc_linux") {
66  source = rebase_path("${node_modules}")
67  output = target_out_dir + "/ets_linux/${source}"
68  part_name = "ets_frontend"
69  subsystem_name = "arkcompiler"
70}
71
72ohos_prebuilt_etc("ets_node_modules_ts2abc_win") {
73  source = rebase_path("${node_modules}")
74  output = target_out_dir + "/ets_win/${source}"
75  part_name = "ets_frontend"
76  subsystem_name = "arkcompiler"
77}
78
79ohos_prebuilt_etc("ets_node_modules_ts2abc_mac") {
80  source = rebase_path("${node_modules}")
81  output = target_out_dir + "/ets_mac/${source}"
82  part_name = "ets_frontend"
83  subsystem_name = "arkcompiler"
84}
85
86ohos_copy("config_files") {
87  sources = [
88    "${ts2abc_root}/package-lock.json",
89    "${ts2abc_root}/package.json",
90    "${ts2abc_root}/tsconfig.json",
91    "${ts2abc_root}/webpack.config.js",
92  ]
93
94  outputs = [ target_out_dir + "/{{source_file_part}}" ]
95  module_install_name = ""
96}
97
98ohos_copy("ts2abc_deps") {
99  sources =
100      [ "//third_party/typescript/build_package/ohos-typescript-4.2.3-r2.tgz" ]
101
102  outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ]
103  module_source_dir = target_out_dir + "/$target_name"
104  module_install_name = ""
105  license_file = "//third_party/typescript/LICENSE"
106  part_name = "ets_frontend"
107  subsystem_name = "arkcompiler"
108}
109
110ohos_copy("ts2abc_deps_ets") {
111  sources =
112      [ "//third_party/typescript/build_package/ohos-typescript-4.2.3-r2.tgz" ]
113
114  outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ]
115  module_source_dir = target_out_dir + "/$target_name"
116  module_install_name = ""
117  license_file = "//third_party/typescript/LICENSE"
118  part_name = "ets_frontend"
119  subsystem_name = "arkcompiler"
120}
121
122ohos_copy("ts2abc_deps_win") {
123  sources =
124      [ "//third_party/typescript/build_package/ohos-typescript-4.2.3-r2.tgz" ]
125
126  outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ]
127  module_source_dir = target_out_dir + "/$target_name"
128  module_install_name = ""
129  license_file = "//third_party/typescript/LICENSE"
130  part_name = "ets_frontend"
131  subsystem_name = "arkcompiler"
132}
133
134ohos_copy("ts2abc_deps_win_ets") {
135  sources =
136      [ "//third_party/typescript/build_package/ohos-typescript-4.2.3-r2.tgz" ]
137
138  outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ]
139  module_source_dir = target_out_dir + "/$target_name"
140  module_install_name = ""
141  license_file = "//third_party/typescript/LICENSE"
142  part_name = "ets_frontend"
143  subsystem_name = "arkcompiler"
144}
145
146ohos_copy("ts2abc_deps_mac") {
147  sources =
148      [ "//third_party/typescript/build_package/ohos-typescript-4.2.3-r2.tgz" ]
149
150  outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ]
151  module_source_dir = target_out_dir + "/$target_name"
152  module_install_name = ""
153  license_file = "//third_party/typescript/LICENSE"
154  part_name = "ets_frontend"
155  subsystem_name = "arkcompiler"
156}
157
158ohos_copy("ts2abc_deps_mac_ets") {
159  sources =
160      [ "//third_party/typescript/build_package/ohos-typescript-4.2.3-r2.tgz" ]
161
162  outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ]
163  module_source_dir = target_out_dir + "/$target_name"
164  module_install_name = ""
165  license_file = "//third_party/typescript/LICENSE"
166  part_name = "ets_frontend"
167  subsystem_name = "arkcompiler"
168}
169
170action("ts2abc_diagnostic_ts") {
171  visibility = [ ":*" ]
172  script = "scripts/gen_diagnostic.rb"
173  args = [
174    "--template",
175    rebase_path("templates/diagnostic.ts.erb", root_build_dir),
176    "--data",
177    rebase_path("scripts/diagnosticMessages.json", root_build_dir),
178    "--output",
179    rebase_path("${src_dir}/diagnostic.ts"),
180  ]
181
182  outputs = [ "${src_dir}/diagnostic.ts" ]
183  deps = [ "$ts2abc_root:ts2abc_src" ]
184}
185
186ark_gen_file("ts2abc_irnodes_ts") {
187  template_file = "templates/irnodes.ts.erb"
188  data_file = "$root_gen_dir/isa/isa.yaml"
189  requires = [
190    "$ark_root/isa/isapi.rb",
191    "$ark_root/libpandafile/pandafile_isapi.rb",
192  ]
193  output_file = "$src_dir/irnodes.ts"
194  extra_dependencies = [
195    "$ts2abc_root:ts2abc_src",
196    "$ark_root/isa:isa_combine",
197  ]
198}
199
200action("npm_run_build") {
201  visibility = [ ":*" ]
202  deps = [
203    "$ts2abc_root:config_files",
204    "$ts2abc_root:node_modules",
205    "$ts2abc_root:ts2abc_diagnostic_ts",
206    "$ts2abc_root:ts2abc_irnodes_ts",
207    "$ts2abc_root:ts2abc_src",
208  ]
209
210  if (is_linux || is_mingw || is_mac) {
211    deps += [ "$ts2abc_root/ts2abc:ts2abc" ]
212  }
213
214  script = "${ts2abc_root}/scripts/run.py"
215  args = [
216    "--src-dir",
217    rebase_path(ts2abc_root),
218    "--dist-dir",
219    rebase_path(target_out_dir),
220    "--node",
221    rebase_path(node_path),
222    "--node-modules",
223    rebase_path(node_modules),
224  ]
225
226  if (is_linux) {
227    args += [
228      "--platform",
229      "linux",
230      "--js2abc",
231      rebase_path("${root_out_dir}/arkcompiler/ets_frontend/js2abc"),
232    ]
233  } else if (is_mingw) {
234    args += [
235      "--platform",
236      "win",
237      "--js2abc",
238      rebase_path("${root_out_dir}/arkcompiler/ets_frontend/js2abc.exe"),
239    ]
240  } else if (is_mac) {
241    args += [
242      "--platform",
243      "mac",
244      "--js2abc",
245      rebase_path("${root_out_dir}/arkcompiler/ets_frontend/js2abc"),
246    ]
247  }
248
249  if (is_debug) {
250    args += [
251      "--buildMode",
252      "debug",
253    ]
254  } else {
255    args += [
256      "--buildMode",
257      "release",
258    ]
259  }
260
261  outputs = []
262  if (is_mingw) {
263    outputs += [ "${root_out_dir}/arkcompiler/ets_frontend/build-win" ]
264  } else if (is_mac) {
265    outputs += [ "${root_out_dir}/arkcompiler/ets_frontend/build-mac" ]
266  } else {
267    outputs += [ "${root_out_dir}/arkcompiler/ets_frontend/build" ]
268  }
269}
270
271if (is_linux) {
272  ohos_copy("ts2abc_build") {
273    deps = [ "$ts2abc_root:npm_run_build" ]
274    sources = [ "${root_out_dir}/arkcompiler/ets_frontend/build" ]
275    outputs = [ "${target_out_dir}/build-tmp" ]
276    module_source_dir = "${root_out_dir}/arkcompiler/ets_frontend/build"
277    module_install_name = ""
278  }
279
280  ohos_copy("ts2abc_build_ets") {
281    deps = [ "$ts2abc_root:npm_run_build" ]
282
283    sources = [ "${root_out_dir}/arkcompiler/ets_frontend/build" ]
284    outputs = [ "${root_out_dir}/arkcompiler/ets_frontend/build-ets" ]
285    module_source_dir = "${root_out_dir}/arkcompiler/ets_frontend/build-ets"
286    module_install_name = ""
287  }
288}
289
290if (is_mingw) {
291  ohos_copy("ts2abc_build_win") {
292    deps = [ "$ts2abc_root:npm_run_build" ]
293    sources = [ "${root_out_dir}/arkcompiler/ets_frontend/build-win" ]
294    outputs = [ "${target_out_dir}/build-tmp" ]
295    module_source_dir = "${root_out_dir}/arkcompiler/ets_frontend/build-win"
296    module_install_name = ""
297  }
298
299  ohos_copy("ts2abc_build_win_ets") {
300    deps = [ "$ts2abc_root:npm_run_build" ]
301    sources = [ "${root_out_dir}/arkcompiler/ets_frontend/build-win" ]
302    outputs = [ "${root_out_dir}/arkcompiler/ets_frontend/build-win-ets" ]
303    module_source_dir = "${root_out_dir}/arkcompiler/ets_frontend/build-win-ets"
304    module_install_name = ""
305  }
306}
307
308if (is_mac) {
309  ohos_copy("ts2abc_build_mac") {
310    deps = [ "$ts2abc_root:npm_run_build" ]
311    sources = [ "${root_out_dir}/arkcompiler/ets_frontend/build-mac" ]
312    outputs = [ "${target_out_dir}/build-tmp" ]
313    module_source_dir = "${root_out_dir}/arkcompiler/ets_frontend/build-mac"
314    module_install_name = ""
315  }
316
317  ohos_copy("ts2abc_build_mac_ets") {
318    deps = [ "$ts2abc_root:npm_run_build" ]
319    sources = [ "${root_out_dir}/arkcompiler/ets_frontend/build-mac" ]
320    outputs = [ "${root_out_dir}/arkcompiler/ets_frontend/build-mac-ets" ]
321    module_source_dir = "${root_out_dir}/arkcompiler/ets_frontend/build-mac-ets"
322    module_install_name = ""
323  }
324}
325
326ohos_copy("panda_ts2abc") {
327  sources = [ "${ts2abc_root}/scripts/ts2abc.js" ]
328
329  outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ]
330  module_source_dir = target_out_dir + "/$target_name/"
331  module_install_name = ""
332}
333
334ohos_copy("panda_ts2abc_ets") {
335  sources = [ "${ts2abc_root}/scripts/ts2abc.js" ]
336  outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ]
337  module_source_dir = target_out_dir + "/$target_name/"
338  module_install_name = ""
339}
340
341ohos_copy("ts2abc_js_file") {
342  sources = [ "${ts2abc_root}/scripts/ts2abc.js" ]
343  outputs = [ target_out_dir + "/{{source_file_part}}" ]
344}
345
346group("ark_ts2abc_build") {
347  deps = []
348  if (host_os != "mac") {
349    deps += [
350      "${ts2abc_root}:ts2abc_build(${toolchain_linux})",
351      "${ts2abc_root}:ts2abc_build_ets(${toolchain_linux})",
352    ]
353  } else {
354    deps += [
355      "${ts2abc_root}:ts2abc_build_mac(${toolchain_mac})",
356      "${ts2abc_root}:ts2abc_build_mac_ets(${toolchain_mac})",
357    ]
358  }
359}
360
361group("ark_ts2abc_build_win") {
362  deps = [
363    "${ts2abc_root}:ts2abc_build_win(${toolchain_win})",
364    "${ts2abc_root}:ts2abc_build_win_ets(${toolchain_win})",
365  ]
366}
367
368ohos_copy("copy_ts2abc_tests") {
369  sources = [ "${ts2abc_root}/tests" ]
370  deps = [ ":npm_run_build" ]
371
372  outputs = [ target_out_dir + "/tests" ]
373  module_install_name = ""
374}
375
376group("ts2abc_unittests") {
377  if (host_os == "linux") {
378    testonly = true
379    deps = [
380      "tests:ts2abc_ts_instruction_type_test(${toolchain_linux})",
381      "tests:ts2abc_ts_type_system_test(${toolchain_linux})",
382      "tests:ts2abc_ts_ut_test(${toolchain_linux})",
383    ]
384  }
385}
386