diff --git a/llvm-build/build.py b/llvm-build/build.py index d8c72488c7c4f3e5f232b3ab627a1cfd36eb37dc..6c23c8f8add16f0584c7d1c9d352ef6cb19bf8d5 100755 --- a/llvm-build/build.py +++ b/llvm-build/build.py @@ -692,14 +692,14 @@ class BuildUtils(object): return ncurses_libs def get_libxml2_version(self): - version_file = os.path.join(self.build_config.REPOROOT_DIR, 'third_party', 'libxml2', 'libxml2.spec') + version_file = os.path.join(self.build_config.REPOROOT_DIR, 'third_party', 'libxml2', 'README.OpenSource') if os.path.isfile(version_file): - pattern = r'Version:\s+(\d+\.\d+\.\d+)' + pattern = r'"Version Number"\s*:\s*"(\d+\.\d+\.\d+)"' with open(version_file, 'r') as file: lines = file.readlines() VERSION = '' for line in lines: - if 'Version: ' in line: + if 'Version Number' in line: VERSION = re.search(pattern, line).group(1) if VERSION != '': return VERSION @@ -2868,6 +2868,19 @@ class LlvmPackage(BuildUtils): self.check_copy_file(libxml2_src, lib_dst_path) + find_symbolic_links = lambda target, lib_path: next( + (item for item in os.listdir(lib_path) + if os.path.islink(os.path.join(lib_path, item)) + and os.readlink(os.path.join(lib_path, item)) == target), + None + ) + libxml2_link = find_symbolic_links('libxml2%s' % shlib_ext, lib_path) + if libxml2_link is not None: + libxml2_link_dst = os.path.join(lib_dst_path, libxml2_link) + if os.path.isfile(libxml2_link_dst): + os.remove(libxml2_link_dst) + os.symlink('libxml2%s' % shlib_ext, libxml2_link_dst) + def copy_lzma_to_llvm(self, platform_triple, install_dir): self.logger().info('copy_lzma_to_llvm install_dir is %s', install_dir) @@ -3026,7 +3039,7 @@ def main(): build_config.LIBXML2_VERSION = build_utils.get_libxml2_version() if build_config.LIBXML2_VERSION is None: - raise Exception('LIBXML2 version information not found, please check if the libxml2.spec file exists') + raise Exception('LIBXML2 version information not found, please check if the file README.OpenSource exists') if build_config.build_libxml2: llvm_libs.build_libxml2(build_utils.use_platform(), llvm_make, llvm_install)