1# Copyright (c) 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 14 15import("//build/config/clang/clang.gni") 16import("//build/ohos.gni") 17import("jsvm.gni") 18 19action("copy_v8") { 20 external_deps = [] 21 deps = [] 22 script = "copy_v8.sh" 23 sources = [] 24 outputs = [ 25 "$target_gen_dir/libv8_shared.so", 26 "$target_gen_dir/v8-include", 27 ] 28 args = [ 29 "--target_gen_dir", 30 rebase_path("$target_gen_dir"), 31 ] 32} 33 34action("copy_llhttp") { 35 external_deps = [] 36 deps = [] 37 script = "copy_llhttp.sh" 38 sources = [] 39 outputs = [ 40 "$target_gen_dir/llhttp/src/api.c", 41 "$target_gen_dir/llhttp/src/http.c", 42 "$target_gen_dir/llhttp/src/llhttp.c", 43 "$target_gen_dir/llhttp/include", 44 ] 45 args = [ 46 "--target_gen_dir", 47 rebase_path("$target_gen_dir"), 48 ] 49} 50 51config("libv8_config") { 52 include_dirs = 53 [ "$target_gen_dir/v8-include" ] 54} 55 56ohos_prebuilt_shared_library("libv8") { 57 deps = [ ":copy_v8" ] 58 source = "$target_gen_dir/libv8_shared.so" 59 output = "libv8_shared.so" 60 public_configs = [ ":libv8_config" ] 61 62 subsystem_name = "arkcompiler" 63 part_name = "jsvm" 64 65 install_enable = true 66 install_images = [ "system" ] 67 innerapi_tags = [ "ndk" ] 68} 69 70config("llhttp_config") { 71 include_dirs = [ "$target_gen_dir/llhttp/include" ] 72} 73 74ohos_static_library("llhttp") { 75 deps = [ ":copy_llhttp" ] 76 sources = [ 77 "$target_gen_dir/llhttp/src/api.c", 78 "$target_gen_dir/llhttp/src/http.c", 79 "$target_gen_dir/llhttp/src/llhttp.c", 80 ] 81 82 public_configs = [ ":llhttp_config" ] 83 84 subsystem_name = "arkcompiler" 85 part_name = "jsvm" 86} 87 88config("jsvm_common_config") { 89 cflags = [ 90 "-fstack-protector-strong", 91 "--target=aarch64-linux-ohos", 92 "-march=armv8-a", 93 "-mfpu=neon", 94 "-m64", 95 "-msign-return-address=all", 96 "-pthread", 97 "-Wall", 98 "-Wextra", 99 "-Wno-unused-parameter", 100 "-fPIC", 101 "-Werror=unused-result", 102 "-O3", 103 "-fno-omit-frame-pointer", 104 "-fno-rtti", 105 "-fno-exceptions", 106 "-std=gnu++17", 107 "-fvisibility=hidden", 108 ] 109 110 ldflags = [ "-fvisibility=hidden" ] 111 112 defines = [] 113 if (use_platform_ohos && is_ohos) { 114 defines += [ 115 "TARGET_OHOS", 116 "ENABLE_HISYSEVENT", 117 ] 118 } 119 120 if (enable_debug) { 121 cflags += [ "-g" ] 122 defines += [ "DEBUG" ] 123 } 124 125 defines += [ 126 "_GLIBCXX_USE_CXX11_ABI=1", 127 "__STDC_FORMAT_MACROS", 128 "__POSIX__", 129 ] 130 131 include_dirs = [ 132 "interface/innerkits", 133 "interface/kits", 134 "src", 135 ] 136} 137 138config("jsvm_inspector_config") { 139 defines = [ 140 "ENABLE_INSPECTOR", 141 "HAVE_OPENSSL=1", 142 ] 143} 144 145ohos_source_set("jsvm_inspector") { 146 sources = jsvm_inspector_sources 147 include_dirs = [ "inspector" ] 148 149 configs = [ 150 ":jsvm_common_config", 151 ":jsvm_inspector_config", 152 ] 153 154 subsystem_name = "arkcompiler" 155 part_name = "jsvm" 156 157 deps = [ 158 ":libv8", 159 ":llhttp", 160 ] 161 162 external_deps = [ 163 "bounds_checking_function:libsec_static", 164 "icu:shared_icui18n", 165 "icu:shared_icuuc", 166 "openssl:libcrypto_shared", 167 "openssl:libssl_shared", 168 "zlib:libz", 169 ] 170 171 if (jsvm_shared_libuv) { 172 external_deps += [ "libuv:uv" ] 173 } else { 174 external_deps += [ "libuv:uv_static" ] 175 } 176} 177 178config("libjsvm_config") { 179 defines = [] 180 if (enable_inspector) { 181 defines += [ 182 "ENABLE_INSPECTOR", 183 "HAVE_OPENSSL=1", 184 ] 185 } 186} 187 188ohos_shared_library("libjsvm") { 189 sources = jsvm_sources 190 if (use_platform_ohos && is_ohos) { 191 sources += [ "src/platform/platform_ohos.cpp" ] 192 } else { 193 sources += [ "src/platform/platform.cpp" ] 194 } 195 configs = [ 196 ":jsvm_common_config", 197 ":libjsvm_config", 198 ] 199 200 deps = [ ":libv8" ] 201 if (enable_inspector) { 202 deps += [ ":jsvm_inspector" ] 203 } 204 205 external_deps = [] 206 207 if (use_platform_ohos && is_ohos) { 208 external_deps += [ 209 "bounds_checking_function:libsec_static", 210 "hilog:libhilog", 211 "hisysevent:libhisysevent", 212 "hitrace:hitrace_meter", 213 "init:libbegetutil", 214 "resource_schedule_service:ressched_client", 215 ] 216 } 217 218 output_name = "libjsvm" 219 output_extension = "so" 220 221 subsystem_name = "arkcompiler" 222 part_name = "jsvm" 223 224 install_enable = true 225 install_images = [ "system" ] 226 innerapi_tags = [ "ndk" ] 227} 228 229group("jsvm_packages") { 230 deps = [ ":libjsvm" ] 231} 232