diff --git a/llvm-build/build.py b/llvm-build/build.py index 150290447bd18ed50c8fa893ed84c6a06c7b8c61..8dc3e8b484014aedb8999b62adf309c9e68d55c1 100755 --- a/llvm-build/build.py +++ b/llvm-build/build.py @@ -692,18 +692,12 @@ class BuildUtils(object): def merge_build_dir(self, name, platform_triple, *args): return self.merge_out_path('third_party', name, 'build', platform_triple, *args) - def merge_ncurses_install_dir(self, platform_triple, *args): - return self.merge_out_path('third_party', 'ncurses', 'install', platform_triple, *args) - def get_ncurses_dependence_libs(self, platform_triple): ncurses_libs = ['libncurses', 'libpanel', 'libform'] if self.use_platform() != platform_triple: ncurses_libs.append('libtinfo') return ncurses_libs - def merge_ncurses_build_dir(self, platform_triple, *args): - return self.merge_out_path('third_party', 'ncurses', 'build', platform_triple, *args) - def get_libxml2_version(self): version_file = os.path.join(self.build_config.REPOROOT_DIR, 'third_party', 'libxml2', 'libxml2.spec') if os.path.isfile(version_file): @@ -740,12 +734,6 @@ class BuildUtils(object): return None - def merge_libedit_install_dir(self, platform_triple, *args): - return self.merge_out_path('third_party', 'libedit', 'install', platform_triple, *args) - - def merge_libedit_build_dir(self, platform_triple, *args): - return self.merge_out_path('third_party', 'libedit', 'build', platform_triple, *args) - def merge_python_install_dir(self, platform_triple, *args): return self.merge_out_path('third_party', 'python', 'install', platform_triple, *args) @@ -846,7 +834,8 @@ class LlvmCore(BuildUtils): llvm_defines['LLDB_PYTHON_EXT_SUFFIX'] = '.dylib' if self.build_config.build_ncurses: ncurses_libs = ';'.join([ - self.merge_ncurses_install_dir( + self.merge_install_dir( + 'ncurses', self.use_platform(), 'lib', f'{lib_name}.6.dylib') for lib_name in self.get_ncurses_dependence_libs(self.use_platform())]) @@ -858,7 +847,7 @@ class LlvmCore(BuildUtils): if self.build_config.build_libedit: llvm_defines['LibEdit_LIBRARIES'] = \ - self.merge_libedit_install_dir(self.use_platform(), 'lib', 'libedit.0.dylib') + self.merge_install_dir('libedit', self.use_platform(), 'lib', 'libedit.0.dylib') if self.build_config.build_libxml2: llvm_defines['LIBXML2_LIBRARIES'] = \ @@ -890,7 +879,8 @@ class LlvmCore(BuildUtils): if self.build_config.build_ncurses and ncurses_version is not None: ncurses_libs = ";".join( [ - self.merge_ncurses_install_dir( + self.merge_install_dir( + 'ncurses', self.use_platform(), "lib", f"{lib_name}.so.{ncurses_version}", @@ -908,7 +898,7 @@ class LlvmCore(BuildUtils): if self.build_config.build_libedit: llvm_defines['LibEdit_LIBRARIES'] = \ - self.merge_libedit_install_dir(self.use_platform(), 'lib', 'libedit.so.0.0.68') + self.merge_install_dir('libedit', self.use_platform(), 'lib', 'libedit.so.0.0.75') if not build_instrumented and not no_lto and not debug_build: llvm_defines['LLVM_ENABLE_LTO'] = 'Thin' @@ -956,7 +946,7 @@ class LlvmCore(BuildUtils): if self.build_config.build_ncurses and self.get_ncurses_version() is not None: llvm_defines['LLDB_ENABLE_CURSES'] = 'ON' - llvm_defines['CURSES_INCLUDE_DIRS'] = self.merge_ncurses_install_dir(self.use_platform(), 'include') + llvm_defines['CURSES_INCLUDE_DIRS'] = self.merge_install_dir('ncurses', self.use_platform(), 'include') if self.build_config.enable_lzma_7zip: llvm_defines['LLDB_ENABLE_LZMA'] = 'ON' @@ -965,7 +955,7 @@ class LlvmCore(BuildUtils): if self.build_config.build_libedit: llvm_defines['LLDB_ENABLE_LIBEDIT'] = 'ON' - llvm_defines['LibEdit_INCLUDE_DIRS'] = self.merge_libedit_install_dir(self.use_platform(), 'include') + llvm_defines['LibEdit_INCLUDE_DIRS'] = self.merge_install_dir('libedit', self.use_platform(), 'include') if self.build_config.build_libxml2: llvm_defines['LLDB_ENABLE_LIBXML2'] = 'ON' @@ -1980,7 +1970,7 @@ class LlvmLibs(BuildUtils): if self.build_config.build_ncurses: self.build_ncurses(None, llvm_install, llvm_triple, True) lldb_defines['LLDB_ENABLE_CURSES'] = 'ON' - ncurses_install_path = self.merge_ncurses_install_dir(llvm_triple) + ncurses_install_path = self.merge_install_dir('ncurses', llvm_triple) lldb_defines['CURSES_INCLUDE_DIRS'] = os.path.join(ncurses_install_path, 'include') lldb_defines['CURSES_HAVE_NCURSES_CURSES_H'] = 'ON' ncurses_lib_path = os.path.join(ncurses_install_path, 'lib') @@ -1994,7 +1984,7 @@ class LlvmLibs(BuildUtils): if self.build_config.build_libedit: self.build_libedit(None, llvm_install, llvm_triple, True) lldb_defines['LLDB_ENABLE_LIBEDIT'] = 'ON' - libedit_install_path = self.merge_libedit_install_dir(llvm_triple) + libedit_install_path = self.merge_install_dir('libedit', llvm_triple) lldb_defines['LibEdit_INCLUDE_DIRS'] = os.path.join(libedit_install_path, 'include') lldb_defines['LibEdit_LIBRARIES'] = os.path.join(libedit_install_path, 'lib', 'libedit.a') @@ -2078,8 +2068,8 @@ class LlvmLibs(BuildUtils): self.logger().info('Building ncurses.') libncurses_src_dir = os.path.abspath(os.path.join(self.build_config.REPOROOT_DIR, 'third_party', 'ncurses')) - libncurses_install_path = self.merge_ncurses_install_dir(platform_triple) - libncurses_build_path = self.merge_ncurses_build_dir(platform_triple) + libncurses_install_path = self.merge_install_dir('ncurses', platform_triple) + libncurses_build_path = self.merge_build_dir('ncurses', platform_triple) prebuilts_path = os.path.join(self.buildtools_path) self.check_rm_tree(libncurses_build_path) @@ -2093,12 +2083,11 @@ class LlvmLibs(BuildUtils): ncurses_version = self.get_ncurses_version() if ncurses_version is not None: - libncurses_untar_path = self.merge_out_path('third_party', 'ncurses', 'ncurses-' + ncurses_version) args = ['./build_ncurses.sh', libncurses_src_dir, libncurses_build_path, libncurses_install_path, - prebuilts_path, clang_version, ncurses_version, platform_triple, libncurses_untar_path] + prebuilts_path, clang_version, ncurses_version, platform_triple] if static: args.append('static') - args.append(self.merge_ncurses_install_dir(self.use_platform())) + args.append(self.merge_install_dir('ncurses', self.use_platform())) self.check_call(args) os.chdir(cur_dir) @@ -2159,8 +2148,8 @@ class LlvmLibs(BuildUtils): self.logger().info('Building libedit') libedit_src_dir = os.path.abspath(os.path.join(self.build_config.REPOROOT_DIR, 'third_party', 'libedit')) - libedit_build_path = self.merge_libedit_build_dir(platform_triple) - libedit_install_path = self.merge_libedit_install_dir(platform_triple) + libedit_build_path = self.merge_build_dir('libedit', platform_triple) + libedit_install_path = self.merge_install_dir('libedit', platform_triple) prebuilts_path = os.path.join(self.buildtools_path) self.check_rm_tree(libedit_build_path) @@ -2168,13 +2157,12 @@ class LlvmLibs(BuildUtils): self.check_rm_tree(libedit_install_path) self.rm_cmake_cache(libedit_install_path) - libncurses_path = self.merge_ncurses_install_dir(platform_triple) + libncurses_path = self.merge_install_dir('ncurses', platform_triple) cur_dir = os.getcwd() os.chdir(self.build_config.LLVM_BUILD_DIR) clang_version = self.build_config.CLANG_VERSION - libedit_untar_path = self.merge_out_path('third_party', 'libedit', 'libedit-' + self.get_libedit_version()) - args = ['./build_libedit.sh', libedit_src_dir, libedit_build_path , libedit_install_path, libncurses_path, prebuilts_path, clang_version, platform_triple, libedit_untar_path] + args = ['./build_libedit.sh', libedit_src_dir, libedit_build_path , libedit_install_path, libncurses_path, prebuilts_path, clang_version, platform_triple] self.check_call(args) os.chdir(cur_dir) @@ -2807,7 +2795,7 @@ class LlvmPackage(BuildUtils): lib_dst_path = os.path.join(install_dir, 'lib') lib_names = self.get_ncurses_dependence_libs(platform_triple) - lib_srcs = [self.merge_ncurses_install_dir(platform_triple, 'lib', + lib_srcs = [self.merge_install_dir('ncurses', platform_triple, 'lib', f'{name}{shlib_ext}') for name in lib_names] lib_dsts = [os.path.join(install_dir, 'lib', f'{name}{shlib_ext}') for name in lib_names] @@ -2816,7 +2804,7 @@ class LlvmPackage(BuildUtils): os.makedirs(lib_dst_path) for lib_file in lib_srcs: - self.update_lib_id_link(self.merge_ncurses_install_dir(platform_triple, 'lib'), lib_file) + self.update_lib_id_link(self.merge_install_dir('ncurses', platform_triple, 'lib'), lib_file) # Clear historical libraries for lib in lib_dsts: @@ -2834,7 +2822,7 @@ class LlvmPackage(BuildUtils): if self.host_is_linux(): shlib_ext = '.so.0' - libedit_lib_path = self.merge_libedit_install_dir(platform_triple, 'lib') + libedit_lib_path = self.merge_install_dir('libedit', platform_triple, 'lib') libedit_src = os.path.join(libedit_lib_path, 'libedit%s' % shlib_ext) lib_dst_path = os.path.join(install_dir, 'lib') diff --git a/llvm-build/build_libedit.sh b/llvm-build/build_libedit.sh index 86dfbb43e4d1587c8afb33fb6a91dd372910f4db..1cd0bbd800b07578e2868fb64468a90108e11a1a 100755 --- a/llvm-build/build_libedit.sh +++ b/llvm-build/build_libedit.sh @@ -11,15 +11,8 @@ NCURSES_PATH=$4 PREBUILT_PATH=$5 CLANG_VERSION=$6 TARGET=$7 -LIBEDIT_UNTAR_PATH=$8 -# Get version and date form libedit.spec (Compatible with Linux and Mac) -# The format in the libedit.spec is as follows: -# Version: 3.1 -# %global _date 20210910 SPECFILE="${LIBEDIT_SRC_DIR}/libedit.spec" -LIBEDIT_VERSION=$(grep -E '^Version:*' ${SPECFILE} | awk '{print $2}') -DATE=$(grep -E '^%global _date' ${SPECFILE} | sed 's/^.*\(20[0-9]\{6\}\).*$/\1/') case $(uname -s) in Linux) @@ -46,23 +39,22 @@ esac CC_PATH=${PREBUILT_PATH}/clang/ohos/${host_platform}-${host_cpu}/clang-${CLANG_VERSION}/bin/clang CXX_PATH=${PREBUILT_PATH}/clang/ohos/${host_platform}-${host_cpu}/clang-${CLANG_VERSION}/bin/clang++ -libedit_package=${LIBEDIT_SRC_DIR}/libedit-${DATE}-${LIBEDIT_VERSION}.tar.gz -if [ -e ${libedit_package} ]; then - if [ ! -b ${LIBEDIT_UNTAR_PATH} ]; then - mkdir -p ${LIBEDIT_UNTAR_PATH} +if [ -d ${LIBEDIT_SRC_DIR} ]; then + cd ${LIBEDIT_SRC_DIR} + + if [ "${host_platform}" = "linux" ]; then + autoreconf -vfi + patches=($(grep -E '^Patch[0-9]+:' "${SPECFILE}" | sed 's/^[^:]*: *//')) + # Apply patches in order + for patch in "${patches[@]}" + do + patch -Np1 < ${LIBEDIT_SRC_DIR}/$patch + done fi - tar -xzvf ${libedit_package} --strip-components 1 -C ${LIBEDIT_UNTAR_PATH} - cd ${LIBEDIT_UNTAR_PATH} - if [ ! -b ${LIBEDIT_BUILD_PATH} ]; then + if [ ! -d ${LIBEDIT_BUILD_PATH} ]; then mkdir -p ${LIBEDIT_BUILD_PATH} fi - patches=($(grep -E '^Patch[0-9]+:' "${SPECFILE}" | sed 's/^[^:]*: *//')) - # Apply patches in order - for patch in "${patches[@]}" - do - patch -Np1 < ${LIBEDIT_SRC_DIR}/$patch - done # build libedit cd ${LIBEDIT_BUILD_PATH} @@ -86,7 +78,7 @@ if [ -e ${libedit_package} ]; then export CFLAGS="$CFLAGS $ncuses_flags $stack_flags" fi - ${LIBEDIT_UNTAR_PATH}/configure \ + ${LIBEDIT_SRC_DIR}/configure \ --prefix=${LIBEDIT_INSTALL_PATH} \ CC=${CC_PATH} \ CXX=${CXX_PATH} @@ -97,7 +89,7 @@ if [ -e ${libedit_package} ]; then C_FLAGS="$C_FLAGS -march=armv7-a -mfloat-abi=soft" fi C_FLAGS="$C_FLAGS $stack_flags" - ${LIBEDIT_UNTAR_PATH}/configure \ + ${LIBEDIT_SRC_DIR}/configure \ --prefix=${LIBEDIT_INSTALL_PATH} \ --host="${TARGET}" \ CC="${PREBUILT_PATH}/../out/llvm-install/bin/clang --target=${TARGET}" \ @@ -106,6 +98,7 @@ if [ -e ${libedit_package} ]; then make -j$(nproc --all) install | tee build_libedit_${TARGET}.log fi + cd ${LIBEDIT_SRC_DIR} + git reset --hard HEAD + git clean -df fi - - diff --git a/llvm-build/build_ncurses.sh b/llvm-build/build_ncurses.sh index e143c43f1ffd6cfb3596b099e0499e5f4c527313..4d26f8ec4a3e9dab9bcec3b189e13bfa6d172e4b 100755 --- a/llvm-build/build_ncurses.sh +++ b/llvm-build/build_ncurses.sh @@ -11,8 +11,7 @@ PREBUILT_PATH=$4 CLANG_VERSION=$5 NCURSES_VERSION=$6 TARGET=$7 -NCURSES_UNTAR_PATH=$8 -IS_STATIC=$9 +IS_STATIC=$8 SPECFILE="${NCURSES_SRC_DIR}/ncurses.spec" @@ -41,13 +40,8 @@ esac CC_PATH=${PREBUILT_PATH}/clang/ohos/${host_platform}-${host_cpu}/clang-${CLANG_VERSION}/bin/clang CXX_PATH=${PREBUILT_PATH}/clang/ohos/${host_platform}-${host_cpu}/clang-${CLANG_VERSION}/bin/clang++ -ncurses_package=${NCURSES_SRC_DIR}/ncurses-${NCURSES_VERSION}.tar.gz -if [ -e ${ncurses_package} ]; then - if [ ! -b ${NCURSES_UNTAR_PATH} ]; then - mkdir -p ${NCURSES_UNTAR_PATH} - fi - tar -xvzf ${ncurses_package} --strip-components 1 -C ${NCURSES_UNTAR_PATH} - cd ${NCURSES_UNTAR_PATH} +if [ -d ${NCURSES_SRC_DIR} ]; then + cd ${NCURSES_SRC_DIR} # Get the list of patch files for ncurses.spec # The format in the ncurses.spec is as follows: @@ -61,7 +55,7 @@ if [ -e ${ncurses_package} ]; then patch -Np1 < ${NCURSES_SRC_DIR}/$patch done - if [ ! -b ${NCURSES_BUILD_PATH} ]; then + if [ ! -d ${NCURSES_BUILD_PATH} ]; then mkdir -p ${NCURSES_BUILD_PATH} fi cd ${NCURSES_BUILD_PATH} @@ -77,10 +71,11 @@ if [ -e ${ncurses_package} ]; then export CPPFLAGS="$CPPFALGS -I${SDKROOT}/usr/include -I${SDKROOT}/usr/include/i368" export CFLAGS="$CFLAGS -isysroot${SDKROOT} $flags $stack_flags" - ${NCURSES_UNTAR_PATH}/configure \ + ${NCURSES_SRC_DIR}/configure \ --with-shared \ - --with-default-terminfo-dir=/usr/lib/terminfo:/lib/terminfo:/usr/share/terminfo \ + --with-terminfo-dirs=${NCURSES_INSTALL_PATH}/share/terminfo:/usr/lib/terminfo:/lib/terminfo:/usr/share/terminfo \ --disable-mixed-case \ + --disable-widec \ --prefix=${NCURSES_INSTALL_PATH} \ CC=${CC_PATH} \ CXX=${CXX_PATH} @@ -89,10 +84,12 @@ if [ -e ${ncurses_package} ]; then if [ "${host_platform}" == "linux" ]; then export LDFLAGS="-Wl,-rpath,\$$ORIGIN/../lib $got_ldflags" export CFLAGS="$CFLAGS $stack_flags" - ${NCURSES_UNTAR_PATH}/configure \ + ${NCURSES_SRC_DIR}/configure \ --with-shared \ - --with-default-terminfo-dir=/usr/lib/terminfo:/lib/terminfo:/usr/share/terminfo \ + --disable-widec \ --prefix=${NCURSES_INSTALL_PATH} \ + --datadir=${NCURSES_INSTALL_PATH}/share \ + --with-terminfo-dirs=${NCURSES_INSTALL_PATH}/share/terminfo:/usr/lib/terminfo:/lib/terminfo:/usr/share/terminfo \ CC=${CC_PATH} \ CXX=${CXX_PATH} make -j$(nproc --all) install | tee build_ncurses.log @@ -106,24 +103,28 @@ if [ -e ${ncurses_package} ]; then C_FLAGS="$C_FLAGS $stack_flags" export LDFLAGS="$LDFLAGS $got_ldflags" if [[ ${IS_STATIC} == "static" ]]; then - NCURSES_HOST_INSTALL_PATH=${10} + NCURSES_HOST_INSTALL_PATH=${9} export LD_LIBRARY_PATH="${NCURSES_HOST_INSTALL_PATH}/lib:$LD_LIBRARY_PATH" EXTRA_ARGS="--with-fallbacks=linux,vt100,xterm \ --with-tic-path=${NCURSES_HOST_INSTALL_PATH}/bin/tic \ --with-infocmp-path=${NCURSES_HOST_INSTALL_PATH}/bin/infocmp" fi - ${NCURSES_UNTAR_PATH}/configure \ + ${NCURSES_SRC_DIR}/configure \ --host="${TARGET}" \ --with-shared \ --prefix=${NCURSES_INSTALL_PATH} \ --with-termlib \ --without-manpages \ --with-strip-program="${PREBUILT_PATH}/../out/llvm-install/bin/llvm-strip" \ + --disable-widec \ ${EXTRA_ARGS} \ CC=${PREBUILT_PATH}/../out/llvm-install/bin/clang \ CXX=${PREBUILT_PATH}/../out/llvm-install/bin/clang++ \ CFLAGS="${C_FLAGS}" make -j$(nproc --all) install | tee build_ncurses_${TARGET}.log fi + cd ${NCURSES_SRC_DIR} + git reset --hard HEAD + git clean -df fi diff --git a/llvm-build/cross_toolchain_builder.py b/llvm-build/cross_toolchain_builder.py index 7f2bb792fa7815e9bd22292ceb7e7e22f9719adc..24b573d4b89c16cccbd75507755e9bfe9853fb61 100644 --- a/llvm-build/cross_toolchain_builder.py +++ b/llvm-build/cross_toolchain_builder.py @@ -128,17 +128,18 @@ class CrossToolchainBuilder: lldb_defines["LLDB_ENABLE_CURSES"] = "ON" lldb_defines["CURSES_INCLUDE_DIRS"] = ";".join( [ - self._build_utils.merge_ncurses_install_dir( - self._llvm_triple, "include" + self._build_utils.merge_install_dir( + "ncurses", self._llvm_triple, "include" ), - self._build_utils.merge_ncurses_install_dir( - self._llvm_triple, "include", "ncurses" + self._build_utils.merge_install_dir( + "ncurses", self._llvm_triple, "include", "ncurses" ), ] ) ncurses_libs = [] for library in self._build_utils.get_ncurses_dependence_libs(self._llvm_triple): - library_path = self._build_utils.merge_ncurses_install_dir( + library_path = self._build_utils.merge_install_dir( + "ncurses", self._llvm_triple, "lib", f"{library}.so.%s" % self._build_utils.get_ncurses_version(), @@ -167,13 +168,13 @@ class CrossToolchainBuilder: if self._build_config.build_libedit: lldb_defines["LLDB_ENABLE_LIBEDIT"] = "ON" lldb_defines["LibEdit_INCLUDE_DIRS"] = ( - self._build_utils.merge_libedit_install_dir( - self._llvm_triple, "include" + self._build_utils.merge_install_dir( + "libedit", self._llvm_triple, "include" ) ) lldb_defines["LibEdit_LIBRARIES"] = ( - self._build_utils.merge_libedit_install_dir( - self._llvm_triple, "lib", "libedit.so.0.0.68" + self._build_utils.merge_install_dir( + "libedit", self._llvm_triple, "lib", "libedit.so.0.0.75" ) )