From ae3803b6911f726d222d602880a1d065b5c8a0a6 Mon Sep 17 00:00:00 2001 From: zhengweiwei Date: Mon, 27 Feb 2023 16:57:55 +0800 Subject: [PATCH] Use python static lib by default Description: Install libpython static library and link into lldb toolchain Issue: I6EQVA Test: mac llvm compilation verification Signed-off-by: zhengweiwei Change-Id: I410ef0a45ba6092185e1779c80ea62949b9c4ff1 --- llvm-build/build.py | 15 +++++++++++++++ python_build.sh | 24 ++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 python_build.sh diff --git a/llvm-build/build.py b/llvm-build/build.py index 7d641d457488..1d8fffd0792f 100755 --- a/llvm-build/build.py +++ b/llvm-build/build.py @@ -757,6 +757,19 @@ class SysrootComposer(BuildUtils): '-T', self.build_config.REPOROOT_DIR] + list(extra_args) self.check_call(args) os.chdir(cur_dir) + + def python_build(self): + cur_dir = os.getcwd() + while cur_dir != '/': + third_party_python = os.path.join(cur_dir, 'third_party/python') + if os.path.exists(third_party_python): + break + cur_dir = os.path.dirname(cur_dir) + generated_path = os.path.join(third_party_python, 'build/libpython3.10') + python_build_path = os.path.join(cur_dir, 'toolchain/llvm-project/python_build.sh') + cmakelists_path = os.path.join(cur_dir, 'toolchain/llvm-project/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt') + args = ['sh', python_build_path, third_party_python, generated_path, cmakelists_path] + self.check_call(args) def install_linux_headers(self, arch, target): dir_suffix = arch @@ -2006,6 +2019,8 @@ def main(): build_config = BuildConfig() build_utils = BuildUtils(build_config) sysroot_composer = SysrootComposer(build_config) + if build_utils.host_is_darwin(): + sysroot_composer.python_build() llvm_core = LlvmCore(build_config) llvm_package = LlvmPackage(build_config) lldb_mi = LldbMi(build_config, llvm_package) diff --git a/python_build.sh b/python_build.sh new file mode 100644 index 000000000000..e1234dc72dfb --- /dev/null +++ b/python_build.sh @@ -0,0 +1,24 @@ +#!/bin/bash +name='3.10.2' +CONFIGURE_PATH=$1 +EPREFIX=$2 +CMAKELISTS_PATH=$3 +if [ -f "${EPREFIX}/libpython3.10.a" ]; +then + : +else + mkdir -p ${EPREFIX} + cd $EPREFIX + + $CONFIGURE_PATH/configure --prefix=$EPREFIX \ + --bindir=$EPREFIX/bin \ + --libdir=$EPREFIX/lib \ + --includedir=$EPREFIX/include \ + --datarootdir=$EPREFIX/share + + make + + make install + + sed -i '' "s#\${Python3_LIBRARIES}#\"$EPREFIX/libpython3.10.a\"#" $CMAKELISTS_PATH +fi -- Gitee