• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021-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/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_packages") {
25  deps = []
26  if (host_os != "mac") {
27    deps += [
28      "$ark_root/libpandabase:libarkbase",
29      "$ark_root/libpandafile:libarkfile",
30      "$ark_root/libziparchive:libarkziparchive",
31    ]
32  }
33
34  foreach(plugin, enabled_plugins) {
35    deps += [ "$ark_root/plugins/$plugin:ark_packages" ]
36  }
37}
38
39group("ark_host_linux_tools_packages") {
40  deps = []
41  if (host_os != "mac") {
42    deps += [
43      "$ark_root/assembler:ark_asm(${host_toolchain})",
44      "$ark_root/disassembler:ark_disasm(${host_toolchain})",
45      "$ark_root/libpandabase:libarkbase(${host_toolchain})",
46      "$ark_root/libpandafile:libarkfile(${host_toolchain})",
47      "$ark_root/libziparchive:libarkziparchive(${host_toolchain})",
48    ]
49  }
50  foreach(plugin, enabled_plugins) {
51    deps += [ "$ark_root/plugins/$plugin:ark_host_linux_tools_packages" ]
52  }
53}
54
55group("ark_host_windows_tools_packages") {
56  deps = []
57  if (host_os != "mac") {
58    deps += [
59      "$ark_root/assembler:ark_asm($build_root/toolchain/mingw:mingw_x86_64)",
60      "$ark_root/disassembler:ark_disasm($build_root/toolchain/mingw:mingw_x86_64)",
61    ]
62  }
63
64  foreach(plugin, enabled_plugins) {
65    deps += [ "$ark_root/plugins/$plugin:ark_host_windows_tools_packages" ]
66  }
67}
68
69group("ark_host_mac_tools_packages") {
70  deps = []
71  if (host_os == "mac") {
72    if (host_cpu == "arm64") {
73      deps += [
74        "$ark_root/assembler:ark_asm($build_root/toolchain/mac:clang_arm64)",
75        "$ark_root/disassembler:ark_disasm($build_root/toolchain/mac:clang_arm64)",
76        "$ark_root/libpandabase:libarkbase($build_root/toolchain/mac:clang_arm64)",
77        "$ark_root/libpandafile:libarkfile($build_root/toolchain/mac:clang_arm64)",
78        "$ark_root/libziparchive:libarkziparchive($build_root/toolchain/mac:clang_arm64)",
79      ]
80    } else {
81      deps += [
82        "$ark_root/assembler:ark_asm($build_root/toolchain/mac:clang_x64)",
83        "$ark_root/disassembler:ark_disasm($build_root/toolchain/mac:clang_x64)",
84        "$ark_root/libpandabase:libarkbase($build_root/toolchain/mac:clang_x64)",
85        "$ark_root/libpandafile:libarkfile($build_root/toolchain/mac:clang_x64)",
86        "$ark_root/libziparchive:libarkziparchive($build_root/toolchain/mac:clang_x64)",
87      ]
88    }
89  }
90
91  foreach(plugin, enabled_plugins) {
92    deps += [ "$ark_root/plugins/$plugin:ark_host_mac_tools_packages" ]
93  }
94}
95
96# Common config for ark source
97config("ark_config") {
98  visibility = [
99    "./*",
100    "//arkcompiler/ets_frontend/*",
101  ]
102
103  include_dirs = [ "$ark_root" ]
104  defines = [ "PANDA_TARGET_MOBILE_WITH_MANAGED_LIBS=1" ]
105
106  if (is_linux) {
107    defines += [
108      "PANDA_TARGET_UNIX",
109      "PANDA_TARGET_LINUX",
110      "PANDA_WITH_BYTECODE_OPTIMIZER",
111      "PANDA_WITH_COMPILER",
112      "PANDA_USE_FUTEX",
113    ]
114  } else if (is_mingw) {
115    defines += [
116      "PANDA_TARGET_WINDOWS",
117      "PANDA_WITH_BYTECODE_OPTIMIZER",
118      "PANDA_WITH_COMPILER",
119      "_CRTBLD",
120      "__LIBMSVCRT__",
121    ]
122  } else if (is_mac) {
123    defines += [
124      "PANDA_TARGET_UNIX",
125      "PANDA_TARGET_MACOS",
126      "PANDA_WITH_BYTECODE_OPTIMIZER",
127      "PANDA_WITH_COMPILER",
128    ]
129  } else if (target_os == "ios") {
130    defines += [
131      "PANDA_TARGET_UNIX",
132      "PANDA_TARGET_IOS",
133      "PANDA_WITH_BYTECODE_OPTIMIZER",
134      "PANDA_WITH_COMPILER",
135    ]
136  } else if (is_mob) {
137    defines += [
138      "PANDA_TARGET_UNIX",
139      "PANDA_USE_FUTEX",
140      "PANDA_TARGET_MOBILE",
141      "PANDA_TARGET_MOBILE_WITH_NATIVE_LIBS",
142    ]
143  } else {
144    defines += [
145      "PANDA_TARGET_UNIX",
146      "PANDA_USE_FUTEX",
147    ]
148  }
149
150  if (current_os == "android" && defined(is_arkui_x) && is_arkui_x) {
151    defines += [ "PANDA_TARGET_ARKUI_X" ]
152  }
153
154  if (enable_hilog) {
155    defines += [ "ENABLE_HILOG" ]
156  }
157
158  if (!is_debug) {
159    defines += [ "NDEBUG" ]
160  }
161
162  cflags_cc = [
163    "-std=c++17",
164    "-pedantic",
165    "-Wall",
166    "-Wextra",
167    "-Werror",
168    "-fno-rtti",
169    "-fno-exceptions",
170    "-Wno-invalid-offsetof",
171
172    "-Wno-gnu-statement-expression",
173    "-Wno-unused-parameter",
174    "-Wno-unused-result",
175    "-Wno-unused-but-set-variable",
176  ]
177
178  if (!is_mac && use_pbqp) {
179    cflags_cc += [
180      # PBQP regalloc
181      "-mllvm",
182      "-regalloc=pbqp",
183    ]
184  }
185
186  if (is_debug) {
187    cflags_cc += [
188      "-Og",
189      "-ggdb3",
190    ]
191  }
192
193  if (enable_relayout_profile) {
194    defines += [ "PANDA_ENABLE_RELAYOUT_PROFILE" ]
195  }
196
197  configs = []
198  foreach(plugin, enabled_plugins) {
199    configs += [ "$ark_root/plugins/$plugin:ark_config" ]
200  }
201
202  if (current_cpu == "arm") {
203    cflags_cc += [
204      "-march=armv7-a",
205      "-mfloat-abi=${arm_float_abi}",
206      "-marm",
207      "-mfpu=vfp",
208    ]
209
210    if (arm_float_abi == "soft") {
211      defines += [ "PANDA_TARGET_ARM32_ABI_SOFT=1" ]
212    } else if (arm_float_abi == "softfp") {
213      defines += [ "PANDA_TARGET_ARM32_ABI_SOFTFP=1" ]
214    } else if (arm_float_abi == "hard") {
215      defines += [ "PANDA_TARGET_ARM32_ABI_HARD=1" ]
216    }
217
218    defines += [ "PANDA_TARGET_ARM32" ]
219  } else if (current_cpu == "arm64") {
220    defines += [
221      "PANDA_TARGET_ARM64",
222      "PANDA_TARGET_64",
223      "PANDA_ENABLE_GLOBAL_REGISTER_VARIABLES",
224      "PANDA_USE_32_BIT_POINTER",
225    ]
226  } else if (current_cpu == "x86") {
227    defines += [ "PANDA_TARGET_X86" ]
228  } else if (current_cpu == "amd64" || current_cpu == "x64" ||
229             current_cpu == "x86_64") {
230    defines += [
231      "PANDA_TARGET_64",
232      "PANDA_TARGET_AMD64",
233      "PANDA_USE_32_BIT_POINTER",
234    ]
235  }
236}
237
238plugins_yamls = []
239foreach(plugin, enabled_plugins) {
240  plugin_dir = "$ark_root/plugins/$plugin"
241  source_files = read_file("$plugin_dir/subproject_sources.gn", "scope")
242
243  if (defined(source_files.option_yaml_path)) {
244    plugins_yamls += [ "$plugin_dir/${source_files.option_yaml_path}" ]
245  }
246
247  source_files = {
248  }
249}
250
251concat_yamls("concat_plugins_yamls") {
252  output_file = "$target_gen_dir/plugin_options.yaml"
253  default_file = "$ark_root/templates/plugin_options.yaml"
254  add_yamls = plugins_yamls
255}
256
257inst_templates_yamls = []
258foreach(plugin, enabled_plugins) {
259  plugin_dir = "$ark_root/plugins/$plugin"
260  source_files = read_file("$plugin_dir/subproject_sources.gn", "scope")
261  if (defined(source_files.inst_templates_yaml_path)) {
262    inst_templates_yamls +=
263        [ "$plugin_dir/${source_files.inst_templates_yaml_path}" ]
264  }
265  source_files = {
266  }
267}
268
269concat_yamls("concat_inst_templates_yamls") {
270  output_file = "$target_gen_dir/compiler/generated/inst_templates.yaml"
271  default_file = "$ark_root/compiler/optimizer/ir_builder/inst_templates.yaml"
272  add_yamls = inst_templates_yamls
273}
274
275if (!ark_standalone_build) {
276  group("ark_host_linux_defectscanaux_lib") {
277    deps = []
278    if (host_os == "linux") {
279      deps += [ "$ark_root/libark_defect_scan_aux:libark_defect_scan_aux(${host_toolchain})" ]
280    }
281  }
282
283  group("ark_host_linux_defectscanaux_unittest") {
284    testonly = true
285    deps = []
286    if (host_os == "linux") {
287      deps += [ "$ark_root/libark_defect_scan_aux/tests/unittest:defect_scan_aux_unittest(${host_toolchain})" ]
288    }
289  }
290
291  group("runtime_core_unittest") {
292    testonly = true
293    deps = [
294      "$ark_root/libpandabase/tests:unittest",
295      "$ark_root/libpandafile/tests:unittest",
296      "$ark_root/libziparchive/tests:unittest",
297    ]
298  }
299
300  group("runtime_core_host_unittest") {
301    testonly = true
302    deps = [
303      "$ark_root/assembler/tests:host_unittest",
304      "$ark_root/bytecode_optimizer/tests:host_unittest",
305      "$ark_root/compiler/tests:host_unittest",
306      "$ark_root/libpandabase/tests:host_unittest",
307      "$ark_root/libpandafile/tests:host_unittest",
308      "$ark_root/libziparchive/tests:host_unittest",
309      "$ark_root/platforms/tests:host_unittest",
310    ]
311  }
312
313  group("compiler_host_unittest") {
314    testonly = true
315    deps = [ "$ark_root/compiler/tests:host_unittest" ]
316  }
317}
318