From 084917238ee5a0e846ea87951e9631e7126e67fe Mon Sep 17 00:00:00 2001 From: jiang-qunchao Date: Mon, 30 Jun 2025 16:07:30 +0800 Subject: [PATCH] update dependency tag Signed-off-by: jiang-qunchao --- BUILD.gn | 9 +++++++-- CMakeLists.txt | 12 +++++++++--- build_jsvm.sh | 7 +++++++ build_jsvm_inter.sh | 19 ++++++++++++------- copy_v8.sh | 21 +-------------------- 5 files changed, 36 insertions(+), 32 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index a23c6a1..7358a17 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -22,6 +22,9 @@ ohos_prebuilt_etc("jit_enable_list_appid") { subsystem_name = "arkcompiler" } +dependency_tag = "default" +js_engine_url = "//vendor/${dependency_tag}/binary/artifacts/js_engine_url/" + action("copy_v8") { external_deps = [] deps = [] @@ -34,7 +37,7 @@ action("copy_v8") { args = [ "--target_gen_dir", rebase_path("$target_gen_dir"), - rebase_path("//vendor/huawei/binary/artifacts/js_engine_url/"), + rebase_path("${js_engine_url}"), target_cpu, ] } @@ -154,7 +157,7 @@ action("build_libjsvm") { "--target_platform", "$target_platform", "--prefix", - rebase_path("//vendor/huawei/binary/artifacts/js_engine_url/llvm/bin"), + rebase_path("${js_engine_url}/llvm/bin"), "--sysroot", rebase_path("$musl_sysroot"), "--is_asan", @@ -164,6 +167,8 @@ action("build_libjsvm") { "{{include_dirs}}", "--cmake_path", rebase_path("//prebuilts/cmake/linux-x86/bin/cmake"), + "--dependency_tag", + "${dependency_tag}", "--jsvm_path", rebase_path("."), ] diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a34d93..b160057 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,13 @@ include_directories(jsvm "interface/kits" ) +# TODO: samgr:samgr_proxy module, indirect dependencies cannot be passed +if (DEPENDENCY_TAG STREQUAL "default") +include_directories(jsvm + "../../foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include" +) +endif() + # 设置源文件 set (jsvm_sources "src/js_native_api_v8.cpp" @@ -74,7 +81,7 @@ set (LIB_DIRS "${LIB_ROOT_DIR}/thirdparty/libuv/" "${LIB_ROOT_DIR}/thirdparty/icu/" "${LIB_ROOT_DIR}/thirdparty/openssl/" - "${LIB_ROOT_DIR}/obj/vendor/huawei/foundation/bundlemanager/zlib_override/" + "${LIB_ROOT_DIR}/obj/vendor/${DEPENDENCY_TAG}/foundation/bundlemanager/zlib_override/" ) set(CMAKE_SKIP_RPATH TRUE) link_directories(${LIB_DIRS}) @@ -92,8 +99,7 @@ target_link_options(jsvm "-Wl,--exclude-libs=libc++_static.a" ) -string(FIND "$ENV{SYSROOT}" "rk3568" RK3568_INDEX) -if (RK3568_INDEX LESS 0) +if (NOT DEPENDENCY_TAG STREQUAL "default") if ((DEFINED USE_LIBZ_INNER) AND USE_LIBZ_INNER) target_link_libraries(jsvm libz_inner.a diff --git a/build_jsvm.sh b/build_jsvm.sh index 4f9d343..b821232 100755 --- a/build_jsvm.sh +++ b/build_jsvm.sh @@ -20,6 +20,8 @@ declare PREFIX declare TARGET_CPU declare TARGET_GEN_DIR declare TARGET_PLATFORM +declare JS_ENGINE_URL +declare DEPENDENCY_TAG export SCRIPT_PATCH=$(dirname $(readlink -f "$0")) @@ -89,6 +91,7 @@ do_opt_process() { ;; --prefix) export PREFIX=$2 + export JS_ENGINE_URL=${PREFIX=}/../.. shift ;; --target_cpu) @@ -123,6 +126,10 @@ do_opt_process() { export LIB_ROOT_DIR=$2 shift ;; + --dependency_tag) + export DEPENDENCY_TAG=$2 + shift + ;; -I*) export INCLUDE_DIRS="${INCLUDE_DIRS} -I${LIB_ROOT_DIR}/${1#-I}" ;; diff --git a/build_jsvm_inter.sh b/build_jsvm_inter.sh index f5beeb4..40e4140 100755 --- a/build_jsvm_inter.sh +++ b/build_jsvm_inter.sh @@ -25,7 +25,7 @@ do_patch() { do_configure() { use_libz_inner=0 - if [ -f "${LIB_ROOT_DIR}/obj/vendor/huawei/foundation/bundlemanager/zlib_override/libz_inner.a" ];then + if [ -f "${LIB_ROOT_DIR}/obj/vendor/${DEPENDENCY_TAG}/foundation/bundlemanager/zlib_override/libz_inner.a" ];then use_libz_inner=1 fi @@ -36,14 +36,15 @@ do_configure() { -B${TARGET_GEN_DIR}/build\ -S${JSVM_PATH}\ -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS}"\ - -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS}" + -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS}"\ + -DDEPENDENCY_TAG="${DEPENDENCY_TAG}" } do_unstripped_copy() { JSVM_UNSTRIPPED_PATH=${TARGET_GEN_DIR}/../../../lib.unstripped/arkcompiler/jsvm/ mkdir -p ${JSVM_UNSTRIPPED_PATH} cp -u ${workdir}/libjsvm.so ${JSVM_UNSTRIPPED_PATH} - cp -u ${JSVM_PATH}/../../vendor/huawei/binary/artifacts/js_engine_url/v8/${TARGET_CPU}/lib.unstripped_v8/lib.unstripped/libv8_shared.so ${JSVM_UNSTRIPPED_PATH} + cp -u ${JS_ENGINE_URL}/v8/${TARGET_CPU}/lib.unstripped_v8/lib.unstripped/libv8_shared.so ${JSVM_UNSTRIPPED_PATH} } get_thread_num() { @@ -115,11 +116,11 @@ do_install_asan() { # todo replace libv8_shared.so with hwasan mkdir -p ${TARGET_GEN_DIR}/asan cp -u ${workdir}/libjsvm.so ${TARGET_GEN_DIR}/asan - cp -u ${JSVM_PATH}/../../vendor/huawei/binary/artifacts/js_engine_url/v8/${TARGET_CPU}/lib.unstripped_v8/lib.unstripped/libv8_shared.so ${TARGET_GEN_DIR}/asan + cp -u ${JS_ENGINE_URL}/v8/${TARGET_CPU}/lib.unstripped_v8/lib.unstripped/libv8_shared.so ${TARGET_GEN_DIR}/asan mkdir -p ${TARGET_GEN_DIR}/../../../../../lib.unstripped/jsvm/ cp -u ${workdir}/libjsvm.so ${TARGET_GEN_DIR}/../../../../../lib.unstripped/jsvm/ - cp -u ${JSVM_PATH}/../../vendor/huawei/binary/artifacts/js_engine_url/v8/${TARGET_CPU}/lib.unstripped_v8/lib.unstripped/libv8_shared.so ${TARGET_GEN_DIR}/../../../../../lib.unstripped/jsvm/ + cp -u ${JS_ENGINE_URL}/v8/${TARGET_CPU}/lib.unstripped_v8/lib.unstripped/libv8_shared.so ${TARGET_GEN_DIR}/../../../../../lib.unstripped/jsvm/ } do_env() { @@ -141,7 +142,9 @@ do_env() { if [[ "${TARGET_CPU}" = "arm" ]]; then cflags=" --target=arm-linux-ohos" cflags+=" --sysroot=${SYSROOT}" - cflags+=" -isystem ${SYSROOT}/usr/include/arm-linux-ohos" + if [[ "${DEPENDENCY_TAG}" = "default" ]]; then + cflags+=" -isystem ${SYSROOT}/usr/include/arm-linux-ohos" + fi cflags+=" -march=armv7-a" cflags+=" -mfpu=neon" cflags+=" -mbranch-protection=pac-ret+b-key+bti" @@ -150,7 +153,9 @@ do_env() { elif [[ "${TARGET_CPU}" = "arm64" ]]; then cflags=" --target=aarch64-linux-ohos" cflags+=" --sysroot=${SYSROOT}" - cflags+=" -isystem ${SYSROOT}/usr/include/aarch64-linux-ohos" + if [[ "${DEPENDENCY_TAG}" = "default" ]]; then + cflags+=" -isystem ${SYSROOT}/usr/include/aarch64-linux-ohos" + fi cflags+=" -march=armv8-a" cflags+=" -DV8_OS_OH=1" cflags+=" -mfpu=neon" diff --git a/copy_v8.sh b/copy_v8.sh index 6b88093..ec63bc5 100755 --- a/copy_v8.sh +++ b/copy_v8.sh @@ -11,29 +11,10 @@ # 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 TARGET_GEN_DIR=$2 v8_path=$3 target_cpu=$4 -JSVM_PATH=$(dirname $(readlink -f "$0")) -js_engine_url_version=arkcompiler_jsvm_20250527.tar.gz -llvm_version=llvm-linux-19.1.7-x86_64.tar.gz -if [ ! -d "${v8_path}/v8" ]; then - if [ ! -f "${JSVM_PATH}/${js_engine_url_version}" ]; then - wget -o ${JSVM_PATH}/wget_download.log -O ${JSVM_PATH}/${js_engine_url_version} https://mirrors.huaweicloud.com/openharmony/compiler/jsvm/${js_engine_url_version} - cd ${JSVM_PATH} - tar -zxf ${js_engine_url_version} - fi - if [ ! -f "${JSVM_PATH}/${llvm_version}" ]; then - wget -o ${JSVM_PATH}/wget_download.log -O ${JSVM_PATH}/${llvm_version} https://mirrors.huaweicloud.com/openharmony/compiler/jsvm/${llvm_version} - cd ${JSVM_PATH} - tar -zxf ${llvm_version} - fi - mkdir -p ${v8_path} - rm -rf ${v8_path}/* - cp -r ${JSVM_PATH}/js_engine_url/* ${v8_path} - cp -r ${JSVM_PATH}/llvm ${v8_path} -fi - cp -u ${v8_path}/v8/${target_cpu}/libv8_shared.so ${TARGET_GEN_DIR}/libv8_shared.so cp -r ${v8_path}/v8-include/v8-include ${TARGET_GEN_DIR}/v8-include -- Gitee