• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021-2025 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
14if ((defined(ark_standalone_build) && ark_standalone_build) || (defined(is_arkui_x) && is_arkui_x)) {
15  import("//arkcompiler/runtime_core/ark_config.gni")
16} else {
17  import("//arkcompiler/ets_frontend/ark_config.gni")
18}
19
20group("ets_frontend_build") {
21  deps = [
22    "./es2panda:es2panda_build",
23    "./merge_abc:merge_proto_abc_build",
24  ]
25}
26
27# Common config for ark source
28config("ark_config") {
29  visibility = [
30    "./*",
31    "//arkcompiler/ets_frontend/*",
32  ]
33
34  include_dirs = [ "$ark_root" ]
35  defines = [ "PANDA_TARGET_MOBILE_WITH_MANAGED_LIBS=1" ]
36
37  if (is_linux) {
38    defines += [
39      "PANDA_TARGET_UNIX",
40      "PANDA_TARGET_LINUX",
41      "PANDA_WITH_BYTECODE_OPTIMIZER",
42      "PANDA_WITH_COMPILER",
43      "PANDA_USE_FUTEX",
44    ]
45  } else if (is_mingw) {
46    defines += [
47      "PANDA_TARGET_WINDOWS",
48      "PANDA_WITH_BYTECODE_OPTIMIZER",
49      "PANDA_WITH_COMPILER",
50      "_CRTBLD",
51      "__LIBMSVCRT__",
52    ]
53  } else if (is_mac) {
54    defines += [
55      "PANDA_TARGET_UNIX",
56      "PANDA_TARGET_MACOS",
57      "PANDA_WITH_BYTECODE_OPTIMIZER",
58      "PANDA_WITH_COMPILER",
59    ]
60  } else if (target_os == "ios") {
61    defines += [
62      "PANDA_TARGET_UNIX",
63      "PANDA_TARGET_IOS",
64      "PANDA_WITH_BYTECODE_OPTIMIZER",
65      "PANDA_WITH_COMPILER",
66    ]
67  } else if (is_mob) {
68    defines += [
69      "PANDA_TARGET_OHOS",
70      "PANDA_TARGET_UNIX",
71      "PANDA_USE_FUTEX",
72      "PANDA_TARGET_MOBILE",
73      "PANDA_TARGET_MOBILE_WITH_NATIVE_LIBS",
74    ]
75  } else if (is_ohos) {
76    if (is_build_sdk) {
77      defines += [
78        "PANDA_TARGET_OHOS",
79        "PANDA_TARGET_UNIX",
80        "PANDA_WITH_BYTECODE_OPTIMIZER",
81        "PANDA_USE_FUTEX",
82      ]
83    } else {
84      defines += [
85        "PANDA_TARGET_OHOS",
86        "PANDA_TARGET_UNIX",
87        "PANDA_USE_FUTEX",
88      ]
89    }
90  } else {
91    defines += [
92      "PANDA_TARGET_UNIX",
93      "PANDA_USE_FUTEX",
94    ]
95  }
96
97  if (current_os == "android" && defined(is_arkui_x) && is_arkui_x) {
98    defines += [ "PANDA_TARGET_ARKUI_X" ]
99  }
100
101  if (enable_hilog) {
102    defines += [ "ENABLE_HILOG" ]
103  }
104
105  if (!is_debug) {
106    defines += [ "NDEBUG" ]
107  }
108
109  cflags_cc = [
110    "-std=c++17",
111    "-pedantic",
112    "-Wall",
113    "-Wextra",
114    "-Werror",
115    "-fno-rtti",
116    "-Wno-invalid-offsetof",
117
118    "-Wno-gnu-statement-expression",
119    "-Wno-unused-parameter",
120    "-Wno-unused-result",
121    "-Wno-unused-but-set-variable",
122  ]
123  if (defined(ohos_indep_compiler_enable) && !ohos_indep_compiler_enable) {
124    cflags_cc += [ "-fno-exceptions" ]
125  }
126
127  cflags_c = []
128
129  if (!is_mac && use_pbqp) {
130    cflags_cc += [
131      # PBQP regalloc
132      "-mllvm",
133      "-regalloc=pbqp",
134    ]
135  }
136
137  if (is_fastverify) {
138    cflags_cc += [
139      "-O3",
140      "-ggdb3",
141      "-gdwarf-4",
142      "-fno-omit-frame-pointer",
143      "-D_GLIBCXX_ASSERTIONS",
144    ]
145    cflags_c += [
146      "-O3",
147      "-ggdb3",
148      "-gdwarf-4",
149      "-fno-omit-frame-pointer",
150      "-D_GLIBCXX_ASSERTIONS",
151    ]
152  } else if (is_debug) {
153    cflags_cc += [
154      "-Og",
155      "-ggdb3",
156      "-gdwarf-4",
157    ]
158  }
159
160  if (enable_relayout_profile) {
161    defines += [ "PANDA_ENABLE_RELAYOUT_PROFILE" ]
162  }
163
164  configs = []
165  foreach(plugin, enabled_plugins) {
166    configs += [ "$ark_root/plugins/$plugin:ark_config" ]
167  }
168
169  if (current_cpu == "arm") {
170    cflags_cc += [
171      "-march=armv7-a",
172      "-mfloat-abi=${arm_float_abi}",
173      "-marm",
174      "-mfpu=vfp",
175    ]
176
177    if (arm_float_abi == "soft") {
178      defines += [ "PANDA_TARGET_ARM32_ABI_SOFT=1" ]
179    } else if (arm_float_abi == "softfp") {
180      defines += [ "PANDA_TARGET_ARM32_ABI_SOFTFP=1" ]
181    } else if (arm_float_abi == "hard") {
182      defines += [ "PANDA_TARGET_ARM32_ABI_HARD=1" ]
183    }
184
185    defines += [ "PANDA_TARGET_ARM32" ]
186  } else if (current_cpu == "arm64") {
187    defines += [
188      "PANDA_TARGET_ARM64",
189      "PANDA_TARGET_64",
190      "PANDA_ENABLE_GLOBAL_REGISTER_VARIABLES",
191      "PANDA_USE_32_BIT_POINTER",
192    ]
193  } else if (current_cpu == "x86") {
194    defines += [ "PANDA_TARGET_X86" ]
195  } else if (current_cpu == "amd64" || current_cpu == "x64" ||
196             current_cpu == "x86_64") {
197    defines += [
198      "PANDA_TARGET_64",
199      "PANDA_TARGET_AMD64",
200      "PANDA_USE_32_BIT_POINTER",
201    ]
202  }
203}
204