• 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
16config("arkbase_public_config") {
17  include_dirs = [
18    "$ark_root",
19    "$ark_root/libpandabase",
20    "$target_gen_dir/include",
21    "$target_gen_dir",
22  ]
23
24  if (enable_hilog) {
25    include_dirs += [ "$hilog_root/include" ]
26  }
27
28  include_dirs += platform_include_dirs
29}
30
31config("arkbase_fuzz_config") {
32  configs = [ "$build_root/config/compiler:exceptions" ]
33  defines = [ "SUPPORT_KNOWN_EXCEPTION" ]
34}
35
36ark_gen_file("events_gen") {
37  template_file = "events/events_gen.h.erb"
38  data_file = "events/events.yaml"
39  requires = [ "events/events.rb" ]
40  output_file = "$target_gen_dir/events_gen.h"
41}
42
43ark_gen_file("base_options_h") {
44  template_file = "../templates/options/options.h.erb"
45  data_file = "options.yaml"
46  requires = [ "../templates/common.rb" ]
47  output_file = "$target_gen_dir/generated/base_options.h"
48}
49
50action("generate_version_file") {
51  script = "$ark_root/gn/build/cmake_configure_file.py"
52
53  sources = [ "$ark_root/libpandabase/templates/ark_version.h.in" ]
54  outputs = [ "$root_gen_dir/libpandabase/ark_version.h" ]
55
56  hash = exec_script("$ark_root/gn/build/find_git.sh",
57                     [ rebase_path("${ark_root}", "$root_build_dir") ],
58                     "trim string")
59
60  if (hash == "") {
61    args = [
62      rebase_path(sources[0], "$root_build_dir"),
63      rebase_path(outputs[0], "$root_build_dir"),
64    ]
65  } else {
66    args = [
67      rebase_path(sources[0], "$root_build_dir"),
68      rebase_path(outputs[0], "$root_build_dir"),
69      "ARK_VERSION_GIT_HASH=${hash}",
70    ]
71  }
72}
73
74if (is_mingw) {
75  libarkbase_sources = [
76    "$ark_root/libpandabase/mem/arena_allocator.cpp",
77    "$ark_root/libpandabase/mem/base_mem_stats.cpp",
78    "$ark_root/libpandabase/mem/code_allocator.cpp",
79    "$ark_root/libpandabase/mem/mem_config.cpp",
80    "$ark_root/libpandabase/mem/pool_manager.cpp",
81    "$ark_root/libpandabase/mem/pool_map.cpp",
82    "$ark_root/libpandabase/os/filesystem.cpp",
83    "$ark_root/libpandabase/os/mutex.cpp",
84    "$ark_root/libpandabase/os/native_stack.cpp",
85    "$ark_root/libpandabase/os/stacktrace_stub.cpp",
86    "$ark_root/libpandabase/os/time.cpp",
87    "$ark_root/libpandabase/utils/json_builder.cpp",
88    "$ark_root/libpandabase/utils/json_parser.cpp",
89    "$ark_root/libpandabase/utils/logger.cpp",
90    "$ark_root/libpandabase/utils/time.cpp",
91    "$ark_root/libpandabase/utils/type_converter.cpp",
92    "$ark_root/libpandabase/utils/utf.cpp",
93    "$ark_root/platforms/windows/libpandabase/error.cpp",
94    "$ark_root/platforms/windows/libpandabase/file.cpp",
95    "$ark_root/platforms/windows/libpandabase/filesystem.cpp",
96    "$ark_root/platforms/windows/libpandabase/library_loader.cpp",
97    "$ark_root/platforms/windows/libpandabase/mem.cpp",
98    "$ark_root/platforms/windows/libpandabase/thread.cpp",
99    "$ark_root/platforms/windows/libpandabase/trace.cpp",
100  ]
101} else {
102  libarkbase_sources = [
103    "$ark_root/libpandabase/mem/arena_allocator.cpp",
104    "$ark_root/libpandabase/mem/base_mem_stats.cpp",
105    "$ark_root/libpandabase/mem/code_allocator.cpp",
106    "$ark_root/libpandabase/mem/mem_config.cpp",
107    "$ark_root/libpandabase/mem/pool_manager.cpp",
108    "$ark_root/libpandabase/mem/pool_map.cpp",
109    "$ark_root/libpandabase/os/native_stack.cpp",
110    "$ark_root/libpandabase/os/property.cpp",
111
112    # product build
113    "$ark_root/libpandabase/os/stacktrace_stub.cpp",
114    "$ark_root/libpandabase/os/time.cpp",
115    "$ark_root/libpandabase/trace/trace.cpp",
116    "$ark_root/libpandabase/utils/json_builder.cpp",
117    "$ark_root/libpandabase/utils/json_parser.cpp",
118    "$ark_root/libpandabase/utils/logger.cpp",
119    "$ark_root/libpandabase/utils/time.cpp",
120    "$ark_root/libpandabase/utils/type_converter.cpp",
121    "$ark_root/libpandabase/utils/utf.cpp",
122    "$ark_root/platforms/unix/libpandabase/error.cpp",
123    "$ark_root/platforms/unix/libpandabase/file.cpp",
124    "$ark_root/platforms/unix/libpandabase/filesystem.cpp",
125    "$ark_root/platforms/unix/libpandabase/library_loader_resolve_symbol.cpp",
126    "$ark_root/platforms/unix/libpandabase/mem.cpp",
127    "$ark_root/platforms/unix/libpandabase/native_stack.cpp",
128    "$ark_root/platforms/unix/libpandabase/property.cpp",
129    "$ark_root/platforms/unix/libpandabase/thread.cpp",
130    "$ark_root/platforms/unix/libpandabase/trace.cpp",
131  ]
132
133  if (!is_mob || is_linux || current_os == "android" || target_os == "ios") {
134    libarkbase_sources +=
135        [ "$ark_root/platforms/unix/libpandabase/library_loader_load.cpp" ]
136  }
137
138  if (!is_mac && target_os != "ios") {
139    libarkbase_sources += [
140      "$ark_root/libpandabase/os/filesystem.cpp",
141      "$ark_root/platforms/unix/libpandabase/exec.cpp",
142      "$ark_root/platforms/unix/libpandabase/futex/fmutex.cpp",
143      "$ark_root/platforms/unix/libpandabase/futex/mutex.cpp",
144    ]
145  } else {
146    libarkbase_sources += [ "$ark_root/libpandabase/os/mutex.cpp" ]
147  }
148
149  if (is_mac && !is_arkui_x) {
150    libarkbase_sources += [ "$ark_root/libpandabase/os/filesystem.cpp" ]
151  }
152}
153
154if (is_debug) {
155  libarkbase_sources += [ "$ark_root/libpandabase/utils/debug.cpp" ]
156}
157
158if (current_cpu == "arm64" && !is_mac && target_os != "ios") {
159  libarkbase_sources +=
160      [ "$ark_root/libpandabase/arch/aarch64/cpu_features.cpp" ]
161} else {
162  libarkbase_sources +=
163      [ "$ark_root/libpandabase/arch/default/cpu_features.cpp" ]
164}
165
166libarkbase_configs = [
167  ":arkbase_public_config",
168  "$ark_root:ark_config",
169]
170
171group("arkbase_header_deps") {
172  deps = [
173    ":base_options_h",
174    ":events_gen",
175    ":generate_version_file",
176    ":logger_enum_gen_h",
177    ":logger_impl_gen_h",
178  ]
179}
180
181libarkbase_deps = [ ":arkbase_header_deps" ]
182
183ohos_source_set("libarkbase_static_fuzz") {
184  sources = libarkbase_sources
185
186  public_configs = libarkbase_configs
187  public_configs += [ ":arkbase_fuzz_config" ]
188
189  deps = libarkbase_deps
190
191  external_deps = [ sdk_libc_secshared_dep ]
192
193  part_name = "runtime_core"
194  subsystem_name = "arkcompiler"
195}
196
197ohos_static_library("libarkbase_static") {
198  sources = libarkbase_sources
199
200  public_configs = libarkbase_configs
201
202  deps = libarkbase_deps
203
204  if (is_arkui_x) {
205    deps += [ "$ark_third_party_root/bounds_checking_function:libsec_static" ]
206  } else if (ark_standalone_build) {
207    external_deps = [ sdk_libc_secshared_dep ]
208  } else {
209    public_external_deps = [ sdk_libc_secshared_dep ]
210  }
211
212  if (enable_hilog) {
213    public_external_deps += [ "hilog:libhilog" ]
214  }
215  part_name = "runtime_core"
216  subsystem_name = "arkcompiler"
217}
218
219ohos_shared_library("libarkbase") {
220  stack_protector_ret = false
221  deps = [ ":libarkbase_static" ]
222  external_deps = [ sdk_libc_secshared_dep ]
223  if (!is_mingw && !is_mac) {
224    output_extension = "so"
225  }
226  if (!is_standard_system) {
227    relative_install_dir = "ark"
228  }
229  part_name = "runtime_core"
230  subsystem_name = "arkcompiler"
231}
232
233ohos_source_set("libarkbase_frontend_set_static") {
234  sources = libarkbase_sources
235
236  public_configs = libarkbase_configs
237
238  deps = libarkbase_deps
239
240  if (is_arkui_x) {
241    deps += [ "$ark_third_party_root/bounds_checking_function:libsec_static" ]
242  } else {
243    external_deps = [ sdk_libc_secshared_dep ]
244  }
245
246  part_name = "runtime_core"
247  subsystem_name = "arkcompiler"
248}
249
250ohos_static_library("libarkbase_frontend_static") {
251  stack_protector_ret = false
252  deps = [ ":libarkbase_frontend_set_static" ]
253
254  part_name = "runtime_core"
255  subsystem_name = "arkcompiler"
256}
257
258action("logger_yaml_gen") {
259  script = "$ark_root/libpandabase/templates/logger_gen.rb"
260  inputs = [ "$ark_root/libpandabase/templates/logger.yaml" ]
261  outputs = [ "$root_gen_dir/libpandabase/logger.yaml" ]
262  args = [
263    "-p",
264    rebase_path("$target_gen_dir/../plugin_options.yaml", root_build_dir),
265    "-d",
266    rebase_path(inputs[0], root_build_dir),
267    "-o",
268    rebase_path(outputs[0], root_build_dir),
269  ]
270  deps = [ "$ark_root:concat_plugins_yamls" ]
271}
272
273ark_gen_file("logger_enum_gen_h") {
274  extra_dependencies = [ ":logger_yaml_gen" ]
275  template_file = "templates/logger_enum_gen.h.erb"
276  data_file = "$root_gen_dir/libpandabase/logger.yaml"
277  requires = [ "$ark_root/libpandabase/templates/logger.rb" ]
278  output_file = "$target_gen_dir/include/logger_enum_gen.h"
279}
280
281ark_gen_file("logger_impl_gen_h") {
282  extra_dependencies = [ ":logger_yaml_gen" ]
283  template_file = "templates/logger_impl_gen.inc.erb"
284  data_file = "$root_gen_dir/libpandabase/logger.yaml"
285  requires = [ "$ark_root/libpandabase/templates/logger.rb" ]
286  output_file = "$target_gen_dir/include/logger_impl_gen.inc"
287}
288