# Copyright (c) 2024 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("//build/config/clang/clang.gni") import("//build/ohos.gni") import("jsvm.gni") action("copy_v8") { external_deps = [] deps = [] script = "copy_v8.sh" sources = [] outputs = [ "$target_gen_dir/libv8_shared.so", "$target_gen_dir/v8-include", ] args = [ "--target_gen_dir", rebase_path("$target_gen_dir"), ] } action("copy_llhttp") { external_deps = [] deps = [] script = "copy_llhttp.sh" sources = [] outputs = [ "$target_gen_dir/llhttp/src/api.c", "$target_gen_dir/llhttp/src/http.c", "$target_gen_dir/llhttp/src/llhttp.c", "$target_gen_dir/llhttp/include", ] args = [ "--target_gen_dir", rebase_path("$target_gen_dir"), ] } config("libv8_config") { include_dirs = [ "$target_gen_dir/v8-include" ] } ohos_prebuilt_shared_library("libv8") { deps = [ ":copy_v8" ] source = "$target_gen_dir/libv8_shared.so" output = "libv8_shared.so" public_configs = [ ":libv8_config" ] subsystem_name = "arkcompiler" part_name = "jsvm" install_enable = true install_images = [ "system" ] innerapi_tags = [ "ndk" ] } config("llhttp_config") { include_dirs = [ "$target_gen_dir/llhttp/include" ] } ohos_static_library("llhttp") { deps = [ ":copy_llhttp" ] sources = [ "$target_gen_dir/llhttp/src/api.c", "$target_gen_dir/llhttp/src/http.c", "$target_gen_dir/llhttp/src/llhttp.c", ] public_configs = [ ":llhttp_config" ] subsystem_name = "arkcompiler" part_name = "jsvm" } config("jsvm_common_config") { cflags = [ "-fstack-protector-strong", "--target=aarch64-linux-ohos", "-march=armv8-a", "-mfpu=neon", "-m64", "-msign-return-address=all", "-pthread", "-Wall", "-Wextra", "-Wno-unused-parameter", "-fPIC", "-Werror=unused-result", "-O3", "-fno-omit-frame-pointer", "-fno-rtti", "-fno-exceptions", "-std=gnu++17", "-fvisibility=hidden", ] ldflags = [ "-fvisibility=hidden" ] defines = [] if (use_platform_ohos && is_ohos) { defines += [ "TARGET_OHOS", "ENABLE_HISYSEVENT", ] } if (enable_debug) { cflags += [ "-g" ] defines += [ "DEBUG" ] } defines += [ "_GLIBCXX_USE_CXX11_ABI=1", "__STDC_FORMAT_MACROS", "__POSIX__", ] include_dirs = [ "interface/innerkits", "interface/kits", "src", ] } config("jsvm_inspector_config") { defines = [ "ENABLE_INSPECTOR", "HAVE_OPENSSL=1", ] } ohos_source_set("jsvm_inspector") { sources = jsvm_inspector_sources include_dirs = [ "inspector" ] configs = [ ":jsvm_common_config", ":jsvm_inspector_config", ] subsystem_name = "arkcompiler" part_name = "jsvm" deps = [ ":libv8", ":llhttp", ] external_deps = [ "bounds_checking_function:libsec_static", "icu:shared_icui18n", "icu:shared_icuuc", "openssl:libcrypto_shared", "openssl:libssl_shared", "zlib:libz", ] if (jsvm_shared_libuv) { external_deps += [ "libuv:uv" ] } else { external_deps += [ "libuv:uv_static" ] } } config("libjsvm_config") { defines = [] if (enable_inspector) { defines += [ "ENABLE_INSPECTOR", "HAVE_OPENSSL=1", ] } } ohos_shared_library("libjsvm") { sources = jsvm_sources if (use_platform_ohos && is_ohos) { sources += [ "src/platform/platform_ohos.cpp" ] } else { sources += [ "src/platform/platform.cpp" ] } configs = [ ":jsvm_common_config", ":libjsvm_config", ] deps = [ ":libv8" ] if (enable_inspector) { deps += [ ":jsvm_inspector" ] } external_deps = [] if (use_platform_ohos && is_ohos) { external_deps += [ "bounds_checking_function:libsec_static", "hilog:libhilog", "hisysevent:libhisysevent", "hitrace:hitrace_meter", "init:libbegetutil", "resource_schedule_service:ressched_client", ] } output_name = "libjsvm" output_extension = "so" subsystem_name = "arkcompiler" part_name = "jsvm" install_enable = true install_images = [ "system" ] innerapi_tags = [ "ndk" ] } group("jsvm_packages") { deps = [ ":libjsvm" ] }