diff --git a/llvm-build/build.py b/llvm-build/build.py index 7d641d4574881428c50545f6403435b6d94f1754..1d8fffd0792fc31f2754fcbde7d89a26a3436302 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 0000000000000000000000000000000000000000..e1234dc72dfbeb5f2fd1cb6cfab2c59cae7df1bc --- /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