• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021-2024 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/runtime_core/ark_config.gni")
15
16foreach(plugin, enabled_plugins) {
17  print("plugin $plugin is enabled")
18}
19
20group("arkcompiler_params") {
21  deps = [ "libpandafile:arkcompiler_params" ]
22}
23
24group("ark_device_packages") {
25  deps = [ "$ark_root/verifier:libarkverifier" ]
26}
27
28group("ark_packages") {
29  deps = []
30  if (host_os != "mac") {
31    deps += [
32      "$ark_root/libpandabase:libarkbase",
33      "$ark_root/libpandafile:libarkfile",
34      "$ark_root/libziparchive:libarkziparchive",
35    ]
36  }
37
38  foreach(plugin, enabled_plugins) {
39    deps += [ "$ark_root/plugins/$plugin:ark_packages" ]
40  }
41}
42
43group("ark_host_linux_tools_packages") {
44  deps = []
45  if (host_os != "mac") {
46    deps += [
47      "$ark_root/abc2program:abc2prog(${host_toolchain})",
48      "$ark_root/disassembler:ark_disasm(${host_toolchain})",
49      "$ark_root/libpandabase:libarkbase(${host_toolchain})",
50      "$ark_root/libpandafile:libarkfile(${host_toolchain})",
51      "$ark_root/libziparchive:libarkziparchive(${host_toolchain})",
52      "$ark_root/panda_guard:panda_guard(${host_toolchain})",
53      "$ark_root/verifier:ark_verifier(${host_toolchain})",
54    ]
55  }
56  foreach(plugin, enabled_plugins) {
57    deps += [ "$ark_root/plugins/$plugin:ark_host_linux_tools_packages" ]
58  }
59}
60
61group("ark_host_windows_tools_packages") {
62  deps = []
63  if (host_os != "mac") {
64    deps += [
65      "$ark_root/abc2program:abc2prog($build_root/toolchain/mingw:mingw_x86_64)",
66      "$ark_root/disassembler:ark_disasm($build_root/toolchain/mingw:mingw_x86_64)",
67      "$ark_root/panda_guard:panda_guard($build_root/toolchain/mingw:mingw_x86_64)",
68      "$ark_root/verifier:ark_verifier($build_root/toolchain/mingw:mingw_x86_64)",
69    ]
70  }
71
72  foreach(plugin, enabled_plugins) {
73    deps += [ "$ark_root/plugins/$plugin:ark_host_windows_tools_packages" ]
74  }
75}
76
77group("ark_host_mac_tools_packages") {
78  deps = []
79  if (host_os == "mac") {
80    if (host_cpu == "arm64") {
81      deps += [
82        "$ark_root/abc2program:abc2prog($build_root/toolchain/mac:clang_arm64)",
83        "$ark_root/disassembler:ark_disasm($build_root/toolchain/mac:clang_arm64)",
84        "$ark_root/libpandabase:libarkbase($build_root/toolchain/mac:clang_arm64)",
85        "$ark_root/libpandafile:libarkfile($build_root/toolchain/mac:clang_arm64)",
86        "$ark_root/libziparchive:libarkziparchive($build_root/toolchain/mac:clang_arm64)",
87        "$ark_root/panda_guard:panda_guard($build_root/toolchain/mac:clang_arm64)",
88        "$ark_root/verifier:ark_verifier($build_root/toolchain/mac:clang_arm64)",
89      ]
90    } else {
91      deps += [
92        "$ark_root/abc2program:abc2prog($build_root/toolchain/mac:clang_x64)",
93        "$ark_root/disassembler:ark_disasm($build_root/toolchain/mac:clang_x64)",
94        "$ark_root/libpandabase:libarkbase($build_root/toolchain/mac:clang_x64)",
95        "$ark_root/libpandafile:libarkfile($build_root/toolchain/mac:clang_x64)",
96        "$ark_root/libziparchive:libarkziparchive($build_root/toolchain/mac:clang_x64)",
97        "$ark_root/panda_guard:panda_guard($build_root/toolchain/mac:clang_x64)",
98        "$ark_root/verifier:ark_verifier($build_root/toolchain/mac:clang_x64)",
99      ]
100    }
101  }
102
103  foreach(plugin, enabled_plugins) {
104    deps += [ "$ark_root/plugins/$plugin:ark_host_mac_tools_packages" ]
105  }
106}
107
108if (!ark_standalone_build) {
109  group("ark_host_ohos_tools_packages") {
110    deps = []
111    if (host_os != "mac") {
112      deps += [ "$ark_root/disassembler:ark_disasm($build_root/toolchain/ohos:ohos_clang_arm64)" ]
113    }
114    foreach(plugin, enabled_plugins) {
115      deps += [ "$ark_root/plugins/$plugin:ark_host_ohos_tools_packages" ]
116    }
117  }
118}
119
120# Common config for ark source
121config("ark_config") {
122  visibility = [
123    "./*",
124    "//arkcompiler/ets_frontend/*",
125  ]
126
127  include_dirs = [ "$ark_root" ]
128  defines = [ "PANDA_TARGET_MOBILE_WITH_MANAGED_LIBS=1" ]
129
130  if (is_linux) {
131    defines += [
132      "PANDA_TARGET_UNIX",
133      "PANDA_TARGET_LINUX",
134      "PANDA_WITH_BYTECODE_OPTIMIZER",
135      "PANDA_WITH_COMPILER",
136      "PANDA_USE_FUTEX",
137    ]
138  } else if (is_mingw) {
139    defines += [
140      "PANDA_TARGET_WINDOWS",
141      "PANDA_WITH_BYTECODE_OPTIMIZER",
142      "PANDA_WITH_COMPILER",
143      "_CRTBLD",
144      "__LIBMSVCRT__",
145    ]
146  } else if (is_mac) {
147    defines += [
148      "PANDA_TARGET_UNIX",
149      "PANDA_TARGET_MACOS",
150      "PANDA_WITH_BYTECODE_OPTIMIZER",
151      "PANDA_WITH_COMPILER",
152    ]
153  } else if (target_os == "ios") {
154    defines += [
155      "PANDA_TARGET_UNIX",
156      "PANDA_TARGET_IOS",
157      "PANDA_WITH_BYTECODE_OPTIMIZER",
158      "PANDA_WITH_COMPILER",
159    ]
160  } else if (is_mob) {
161    defines += [
162      "PANDA_TARGET_OHOS",
163      "PANDA_TARGET_UNIX",
164      "PANDA_USE_FUTEX",
165      "PANDA_TARGET_MOBILE",
166      "PANDA_TARGET_MOBILE_WITH_NATIVE_LIBS",
167    ]
168  } else if (is_ohos) {
169    if (is_build_sdk) {
170      defines += [
171        "PANDA_TARGET_OHOS",
172        "PANDA_TARGET_UNIX",
173        "PANDA_WITH_BYTECODE_OPTIMIZER",
174        "PANDA_USE_FUTEX",
175      ]
176    } else {
177      defines += [
178        "PANDA_TARGET_OHOS",
179        "PANDA_TARGET_UNIX",
180        "PANDA_USE_FUTEX",
181      ]
182    }
183  } else {
184    defines += [
185      "PANDA_TARGET_UNIX",
186      "PANDA_USE_FUTEX",
187    ]
188  }
189
190  if (current_os == "android" && defined(is_arkui_x) && is_arkui_x) {
191    defines += [ "PANDA_TARGET_ARKUI_X" ]
192  }
193
194  if (enable_hilog) {
195    defines += [ "ENABLE_HILOG" ]
196  }
197
198  if (!is_debug) {
199    defines += [ "NDEBUG" ]
200  }
201
202  cflags_cc = [
203    "-std=c++17",
204    "-pedantic",
205    "-Wall",
206    "-Wextra",
207    "-Werror",
208    "-fno-rtti",
209    "-fno-exceptions",
210    "-Wno-invalid-offsetof",
211
212    "-Wno-gnu-statement-expression",
213    "-Wno-unused-parameter",
214    "-Wno-unused-result",
215    "-Wno-unused-but-set-variable",
216  ]
217
218  cflags_c = []
219
220  if (!is_mac && use_pbqp) {
221    cflags_cc += [
222      # PBQP regalloc
223      "-mllvm",
224      "-regalloc=pbqp",
225    ]
226  }
227
228  if (is_fastverify) {
229    cflags_cc += [
230      "-O3",
231      "-ggdb3",
232      "-fno-omit-frame-pointer",
233      "-D_GLIBCXX_ASSERTIONS",
234    ]
235    cflags_c += [
236      "-O3",
237      "-ggdb3",
238      "-fno-omit-frame-pointer",
239      "-D_GLIBCXX_ASSERTIONS",
240    ]
241  } else if (is_debug) {
242    cflags_cc += [
243      "-Og",
244      "-ggdb3",
245    ]
246  }
247
248  if (enable_relayout_profile) {
249    defines += [ "PANDA_ENABLE_RELAYOUT_PROFILE" ]
250  }
251
252  configs = []
253  foreach(plugin, enabled_plugins) {
254    configs += [ "$ark_root/plugins/$plugin:ark_config" ]
255  }
256
257  if (current_cpu == "arm") {
258    cflags_cc += [
259      "-march=armv7-a",
260      "-mfloat-abi=${arm_float_abi}",
261      "-marm",
262      "-mfpu=vfp",
263    ]
264
265    if (arm_float_abi == "soft") {
266      defines += [ "PANDA_TARGET_ARM32_ABI_SOFT=1" ]
267    } else if (arm_float_abi == "softfp") {
268      defines += [ "PANDA_TARGET_ARM32_ABI_SOFTFP=1" ]
269    } else if (arm_float_abi == "hard") {
270      defines += [ "PANDA_TARGET_ARM32_ABI_HARD=1" ]
271    }
272
273    defines += [ "PANDA_TARGET_ARM32" ]
274  } else if (current_cpu == "arm64") {
275    defines += [
276      "PANDA_TARGET_ARM64",
277      "PANDA_TARGET_64",
278      "PANDA_ENABLE_GLOBAL_REGISTER_VARIABLES",
279      "PANDA_USE_32_BIT_POINTER",
280    ]
281  } else if (current_cpu == "x86") {
282    defines += [ "PANDA_TARGET_X86" ]
283  } else if (current_cpu == "amd64" || current_cpu == "x64" ||
284             current_cpu == "x86_64") {
285    defines += [
286      "PANDA_TARGET_64",
287      "PANDA_TARGET_AMD64",
288      "PANDA_USE_32_BIT_POINTER",
289    ]
290  }
291}
292
293plugins_yamls = []
294foreach(plugin, enabled_plugins) {
295  plugin_dir = "$ark_root/plugins/$plugin"
296  source_files = read_file("$plugin_dir/subproject_sources.gn", "scope")
297
298  if (defined(source_files.option_yaml_path)) {
299    plugins_yamls += [ "$plugin_dir/${source_files.option_yaml_path}" ]
300  }
301
302  source_files = {
303  }
304}
305
306concat_yamls("concat_plugins_yamls") {
307  output_file = "$target_gen_dir/plugin_options.yaml"
308  default_file = "$ark_root/templates/plugin_options.yaml"
309  add_yamls = plugins_yamls
310}
311
312inst_templates_yamls = []
313foreach(plugin, enabled_plugins) {
314  plugin_dir = "$ark_root/plugins/$plugin"
315  source_files = read_file("$plugin_dir/subproject_sources.gn", "scope")
316  if (defined(source_files.inst_templates_yaml_path)) {
317    inst_templates_yamls +=
318        [ "$plugin_dir/${source_files.inst_templates_yaml_path}" ]
319  }
320  source_files = {
321  }
322}
323
324concat_yamls("concat_inst_templates_yamls") {
325  output_file = "$target_gen_dir/compiler/generated/inst_templates.yaml"
326  default_file = "$ark_root/compiler/optimizer/ir_builder/inst_templates.yaml"
327  add_yamls = inst_templates_yamls
328}
329
330group("ark_host_defectscanaux_tools") {
331  deps = []
332  if (host_os == "linux") {
333    deps += [ ":ark_host_linux_defectscanaux_unittest" ]
334    if (host_cpu != "arm64") {
335      deps += [ ":ark_host_win_defectscanaux_unittest" ]
336    }
337  } else if (host_os == "mac") {
338    deps += [ ":ark_host_mac_defectscanaux_unittest" ]
339  }
340}
341
342group("ark_host_linux_defectscanaux_unittest") {
343  deps = []
344  if (host_os == "linux") {
345    deps += [ "$ark_root/libark_defect_scan_aux/tests/unittest:defect_scan_aux_demo(${host_toolchain})" ]
346  }
347}
348
349group("ark_host_win_defectscanaux_unittest") {
350  deps = []
351  if (host_os == "linux") {
352    deps += [ "$ark_root/libark_defect_scan_aux/tests/unittest:defect_scan_aux_demo($build_root/toolchain/mingw:mingw_x86_64)" ]
353  }
354}
355
356group("ark_host_mac_defectscanaux_unittest") {
357  deps = []
358  if (host_os == "mac") {
359    if (host_cpu == "arm64") {
360      deps += [ "$ark_root/libark_defect_scan_aux/tests/unittest:defect_scan_aux_demo($build_root/toolchain/mac:clang_arm64)" ]
361    } else {
362      deps += [ "$ark_root/libark_defect_scan_aux/tests/unittest:defect_scan_aux_demo($build_root/toolchain/mac:clang_x64)" ]
363    }
364  }
365}
366
367group("runtime_core_host_unittest") {
368  testonly = true
369  deps = [
370    "$ark_root/abc2program/tests:host_unittest",
371    "$ark_root/arkplatform/tests:host_unittest",
372    "$ark_root/assembler/tests:host_unittest",
373    "$ark_root/bytecode_optimizer/tests:host_unittest",
374    "$ark_root/compiler/tests:host_unittest",
375    "$ark_root/disassembler/tests:host_unittest",
376    "$ark_root/libark_defect_scan_aux/tests/unittest:host_unittest",
377    "$ark_root/libpandafile/tests:host_unittest",
378    "$ark_root/libziparchive/tests:host_unittest",
379    "$ark_root/platforms/tests:host_unittest",
380    "$ark_root/verifier/tests:host_unittest",
381  ]
382  if (!ark_standalone_build) {
383    deps += [
384      "$ark_root/libpandabase/tests:host_unittest",
385      "$ark_root/panda_guard/tests:host_unittest",
386    ]
387  }
388}
389
390if (!ark_standalone_build) {
391  group("runtime_core_unittest") {
392    testonly = true
393    deps = [
394      "$ark_root/arkplatform/tests:unittest",
395      "$ark_root/libpandabase/tests:unittest",
396      "$ark_root/libpandafile/tests:unittest",
397      "$ark_root/libziparchive/tests:unittest",
398    ]
399  }
400
401  group("verifier_host_unittest") {
402    testonly = true
403    deps = [ "$ark_root/verifier/tests:host_unittest" ]
404  }
405
406  group("compiler_host_unittest") {
407    testonly = true
408    deps = [ "$ark_root/compiler/tests:host_unittest" ]
409  }
410
411  group("arkplatform_host_unittest") {
412    testonly = true
413    deps = [ "$ark_root/arkplatform/tests:host_unittest" ]
414  }
415
416  group("arkplatform_unittest") {
417    testonly = true
418    deps = [ "$ark_root/arkplatform/tests:unittest" ]
419  }
420}
421