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