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