• 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/static_core/ark_config.gni")
15import("//arkcompiler/runtime_core/static_vm_config.gni")
16import("//build/ohos.gni")
17
18ohos_static_library("libarktsbase_package") {
19  deps = []
20  if (enable_static_vm) {
21    deps += [ ":libarktsbase_frontend_static" ]
22  }
23
24  part_name = ark_part_name
25  subsystem_name = "$ark_subsystem_name"
26}
27
28config("arkbase_public_config") {
29  include_dirs = [
30    "$ark_root_gen_dir/libpandabase",
31    "$ark_root/libpandabase",
32    "$target_gen_dir/generated",
33    "$target_gen_dir/include",
34    "$target_gen_dir/generated",
35    "$target_gen_dir",
36  ]
37
38  include_dirs += platform_include_dirs
39
40  if (ark_standalone_build) {
41    ldflags = [ "-ldl" ]
42  }
43}
44
45ark_gen_file("events_gen") {
46  template_file = "events/events_gen.h.erb"
47  data = [ "events/events.yaml" ]
48  api = [ "events/events.rb" ]
49  output_file = "$target_gen_dir/events_gen.h"
50}
51
52ark_gen_file("base_options_h") {
53  template_file = "../templates/options/options.h.erb"
54  data = [ "options.yaml" ]
55  api = [ "../templates/common.rb" ]
56  output_file = "$target_gen_dir/generated/base_options.h"
57}
58
59action("generate_version_file") {
60  script = "$ark_root/gn/build/make_version_file.sh"
61  sources = [ "$ark_root/libpandabase/templates/ark_version.h.in" ]
62  outputs = [ "$ark_root_gen_dir/libpandabase/ark_version.h" ]
63  args = [
64    rebase_path("${ark_root}", "$root_build_dir"),
65    rebase_path(sources[0], "$root_build_dir"),
66    rebase_path(outputs[0], "$root_build_dir"),
67  ]
68}
69
70if (is_mingw) {
71  libarkbase_sources = [
72    "$ark_root/libpandabase/mem/arena_allocator.cpp",
73    "$ark_root/libpandabase/mem/base_mem_stats.cpp",
74    "$ark_root/libpandabase/mem/code_allocator.cpp",
75    "$ark_root/libpandabase/mem/mem_config.cpp",
76    "$ark_root/libpandabase/mem/pool_manager.cpp",
77    "$ark_root/libpandabase/mem/pool_map.cpp",
78    "$ark_root/libpandabase/os/dfx_option.cpp",
79    "$ark_root/libpandabase/os/filesystem.cpp",
80    "$ark_root/libpandabase/os/mutex.cpp",
81    "$ark_root/libpandabase/os/native_stack.cpp",
82    "$ark_root/libpandabase/os/stacktrace_stub.cpp",
83    "$ark_root/libpandabase/os/time.cpp",
84    "$ark_root/libpandabase/taskmanager/task.cpp",
85    "$ark_root/libpandabase/taskmanager/task_scheduler.cpp",
86    "$ark_root/libpandabase/taskmanager/utils/task_selector.cpp",
87    "$ark_root/libpandabase/taskmanager/utils/task_time_stats.cpp",
88    "$ark_root/libpandabase/taskmanager/worker_thread.cpp",
89    "$ark_root/libpandabase/utils/dfx.cpp",
90    "$ark_root/libpandabase/utils/json_builder.cpp",
91    "$ark_root/libpandabase/utils/json_parser.cpp",
92    "$ark_root/libpandabase/utils/logger.cpp",
93    "$ark_root/libpandabase/utils/time.cpp",
94    "$ark_root/libpandabase/utils/type_converter.cpp",
95    "$ark_root/libpandabase/utils/utf.cpp",
96    "$ark_root/libpandabase/utils/utils.cpp",
97    "$ark_root/platforms/windows/libpandabase/error.cpp",
98    "$ark_root/platforms/windows/libpandabase/file.cpp",
99    "$ark_root/platforms/windows/libpandabase/filesystem.cpp",
100    "$ark_root/platforms/windows/libpandabase/kill.cpp",
101    "$ark_root/platforms/windows/libpandabase/library_loader.cpp",
102    "$ark_root/platforms/windows/libpandabase/mem.cpp",
103    "$ark_root/platforms/windows/libpandabase/mem_hooks.cpp",
104    "$ark_root/platforms/windows/libpandabase/system_environment.cpp",
105    "$ark_root/platforms/windows/libpandabase/thread.cpp",
106    "$ark_root/platforms/windows/libpandabase/trace.cpp",
107    "$ark_root/platforms/windowslibpandabase/cpu_affinity.cpp",
108  ]
109} else {
110  libarkbase_sources = [
111    "$ark_root/libpandabase/mem/arena_allocator.cpp",
112    "$ark_root/libpandabase/mem/base_mem_stats.cpp",
113    "$ark_root/libpandabase/mem/code_allocator.cpp",
114    "$ark_root/libpandabase/mem/mem_config.cpp",
115    "$ark_root/libpandabase/mem/pool_manager.cpp",
116    "$ark_root/libpandabase/mem/pool_map.cpp",
117    "$ark_root/libpandabase/os/dfx_option.cpp",
118    "$ark_root/libpandabase/os/filesystem.cpp",
119    "$ark_root/libpandabase/os/native_stack.cpp",
120    "$ark_root/libpandabase/os/property.cpp",
121    "$ark_root/libpandabase/taskmanager/task.cpp",
122    "$ark_root/libpandabase/taskmanager/task_scheduler.cpp",
123    "$ark_root/libpandabase/taskmanager/utils/task_selector.cpp",
124    "$ark_root/libpandabase/taskmanager/utils/task_time_stats.cpp",
125    "$ark_root/libpandabase/taskmanager/worker_thread.cpp",
126
127    # product build
128    "$ark_root/libpandabase/os/stacktrace_stub.cpp",
129    "$ark_root/libpandabase/os/time.cpp",
130    "$ark_root/libpandabase/trace/trace.cpp",
131    "$ark_root/libpandabase/utils/dfx.cpp",
132    "$ark_root/libpandabase/utils/json_builder.cpp",
133    "$ark_root/libpandabase/utils/json_parser.cpp",
134    "$ark_root/libpandabase/utils/logger.cpp",
135    "$ark_root/libpandabase/utils/terminate.cpp",
136    "$ark_root/libpandabase/utils/time.cpp",
137    "$ark_root/libpandabase/utils/type_converter.cpp",
138    "$ark_root/libpandabase/utils/utf.cpp",
139    "$ark_root/libpandabase/utils/utils.cpp",
140    "$ark_root/platforms/unix/libpandabase/cpu_affinity.cpp",
141    "$ark_root/platforms/unix/libpandabase/error.cpp",
142    "$ark_root/platforms/unix/libpandabase/file.cpp",
143    "$ark_root/platforms/unix/libpandabase/filesystem.cpp",
144    "$ark_root/platforms/unix/libpandabase/kill.cpp",
145    "$ark_root/platforms/unix/libpandabase/library_loader_resolve_symbol.cpp",
146    "$ark_root/platforms/unix/libpandabase/mem.cpp",
147    "$ark_root/platforms/unix/libpandabase/native_stack.cpp",
148    "$ark_root/platforms/unix/libpandabase/property.cpp",
149    "$ark_root/platforms/unix/libpandabase/system_environment.cpp",
150    "$ark_root/platforms/unix/libpandabase/thread.cpp",
151    "$ark_root/platforms/unix/libpandabase/trace.cpp",
152  ]
153
154  if (is_mob) {
155    libarkbase_sources +=
156        [ "$ark_root/platforms/mobile/libpandabase/library_loader_load.cpp" ]
157  } else {
158    libarkbase_sources +=
159        [ "$ark_root/platforms/unix/libpandabase/library_loader_load.cpp" ]
160  }
161
162  if (!is_mac) {
163    libarkbase_sources += [
164      "$ark_root/platforms/unix/libpandabase/exec.cpp",
165      "$ark_root/platforms/unix/libpandabase/mem_hooks.cpp",
166      "$ark_root/platforms/unix/libpandabase/pipe.cpp",
167      "$ark_root/platforms/unix/libpandabase/sighook.cpp",
168    ]
169    if (is_asan) {
170      # Futexes are not supported with ASAN
171      libarkbase_sources += [ "$ark_root/libpandabase/os/mutex.cpp" ]
172    } else {
173      libarkbase_sources += [
174        "$ark_root/platforms/unix/libpandabase/futex/fmutex.cpp",
175        "$ark_root/platforms/unix/libpandabase/futex/mutex.cpp",
176      ]
177    }
178  } else {
179    libarkbase_sources += [ "$ark_root/libpandabase/os/mutex.cpp" ]
180  }
181
182  if (is_debug) {
183    libarkbase_sources += [ "$ark_root/libpandabase/utils/debug.cpp" ]
184  }
185}
186
187if (current_cpu == "arm64") {
188  libarkbase_sources +=
189      [ "$ark_root/libpandabase/arch/aarch64/cpu_features.cpp" ]
190} else {
191  libarkbase_sources +=
192      [ "$ark_root/libpandabase/arch/default/cpu_features.cpp" ]
193}
194
195if (is_mob) {
196  copy("coherency_line_size_h") {
197    sources =
198        [ "$ark_root/platforms/mobile/libpandabase/coherency_line_size.h" ]
199    outputs = [ "$target_gen_dir/generated/coherency_line_size.h" ]
200  }
201} else {
202  copy("coherency_line_size_h") {
203    sources =
204        [ "$ark_root/platforms/common/libpandabase/coherency_line_size.h" ]
205    outputs = [ "$target_gen_dir/generated/coherency_line_size.h" ]
206  }
207}
208
209libarkbase_configs = [
210  ":arkbase_public_config",
211  "$ark_root:ark_config",
212]
213
214libarkbase_deps = [
215  ":base_options_h",
216  ":coherency_line_size_h",
217  ":events_gen",
218  ":generate_version_file",
219  ":logger_enum_gen_h",
220  ":logger_impl_gen_h",
221  ":plugins_regmasks_gen",
222  ":source_language_gen",
223]
224
225ohos_source_set("libarktsbase_static") {
226  sources = libarkbase_sources
227
228  cflags_cc = [
229    "-fvisibility=hidden",
230    "-fvisibility-inlines-hidden",
231  ]
232
233  public_configs = libarkbase_configs
234
235  deps = libarkbase_deps
236
237  external_deps = [ sdk_libc_secshared_dep ]
238
239  part_name = ark_part_name
240  subsystem_name = "$ark_subsystem_name"
241}
242
243ohos_shared_library("libarktsbase") {
244  deps = [ ":libarktsbase_static" ]
245  if (!is_mingw && !is_mac) {
246    output_extension = "so"
247  }
248  part_name = ark_part_name
249  subsystem_name = "$ark_subsystem_name"
250}
251
252ohos_source_set("libarktsbase_frontend_set_static") {
253  sources = libarkbase_sources
254
255  public_configs = libarkbase_configs
256
257  deps = libarkbase_deps
258
259  external_deps = [ sdk_libc_secshared_dep ]
260
261  part_name = ark_part_name
262  subsystem_name = "$ark_subsystem_name"
263}
264
265ohos_source_set("libarktsbase_frontend_static") {
266  deps = [ ":libarktsbase_frontend_set_static" ]
267  part_name = ark_part_name
268  subsystem_name = ark_subsystem_name
269}
270
271action("logger_yaml_gen") {
272  script = "$ark_root/libpandabase/templates/logger_gen.rb"
273  inputs = [ "$ark_root/libpandabase/templates/logger.yaml" ]
274  outputs = [ "$ark_root_gen_dir/libpandabase/logger.yaml" ]
275  args = [
276    "-p",
277    rebase_path(ark_plugin_options_yaml, root_build_dir),
278    "-d",
279    rebase_path(inputs[0], root_build_dir),
280    "-o",
281    rebase_path(outputs[0], root_build_dir),
282  ]
283  deps = [ "$ark_root:concat_plugins_yamls" ]
284}
285
286ark_gen_file("logger_enum_gen_h") {
287  extra_dependencies = [ ":logger_yaml_gen" ]
288  template_file = "templates/logger_enum_gen.h.erb"
289  data = [ "$ark_root_gen_dir/libpandabase/logger.yaml" ]
290  api = [ "$ark_root/libpandabase/templates/logger.rb" ]
291  output_file = "$target_gen_dir/include/logger_enum_gen.h"
292}
293
294ark_gen_file("logger_impl_gen_h") {
295  extra_dependencies = [ ":logger_yaml_gen" ]
296  template_file = "templates/logger_impl_gen.inc.erb"
297  data = [ "$ark_root_gen_dir/libpandabase/logger.yaml" ]
298  api = [ "$ark_root/libpandabase/templates/logger.rb" ]
299  output_file = "$target_gen_dir/include/logger_impl_gen.inc"
300}
301
302ark_gen_file("source_language_gen") {
303  extra_dependencies = [ "$ark_root:concat_plugins_yamls" ]
304  template_file = "templates/source_language.h.erb"
305  data = [ ark_plugin_options_yaml ]
306  api = [ "$ark_root/templates/plugin_options.rb" ]
307  output_file = "$target_gen_dir/generated/source_language.h"
308}
309
310ark_gen_file("plugins_regmasks_gen") {
311  extra_dependencies = [ "$ark_root:concat_plugins_yamls" ]
312  template_file = "templates/plugins_regmasks.inl.erb"
313  data = [ ark_plugin_options_yaml ]
314  api = [ "$ark_root/templates/plugin_options.rb" ]
315  output_file = "$target_gen_dir/generated/plugins_regmasks.inl"
316}
317