• 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/timers.cpp",
92    "$ark_root/libpandabase/utils/type_converter.cpp",
93    "$ark_root/libpandabase/utils/utf.cpp",
94    "$ark_root/platforms/windows/libpandabase/error.cpp",
95    "$ark_root/platforms/windows/libpandabase/file.cpp",
96    "$ark_root/platforms/windows/libpandabase/filesystem.cpp",
97    "$ark_root/platforms/windows/libpandabase/library_loader.cpp",
98    "$ark_root/platforms/windows/libpandabase/mem.cpp",
99    "$ark_root/platforms/windows/libpandabase/thread.cpp",
100    "$ark_root/platforms/windows/libpandabase/trace.cpp",
101  ]
102} else {
103  libarkbase_sources = [
104    "$ark_root/libpandabase/mem/arena_allocator.cpp",
105    "$ark_root/libpandabase/mem/base_mem_stats.cpp",
106    "$ark_root/libpandabase/mem/code_allocator.cpp",
107    "$ark_root/libpandabase/mem/mem_config.cpp",
108    "$ark_root/libpandabase/mem/pool_manager.cpp",
109    "$ark_root/libpandabase/mem/pool_map.cpp",
110    "$ark_root/libpandabase/os/native_stack.cpp",
111    "$ark_root/libpandabase/os/property.cpp",
112
113    # product build
114    "$ark_root/libpandabase/os/stacktrace_stub.cpp",
115    "$ark_root/libpandabase/os/time.cpp",
116    "$ark_root/libpandabase/trace/trace.cpp",
117    "$ark_root/libpandabase/utils/json_builder.cpp",
118    "$ark_root/libpandabase/utils/json_parser.cpp",
119    "$ark_root/libpandabase/utils/logger.cpp",
120    "$ark_root/libpandabase/utils/time.cpp",
121    "$ark_root/libpandabase/utils/timers.cpp",
122    "$ark_root/libpandabase/utils/type_converter.cpp",
123    "$ark_root/libpandabase/utils/utf.cpp",
124    "$ark_root/platforms/unix/libpandabase/error.cpp",
125    "$ark_root/platforms/unix/libpandabase/file.cpp",
126    "$ark_root/platforms/unix/libpandabase/filesystem.cpp",
127    "$ark_root/platforms/unix/libpandabase/library_loader_resolve_symbol.cpp",
128    "$ark_root/platforms/unix/libpandabase/mem.cpp",
129    "$ark_root/platforms/unix/libpandabase/native_stack.cpp",
130    "$ark_root/platforms/unix/libpandabase/property.cpp",
131    "$ark_root/platforms/unix/libpandabase/thread.cpp",
132    "$ark_root/platforms/unix/libpandabase/trace.cpp",
133  ]
134
135  if (!is_mob || is_linux || current_os == "android" || target_os == "ios") {
136    libarkbase_sources +=
137        [ "$ark_root/platforms/unix/libpandabase/library_loader_load.cpp" ]
138  }
139
140  if (!is_mac && target_os != "ios") {
141    libarkbase_sources += [
142      "$ark_root/libpandabase/os/filesystem.cpp",
143      "$ark_root/platforms/unix/libpandabase/exec.cpp",
144      "$ark_root/platforms/unix/libpandabase/futex/fmutex.cpp",
145      "$ark_root/platforms/unix/libpandabase/futex/mutex.cpp",
146    ]
147  } else {
148    libarkbase_sources += [ "$ark_root/libpandabase/os/mutex.cpp" ]
149  }
150
151  if (is_mac && !is_arkui_x) {
152    libarkbase_sources += [ "$ark_root/libpandabase/os/filesystem.cpp" ]
153  }
154}
155
156if (is_debug) {
157  libarkbase_sources += [ "$ark_root/libpandabase/utils/debug.cpp" ]
158}
159
160if (current_cpu == "arm64" && !is_mac && target_os != "ios") {
161  libarkbase_sources +=
162      [ "$ark_root/libpandabase/arch/aarch64/cpu_features.cpp" ]
163} else {
164  libarkbase_sources +=
165      [ "$ark_root/libpandabase/arch/default/cpu_features.cpp" ]
166}
167
168libarkbase_configs = [
169  ":arkbase_public_config",
170  "$ark_root:ark_config",
171]
172
173group("arkbase_header_deps") {
174  deps = [
175    ":base_options_h",
176    ":events_gen",
177    ":generate_version_file",
178    ":logger_enum_gen_h",
179    ":logger_impl_gen_h",
180  ]
181}
182
183libarkbase_deps = [ ":arkbase_header_deps" ]
184
185ohos_source_set("libarkbase_static_fuzz") {
186  sources = libarkbase_sources
187
188  public_configs = libarkbase_configs
189  public_configs += [ ":arkbase_fuzz_config" ]
190
191  deps = libarkbase_deps
192
193  external_deps = [ sdk_libc_secshared_dep ]
194
195  part_name = "runtime_core"
196  subsystem_name = "arkcompiler"
197}
198
199ohos_static_library("libarkbase_static") {
200  sources = libarkbase_sources
201
202  public_configs = libarkbase_configs
203
204  deps = libarkbase_deps
205
206  if (is_arkui_x) {
207    deps += [ "$ark_third_party_root/bounds_checking_function:libsec_static" ]
208  } else if (ark_standalone_build) {
209    external_deps = [ sdk_libc_secshared_dep ]
210  } else {
211    public_external_deps = [ sdk_libc_secshared_dep ]
212  }
213
214  if (enable_hilog) {
215    public_external_deps += [ "hilog:libhilog" ]
216  }
217  part_name = "runtime_core"
218  subsystem_name = "arkcompiler"
219}
220
221ohos_shared_library("libarkbase") {
222  stack_protector_ret = false
223  deps = [ ":libarkbase_static" ]
224  external_deps = [ sdk_libc_secshared_dep ]
225  if (!is_mingw && !is_mac) {
226    output_extension = "so"
227  }
228  if (!is_standard_system) {
229    relative_install_dir = "ark"
230  }
231  part_name = "runtime_core"
232  subsystem_name = "arkcompiler"
233}
234
235ohos_source_set("libarkbase_frontend_set_static") {
236  sources = libarkbase_sources
237
238  public_configs = libarkbase_configs
239
240  deps = libarkbase_deps
241
242  if (is_arkui_x) {
243    deps += [ "$ark_third_party_root/bounds_checking_function:libsec_static" ]
244  } else {
245    external_deps = [ sdk_libc_secshared_dep ]
246  }
247
248  part_name = "runtime_core"
249  subsystem_name = "arkcompiler"
250}
251
252ohos_static_library("libarkbase_frontend_static") {
253  stack_protector_ret = false
254  deps = [ ":libarkbase_frontend_set_static" ]
255
256  part_name = "runtime_core"
257  subsystem_name = "arkcompiler"
258}
259
260action("logger_yaml_gen") {
261  script = "$ark_root/libpandabase/templates/logger_gen.rb"
262  inputs = [ "$ark_root/libpandabase/templates/logger.yaml" ]
263  outputs = [ "$root_gen_dir/libpandabase/logger.yaml" ]
264  args = [
265    "-p",
266    rebase_path("$target_gen_dir/../plugin_options.yaml", root_build_dir),
267    "-d",
268    rebase_path(inputs[0], root_build_dir),
269    "-o",
270    rebase_path(outputs[0], root_build_dir),
271  ]
272  deps = [ "$ark_root:concat_plugins_yamls" ]
273}
274
275ark_gen_file("logger_enum_gen_h") {
276  extra_dependencies = [ ":logger_yaml_gen" ]
277  template_file = "templates/logger_enum_gen.h.erb"
278  data_file = "$root_gen_dir/libpandabase/logger.yaml"
279  requires = [ "$ark_root/libpandabase/templates/logger.rb" ]
280  output_file = "$target_gen_dir/include/logger_enum_gen.h"
281}
282
283ark_gen_file("logger_impl_gen_h") {
284  extra_dependencies = [ ":logger_yaml_gen" ]
285  template_file = "templates/logger_impl_gen.inc.erb"
286  data_file = "$root_gen_dir/libpandabase/logger.yaml"
287  requires = [ "$ark_root/libpandabase/templates/logger.rb" ]
288  output_file = "$target_gen_dir/include/logger_impl_gen.inc"
289}
290