From 636f61b6139bf9633236408567fd7969840e726f Mon Sep 17 00:00:00 2001 From: A_Wei Date: Fri, 11 Jul 2025 19:22:21 +0800 Subject: [PATCH] LLVM packaging Python modification fix path Issue: https://gitee.com/openharmony/interface_sdk_c/issues/ICLRWK?from=project-issue Signed-off-by: A_Wei --- third_party/musl/ndk_script/BUILD.gn | 12 +++++++++--- third_party/musl/ndk_script/toolchain.sh | 17 ++++++++++------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/third_party/musl/ndk_script/BUILD.gn b/third_party/musl/ndk_script/BUILD.gn index a6e1f689b..b9ae3961e 100644 --- a/third_party/musl/ndk_script/BUILD.gn +++ b/third_party/musl/ndk_script/BUILD.gn @@ -24,6 +24,7 @@ ndk_musl_include = "ndk_musl_include" interface_musl_dir = "//interface/sdk_c/third_party/musl" target_version_dir = "ndk_musl_include/info" target_version_file = "application_target_sdk_version.h" +prebuilts_python = "//prebuilts/python" if (host_os == "mac") { if (host_cpu == "arm64") { @@ -58,9 +59,13 @@ if (host_os == "mac") { args += [ "-o" ] + [ rebase_path("${ndk_darwin_toolchains_out_dir}") ] args += [ "-l" ] + [ rebase_path("${darwin_system_toolchains_dir}/llvm/bin") ] + args += [ "-p" ] + [ rebase_path("${prebuilts_python}") ] + if (host_cpu == "arm64") { + args += [ "-t" ] + [ "darwin-arm64" ] deps = [ ":darwin_arm64" ] } else { + args += [ "-t" ] + [ "darwin-x86" ] deps = [ ":darwin_x86_64" ] } } @@ -95,7 +100,6 @@ if (host_os == "mac") { windows_x86_64_toolchain_dir = "${toolchains_dir}/windows-x86_64" ohos_arm64_toolchain_dir = "${toolchains_dir}/ohos-arm64" linux_x86_64_toolchains_dir = "${toolchains_dir}/linux-x86_64" - prebuilts_python = "//prebuilts/python" ohos_ndk_toolchains("linux_x86_64") { dest_dir = "$ndk_linux_toolchains_out_dir" sources = [ @@ -147,7 +151,8 @@ if (host_os == "mac") { args += [ "-o" ] + [ rebase_path("${ndk_linux_toolchains_out_dir}") ] args += [ "-l" ] + [ rebase_path("${linux_x86_64_toolchains_dir}/llvm/bin") ] - args += [ "-p" ] + [ rebase_path("${prebuilts_python}/linux-x86") ] + args += [ "-p" ] + [ rebase_path("${prebuilts_python}") ] + args += [ "-t" ] + [ "linux-x86" ] deps = [ ":linux_x86_64" ] } @@ -164,7 +169,8 @@ if (host_os == "mac") { } else { args += [ "-l" ] + [ rebase_path("${linux_x86_64_toolchains_dir}/llvm/bin") ] - args += [ "-p" ] + [ rebase_path("${prebuilts_python}/windows-x86") ] + args += [ "-p" ] + [ rebase_path("${prebuilts_python}") ] + args += [ "-t" ] + [ "windows-x86" ] } deps = [ ":windows_x86_64" ] } diff --git a/third_party/musl/ndk_script/toolchain.sh b/third_party/musl/ndk_script/toolchain.sh index db0cf489e..ef5f93ff9 100755 --- a/third_party/musl/ndk_script/toolchain.sh +++ b/third_party/musl/ndk_script/toolchain.sh @@ -2,7 +2,7 @@ # Copyright (c) Huawei Technologies Co., Ltd. 2020-2030. All rights reserved. set -e -while getopts "o:i:l:t:p:h" arg +while getopts "o:i:l:t:p:t:h" arg do case "${arg}" in "o") @@ -17,6 +17,9 @@ do "p") PYTHON_DIR=${OPTARG} ;; + "t") + TARGET=${OPTARG} + ;; "h") echo "help" ;; @@ -40,13 +43,13 @@ cp -rfp ${SOURCE_DIR}/lib ${OUT_DIR} cp -rfp ${SOURCE_DIR}/include ${OUT_DIR} if [ -n "${PYTHON_DIR+x}" ]; then - if [ -e "${OUT_DIR}/python3" ]; then + TARGET_PYTHON_DIR=$(find ${PYTHON_DIR} -name ${TARGET} 2>/dev/null | sort | head -n 1) + if [ -d "${TARGET_PYTHON_DIR}" ]; then rm -rf ${OUT_DIR}/python3 - fi - VERSION_NAME=$(ls -1 "${PYTHON_DIR}" | head -n 1) - cp -rfp ${PYTHON_DIR}/${VERSION_NAME} ${OUT_DIR}/python3 - if [ -e "${OUT_DIR}/bin/libpython3.11.dll" ]; then - cp -rfp ${PYTHON_DIR}/3.11.4/bin/libpython3.11.dll ${OUT_DIR}/bin/libpython3.11.dll + cp -rfp ${TARGET_PYTHON_DIR} ${OUT_DIR}/python3 + if [ -e "${OUT_DIR}/bin/libpython3.11.dll" ]; then + cp -rfp ${TARGET_PYTHON_DIR}/3.11.4/bin/libpython3.11.dll ${OUT_DIR}/bin/libpython3.11.dll + fi fi fi -- Gitee