# Copyright (c) 2021-2022 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import("//arkcompiler/runtime_core/ark_config.gni") config("arkbase_public_config") { include_dirs = [ "$ark_root", "$ark_root/libpandabase", "$target_gen_dir/include", "$target_gen_dir", ] if (enable_hilog) { include_dirs += [ "$hilog_root/include" ] } include_dirs += platform_include_dirs if (is_arkui_x) { defines = [ "IS_ARKUI_X_TARGET" ] } } if (!ark_standalone_build && !is_arkui_x) { ohos_shared_headers("arkbase_public_headers") { include_dirs = [ "$ark_root/libpandabase", "$target_gen_dir/include", "$target_gen_dir", ] include_dirs += platform_include_dirs part_name = "runtime_core" subsystem_name = "arkcompiler" } } config("arkbase_fuzz_config") { configs = [ "$build_root/config/compiler:exceptions" ] defines = [ "SUPPORT_KNOWN_EXCEPTION" ] } ark_gen_file("events_gen") { template_file = "events/events_gen.h.erb" data_file = "events/events.yaml" requires = [ "events/events.rb" ] output_file = "$target_gen_dir/events_gen.h" } ark_gen_file("base_options_h") { template_file = "../templates/options/options.h.erb" data_file = "options.yaml" requires = [ "../templates/common.rb" ] output_file = "$target_gen_dir/generated/base_options.h" } action("generate_version_file") { script = "$ark_root/gn/build/make_version_file.sh" sources = [ "$ark_root/libpandabase/templates/ark_version.h.in" ] outputs = [ "$root_gen_dir/libpandabase/ark_version.h" ] args = [ rebase_path("${ark_root}", "$root_build_dir"), rebase_path(sources[0], "$root_build_dir"), rebase_path(outputs[0], "$root_build_dir"), ] } if (is_mingw) { libarkbase_sources = [ "$ark_root/libpandabase/mem/arena_allocator.cpp", "$ark_root/libpandabase/mem/base_mem_stats.cpp", "$ark_root/libpandabase/mem/code_allocator.cpp", "$ark_root/libpandabase/mem/mem_config.cpp", "$ark_root/libpandabase/mem/pool_manager.cpp", "$ark_root/libpandabase/mem/pool_map.cpp", "$ark_root/libpandabase/os/filesystem.cpp", "$ark_root/libpandabase/os/mutex.cpp", "$ark_root/libpandabase/os/native_stack.cpp", "$ark_root/libpandabase/os/stacktrace_stub.cpp", "$ark_root/libpandabase/os/time.cpp", "$ark_root/libpandabase/utils/json_builder.cpp", "$ark_root/libpandabase/utils/json_parser.cpp", "$ark_root/libpandabase/utils/logger.cpp", "$ark_root/libpandabase/utils/time.cpp", "$ark_root/libpandabase/utils/timers.cpp", "$ark_root/libpandabase/utils/type_converter.cpp", "$ark_root/libpandabase/utils/utf.cpp", "$ark_root/libpandabase/utils/workerQueue.cpp", "$ark_root/platforms/windows/libpandabase/error.cpp", "$ark_root/platforms/windows/libpandabase/file.cpp", "$ark_root/platforms/windows/libpandabase/filesystem.cpp", "$ark_root/platforms/windows/libpandabase/library_loader.cpp", "$ark_root/platforms/windows/libpandabase/mem.cpp", "$ark_root/platforms/windows/libpandabase/thread.cpp", "$ark_root/platforms/windows/libpandabase/trace.cpp", ] } else { libarkbase_sources = [ "$ark_root/libpandabase/mem/arena_allocator.cpp", "$ark_root/libpandabase/mem/base_mem_stats.cpp", "$ark_root/libpandabase/mem/code_allocator.cpp", "$ark_root/libpandabase/mem/mem_config.cpp", "$ark_root/libpandabase/mem/pool_manager.cpp", "$ark_root/libpandabase/mem/pool_map.cpp", "$ark_root/libpandabase/os/native_stack.cpp", "$ark_root/libpandabase/os/property.cpp", # product build "$ark_root/libpandabase/os/stacktrace_stub.cpp", "$ark_root/libpandabase/os/time.cpp", "$ark_root/libpandabase/trace/trace.cpp", "$ark_root/libpandabase/utils/json_builder.cpp", "$ark_root/libpandabase/utils/json_parser.cpp", "$ark_root/libpandabase/utils/logger.cpp", "$ark_root/libpandabase/utils/time.cpp", "$ark_root/libpandabase/utils/timers.cpp", "$ark_root/libpandabase/utils/type_converter.cpp", "$ark_root/libpandabase/utils/utf.cpp", "$ark_root/libpandabase/utils/workerQueue.cpp", "$ark_root/platforms/unix/libpandabase/error.cpp", "$ark_root/platforms/unix/libpandabase/file.cpp", "$ark_root/platforms/unix/libpandabase/filesystem.cpp", "$ark_root/platforms/unix/libpandabase/library_loader_resolve_symbol.cpp", "$ark_root/platforms/unix/libpandabase/mem.cpp", "$ark_root/platforms/unix/libpandabase/native_stack.cpp", "$ark_root/platforms/unix/libpandabase/property.cpp", "$ark_root/platforms/unix/libpandabase/thread.cpp", "$ark_root/platforms/unix/libpandabase/trace.cpp", ] if (!is_mob || is_linux || current_os == "android" || target_os == "ios") { libarkbase_sources += [ "$ark_root/platforms/unix/libpandabase/library_loader_load.cpp" ] } if (!is_mac && target_os != "ios") { libarkbase_sources += [ "$ark_root/libpandabase/os/filesystem.cpp", "$ark_root/platforms/unix/libpandabase/exec.cpp", "$ark_root/platforms/unix/libpandabase/futex/fmutex.cpp", "$ark_root/platforms/unix/libpandabase/futex/mutex.cpp", ] } else { libarkbase_sources += [ "$ark_root/libpandabase/os/mutex.cpp" ] } if (is_arkui_x && target_os == "ios") { libarkbase_sources += [ "$ark_root/libpandabase/os/filesystem.cpp" ] } if (is_mac && !is_arkui_x) { libarkbase_sources += [ "$ark_root/libpandabase/os/filesystem.cpp" ] } } if (is_debug) { libarkbase_sources += [ "$ark_root/libpandabase/utils/debug.cpp" ] } if (current_cpu == "arm64" && !is_mac && target_os != "ios") { libarkbase_sources += [ "$ark_root/libpandabase/arch/aarch64/cpu_features.cpp" ] } else { libarkbase_sources += [ "$ark_root/libpandabase/arch/default/cpu_features.cpp" ] } libarkbase_configs = [ ":arkbase_public_config", "$ark_root:ark_config", ] group("arkbase_header_deps") { deps = [ ":base_options_h", ":events_gen", ":generate_version_file", ":logger_enum_gen_h", ":logger_impl_gen_h", ] } libarkbase_deps = [ ":arkbase_header_deps" ] ohos_source_set("libarkbase_static_fuzz") { sources = libarkbase_sources public_configs = libarkbase_configs public_configs += [ ":arkbase_fuzz_config" ] deps = libarkbase_deps external_deps = [ "json:nlohmann_json_static", sdk_libc_secshared_dep, ] if (enable_hilog && defined(ohos_indep_compiler_enable) && ohos_indep_compiler_enable) { external_deps += [ "hilog:libhilog" ] } part_name = "runtime_core" subsystem_name = "arkcompiler" } ohos_static_library("libarkbase_static") { sources = libarkbase_sources public_configs = libarkbase_configs deps = libarkbase_deps if (is_arkui_x) { deps += [ "$ark_third_party_root/bounds_checking_function:libsec_static" ] } else if (ark_standalone_build) { external_deps = [ "json:nlohmann_json_static", sdk_libc_secshared_dep, ] } else { public_external_deps = [ "json:nlohmann_json_static", sdk_libc_secshared_dep, ] } if (enable_hilog) { public_external_deps += [ "hilog:libhilog" ] } part_name = "runtime_core" subsystem_name = "arkcompiler" } ohos_shared_library("libarkbase") { stack_protector_ret = false deps = [ ":libarkbase_static" ] external_deps = [ sdk_libc_secshared_dep ] if (!is_mingw && !is_mac) { output_extension = "so" } if (!is_standard_system) { relative_install_dir = "ark" } part_name = "runtime_core" subsystem_name = "arkcompiler" } ohos_source_set("libarkbase_frontend_set_static") { sources = libarkbase_sources public_configs = libarkbase_configs deps = libarkbase_deps if (is_arkui_x) { deps += [ "$ark_third_party_root/bounds_checking_function:libsec_static" ] if (target_os == "ios") { defines = [ "IOS_PLATFORM" ] } } else { external_deps = [ "json:nlohmann_json_static", sdk_libc_secshared_dep, ] if (enable_hilog && defined(ohos_indep_compiler_enable) && ohos_indep_compiler_enable) { external_deps += [ "hilog:libhilog" ] } } part_name = "runtime_core" subsystem_name = "arkcompiler" } ohos_static_library("libarkbase_frontend_static") { stack_protector_ret = false deps = [ ":libarkbase_frontend_set_static" ] part_name = "runtime_core" subsystem_name = "arkcompiler" } action("logger_yaml_gen") { script = "$ark_root/libpandabase/templates/logger_gen.rb" inputs = [ "$ark_root/libpandabase/templates/logger.yaml" ] outputs = [ "$root_gen_dir/libpandabase/logger.yaml" ] args = [ "-p", rebase_path("$target_gen_dir/../plugin_options.yaml", root_build_dir), "-d", rebase_path(inputs[0], root_build_dir), "-o", rebase_path(outputs[0], root_build_dir), ] deps = [ "$ark_root:concat_plugins_yamls" ] } ark_gen_file("logger_enum_gen_h") { extra_dependencies = [ ":logger_yaml_gen" ] template_file = "templates/logger_enum_gen.h.erb" data_file = "$root_gen_dir/libpandabase/logger.yaml" requires = [ "$ark_root/libpandabase/templates/logger.rb" ] output_file = "$target_gen_dir/include/logger_enum_gen.h" } ark_gen_file("logger_impl_gen_h") { extra_dependencies = [ ":logger_yaml_gen" ] template_file = "templates/logger_impl_gen.inc.erb" data_file = "$root_gen_dir/libpandabase/logger.yaml" requires = [ "$ark_root/libpandabase/templates/logger.rb" ] output_file = "$target_gen_dir/include/logger_impl_gen.inc" }