From e1d2d160c3147c194bdabfc77b4993572178eea4 Mon Sep 17 00:00:00 2001 From: wangyimin Date: Thu, 9 Jan 2025 14:42:46 +0800 Subject: [PATCH] Add gn files Signed-off-by: wangyimin --- BUILD.gn | 185 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ jsvm.gni | 22 +++++++ 2 files changed, 207 insertions(+) diff --git a/BUILD.gn b/BUILD.gn index 81c455d..1a43576 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -12,3 +12,188 @@ * 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") + +config("libv8_config") { + include_dirs = + [ "//vendor/huawei/binary/artifacts/js_engine_url/v8-include/v8-include" ] +} + +ohos_prebuilt_shared_library("libv8") { + source = "//vendor/huawei/binary/artifacts/js_engine_url/libv8_shared.so" + output = "libv8_shared.so" + public_configs = [ ":libv8_config" ] + + subsystem_name = "arkcompiler" + part_name = "jsvm_longque" + + install_enable = true + install_images = [ "system" ] + innerapi_tags = [ "ndk" ] +} + +config("llhttp_config") { + include_dirs = [ "//third_party/nghttp2/third-party/llhttp/include" ] +} + +ohos_static_library("llhttp") { + sources = [ + "//third_party/nghttp2/third-party/llhttp/src/api.c", + "//third_party/nghttp2/third-party/llhttp/src/http.c", + "//third_party/nghttp2/third-party/llhttp/src/llhttp.c", + ] + + public_configs = [ ":llhttp_config" ] + + subsystem_name = "arkcompiler" + part_name = "jsvm_longque" +} + +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", + "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", + ] +} + +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_longque" + + 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_longque" + + install_enable = true + install_images = [ "system" ] + innerapi_tags = [ "ndk" ] +} + +group("jsvm_packages") { + deps = [ ":libjsvm" ] +} diff --git a/jsvm.gni b/jsvm.gni index 81c455d..c84d32c 100644 --- a/jsvm.gni +++ b/jsvm.gni @@ -12,3 +12,25 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +jsvm_path = "//arkcompiler/jsvm_longque" + +jsvm_sources = [ + "src/js_native_api_v8.cpp", + "src/jsvm_env.cpp", + "src/jsvm_reference.cpp", +] + +jsvm_inspector_sources = [ + "src/inspector/inspector_socket.cpp", + "src/inspector/inspector_socket_server.cpp", + "src/inspector/inspector_utils.cpp", + "src/inspector/js_native_api_v8_inspector.cpp", +] + +declare_args() { + jsvm_shared_libuv = true + enable_debug = false + enable_inspector = true + use_platform_ohos = true +} -- Gitee