From d79d1bee6aa202c24624e1e99f883f6c1d11e98c Mon Sep 17 00:00:00 2001 From: liuweili Date: Mon, 13 Jan 2025 15:03:52 +0800 Subject: [PATCH] fix build bug Signed-off-by: liuweili --- BUILD.gn | 47 ++++++++++++++++++++++++++-------------- bundle.json | 12 +++++----- copy_v8.sh | 20 +++++++++++++++++ jsvm.gni | 26 ++++++++++------------ src/js_native_api_v8.cpp | 4 ++-- src/js_native_api_v8.h | 2 +- 6 files changed, 73 insertions(+), 38 deletions(-) create mode 100755 copy_v8.sh diff --git a/BUILD.gn b/BUILD.gn index 1a43576..7b2edc5 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1,29 +1,44 @@ -/* - * 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. - */ +# 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"), + ] +} + config("libv8_config") { include_dirs = - [ "//vendor/huawei/binary/artifacts/js_engine_url/v8-include/v8-include" ] + [ "$target_gen_dir/v8-include" ] } ohos_prebuilt_shared_library("libv8") { - source = "//vendor/huawei/binary/artifacts/js_engine_url/libv8_shared.so" + deps = [ ":copy_v8" ] + source = "$target_gen_dir/libv8_shared.so" output = "libv8_shared.so" public_configs = [ ":libv8_config" ] diff --git a/bundle.json b/bundle.json index 86bb2db..7468cc8 100644 --- a/bundle.json +++ b/bundle.json @@ -31,26 +31,28 @@ "icu", "init", "libuv", - "resource_schedule_service" + "openssl", + "resource_schedule_service", + "zlib" ] }, "build": { "sub_component": [ - "//arkcompiler/jsvm_longque:jsvm_package" + "//arkcompiler/jsvm_longque:jsvm_packages" ], "inner_kits": [ { "header": { - "header_base": "//arkcompiler/jsvm_longque/interfaces/kits", + "header_base": "//arkcompiler/jsvm_longque/interface/kits", "header_files": [ "jsvm_types.h", "jsvm.h" ] }, - "name": "//arkcompiler/jsvm_longque:jsvm_package" + "name": "//arkcompiler/jsvm_longque:jsvm_packages" } ], "test": [] } } -} \ No newline at end of file +} diff --git a/copy_v8.sh b/copy_v8.sh new file mode 100755 index 0000000..7f5d18a --- /dev/null +++ b/copy_v8.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# 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. + +export SCRIPT_PATCH=$(dirname $(readlink -f "$0")) +export TARGET_GEN_DIR=$2 + +cp -u ${SCRIPT_PATCH}/../../third_party/node/deps/v8/libv8_shared.so ${TARGET_GEN_DIR}/libv8_shared.so +cp -r ${SCRIPT_PATCH}/../../third_party/node/deps/v8/include/v8-include ${TARGET_GEN_DIR}/v8-include + diff --git a/jsvm.gni b/jsvm.gni index c84d32c..e70e4be 100644 --- a/jsvm.gni +++ b/jsvm.gni @@ -1,17 +1,15 @@ -/* - * 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. - */ +# 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. jsvm_path = "//arkcompiler/jsvm_longque" diff --git a/src/js_native_api_v8.cpp b/src/js_native_api_v8.cpp index 1f9bb79..d014cbe 100644 --- a/src/js_native_api_v8.cpp +++ b/src/js_native_api_v8.cpp @@ -5550,7 +5550,7 @@ JSVM_Status OH_JSVM_DefineClassWithOptions(JSVM_Env env, if ((p->attributes & JSVM_STATIC) != 0) { // attributes // Static properties are handled separately below. - static_property_count++; + staticPropertyCount++; continue; } v8::Local propertyName; @@ -5609,7 +5609,7 @@ JSVM_Status OH_JSVM_DefineClassWithOptions(JSVM_Env env, if (staticPropertyCount > 0) { std::vector static_descriptors; - static_descriptors.reserve(static_property_count); + static_descriptors.reserve(staticPropertyCount); for (size_t i = 0; i < propertyCount; i++) { const JSVM_PropertyDescriptor* p = properties + i; diff --git a/src/js_native_api_v8.h b/src/js_native_api_v8.h index 7bcb45b..0c30c8b 100644 --- a/src/js_native_api_v8.h +++ b/src/js_native_api_v8.h @@ -232,7 +232,7 @@ struct JSVM_PropertyHandlerCfgStruct { JSVM_Ref indexedPropertyData; }; -JSVM_PropertyHandlerCfgStruct* CreatePropertyCfg(JSVM_Env env, JSVM_PropertyHandlerCfg propertyCfg) +inline JSVM_PropertyHandlerCfgStruct* CreatePropertyCfg(JSVM_Env env, JSVM_PropertyHandlerCfg propertyCfg) { JSVM_PropertyHandlerCfgStruct* newPropertyCfg = new JSVM_PropertyHandlerCfgStruct; if (newPropertyCfg != nullptr && propertyCfg != nullptr) { -- Gitee