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/libpandabase", 19 "$target_gen_dir/include", 20 "$target_gen_dir", 21 ] 22 23 include_dirs += platform_include_dirs 24 25 if (ark_standalone_build) { 26 ldflags = [ "-ldl" ] 27 } 28} 29 30config("arkbase_fuzz_config") { 31 configs = [ "$build_root/config/compiler:exceptions" ] 32 defines = [ "SUPPORT_KNOWN_EXCEPTION" ] 33} 34 35ark_gen_file("events_gen") { 36 template_file = "events/events_gen.h.erb" 37 data_file = "events/events.yaml" 38 requires = [ "events/events.rb" ] 39 output_file = "$target_gen_dir/events_gen.h" 40} 41 42ark_gen_file("base_options_h") { 43 template_file = "../templates/options/options.h.erb" 44 data_file = "options.yaml" 45 requires = [ "../templates/common.rb" ] 46 output_file = "$target_gen_dir/generated/base_options.h" 47} 48 49action("generate_version_file") { 50 script = "$ark_root/gn/build/cmake_configure_file.py" 51 52 sources = [ "$ark_root/libpandabase/templates/ark_version.h.in" ] 53 outputs = [ "$root_gen_dir/libpandabase/ark_version.h" ] 54 55 hash = exec_script("$ark_root/gn/build/find_git.sh", 56 [ rebase_path("${ark_root}", "$root_build_dir") ], 57 "trim string") 58 59 if (hash == "") { 60 args = [ 61 rebase_path(sources[0], "$root_build_dir"), 62 rebase_path(outputs[0], "$root_build_dir"), 63 ] 64 } else { 65 args = [ 66 rebase_path(sources[0], "$root_build_dir"), 67 rebase_path(outputs[0], "$root_build_dir"), 68 "ARK_VERSION_GIT_HASH=${hash}", 69 ] 70 } 71} 72 73if (is_mingw) { 74 libarkbase_sources = [ 75 "$ark_root/libpandabase/mem/arena_allocator.cpp", 76 "$ark_root/libpandabase/mem/base_mem_stats.cpp", 77 "$ark_root/libpandabase/mem/code_allocator.cpp", 78 "$ark_root/libpandabase/mem/mem_config.cpp", 79 "$ark_root/libpandabase/mem/pool_manager.cpp", 80 "$ark_root/libpandabase/mem/pool_map.cpp", 81 "$ark_root/libpandabase/os/filesystem.cpp", 82 "$ark_root/libpandabase/os/mutex.cpp", 83 "$ark_root/libpandabase/os/native_stack.cpp", 84 "$ark_root/libpandabase/os/stacktrace_stub.cpp", 85 "$ark_root/libpandabase/os/time.cpp", 86 "$ark_root/libpandabase/utils/json_parser.cpp", 87 "$ark_root/libpandabase/utils/logger.cpp", 88 "$ark_root/libpandabase/utils/time.cpp", 89 "$ark_root/libpandabase/utils/type_converter.cpp", 90 "$ark_root/libpandabase/utils/utf.cpp", 91 "$ark_root/platforms/windows/libpandabase/error.cpp", 92 "$ark_root/platforms/windows/libpandabase/file.cpp", 93 "$ark_root/platforms/windows/libpandabase/filesystem.cpp", 94 "$ark_root/platforms/windows/libpandabase/library_loader.cpp", 95 "$ark_root/platforms/windows/libpandabase/mem.cpp", 96 "$ark_root/platforms/windows/libpandabase/thread.cpp", 97 "$ark_root/platforms/windows/libpandabase/trace.cpp", 98 ] 99} else { 100 libarkbase_sources = [ 101 "$ark_root/libpandabase/mem/arena_allocator.cpp", 102 "$ark_root/libpandabase/mem/base_mem_stats.cpp", 103 "$ark_root/libpandabase/mem/code_allocator.cpp", 104 "$ark_root/libpandabase/mem/mem_config.cpp", 105 "$ark_root/libpandabase/mem/pool_manager.cpp", 106 "$ark_root/libpandabase/mem/pool_map.cpp", 107 "$ark_root/libpandabase/os/native_stack.cpp", 108 "$ark_root/libpandabase/os/property.cpp", 109 110 # product build 111 "$ark_root/libpandabase/os/stacktrace_stub.cpp", 112 "$ark_root/libpandabase/os/time.cpp", 113 "$ark_root/libpandabase/trace/trace.cpp", 114 "$ark_root/libpandabase/utils/json_parser.cpp", 115 "$ark_root/libpandabase/utils/logger.cpp", 116 "$ark_root/libpandabase/utils/time.cpp", 117 "$ark_root/libpandabase/utils/type_converter.cpp", 118 "$ark_root/libpandabase/utils/utf.cpp", 119 "$ark_root/platforms/unix/libpandabase/error.cpp", 120 "$ark_root/platforms/unix/libpandabase/file.cpp", 121 "$ark_root/platforms/unix/libpandabase/filesystem.cpp", 122 "$ark_root/platforms/unix/libpandabase/library_loader_resolve_symbol.cpp", 123 "$ark_root/platforms/unix/libpandabase/mem.cpp", 124 "$ark_root/platforms/unix/libpandabase/native_stack.cpp", 125 "$ark_root/platforms/unix/libpandabase/property.cpp", 126 "$ark_root/platforms/unix/libpandabase/thread.cpp", 127 "$ark_root/platforms/unix/libpandabase/trace.cpp", 128 ] 129 130 if (!is_mob || is_linux || current_os == "android" || target_os == "ios") { 131 libarkbase_sources += 132 [ "$ark_root/platforms/unix/libpandabase/library_loader_load.cpp" ] 133 } 134 135 if (!is_mac && target_os != "ios") { 136 libarkbase_sources += [ 137 "$ark_root/libpandabase/os/filesystem.cpp", 138 "$ark_root/platforms/unix/libpandabase/exec.cpp", 139 "$ark_root/platforms/unix/libpandabase/futex/fmutex.cpp", 140 "$ark_root/platforms/unix/libpandabase/futex/mutex.cpp", 141 ] 142 } else { 143 libarkbase_sources += [ "$ark_root/libpandabase/os/mutex.cpp" ] 144 } 145} 146 147if (is_debug) { 148 libarkbase_sources += [ "$ark_root/libpandabase/utils/debug.cpp" ] 149} 150 151if (current_cpu == "arm64" && !is_mac && target_os != "ios") { 152 libarkbase_sources += 153 [ "$ark_root/libpandabase/arch/aarch64/cpu_features.cpp" ] 154} else { 155 libarkbase_sources += 156 [ "$ark_root/libpandabase/arch/default/cpu_features.cpp" ] 157} 158 159libarkbase_configs = [ 160 sdk_libc_secshared_config, 161 ":arkbase_public_config", 162 "$ark_root:ark_config", 163] 164 165group("arkbase_header_deps") { 166 deps = [ 167 ":base_options_h", 168 ":events_gen", 169 ":generate_version_file", 170 ":logger_enum_gen_h", 171 ":logger_impl_gen_h", 172 ] 173} 174 175libarkbase_deps = [ 176 ":arkbase_header_deps", 177 sdk_libc_secshared_dep, 178] 179 180source_set("libarkbase_static_fuzz") { 181 sources = libarkbase_sources 182 183 public_configs = libarkbase_configs 184 public_configs += [ ":arkbase_fuzz_config" ] 185 186 deps = libarkbase_deps 187} 188 189source_set("libarkbase_static") { 190 sources = libarkbase_sources 191 192 public_configs = libarkbase_configs 193 194 deps = libarkbase_deps 195} 196 197ohos_shared_library("libarkbase") { 198 deps = [ ":libarkbase_static" ] 199 if (!is_mingw && !is_mac) { 200 output_extension = "so" 201 } 202 if (!is_standard_system) { 203 relative_install_dir = "ark" 204 } 205 part_name = "runtime_core" 206 subsystem_name = "arkcompiler" 207} 208 209source_set("libarkbase_frontend_set_static") { 210 sources = libarkbase_sources 211 212 public_configs = libarkbase_configs 213 214 deps = libarkbase_deps 215} 216 217ohos_static_library("libarkbase_frontend_static") { 218 deps = [ ":libarkbase_frontend_set_static" ] 219 220 part_name = "runtime_core" 221 subsystem_name = "arkcompiler" 222} 223 224action("logger_yaml_gen") { 225 script = "$ark_root/libpandabase/templates/logger_gen.rb" 226 inputs = [ "$ark_root/libpandabase/templates/logger.yaml" ] 227 outputs = [ "$root_gen_dir/libpandabase/logger.yaml" ] 228 args = [ 229 "-p", 230 rebase_path("$target_gen_dir/../plugin_options.yaml", root_build_dir), 231 "-d", 232 rebase_path(inputs[0], root_build_dir), 233 "-o", 234 rebase_path(outputs[0], root_build_dir), 235 ] 236 deps = [ "$ark_root:concat_plugins_yamls" ] 237} 238 239ark_gen_file("logger_enum_gen_h") { 240 extra_dependencies = [ ":logger_yaml_gen" ] 241 template_file = "templates/logger_enum_gen.h.erb" 242 data_file = "$root_gen_dir/libpandabase/logger.yaml" 243 requires = [ "$ark_root/libpandabase/templates/logger.rb" ] 244 output_file = "$target_gen_dir/include/logger_enum_gen.h" 245} 246 247ark_gen_file("logger_impl_gen_h") { 248 extra_dependencies = [ ":logger_yaml_gen" ] 249 template_file = "templates/logger_impl_gen.inc.erb" 250 data_file = "$root_gen_dir/libpandabase/logger.yaml" 251 requires = [ "$ark_root/libpandabase/templates/logger.rb" ] 252 output_file = "$target_gen_dir/include/logger_impl_gen.inc" 253} 254