From a50a641f4b5a1398fcc811264272aae5bdd3b763 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Mon, 18 Mar 2024 14:08:40 -0700 Subject: [PATCH] Handle new LLVM version path In #399, @glandium points out that newer versions of LLVM will place their version information at a different path. This change adapts #399 to the new Python version script. --- version.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/version.py b/version.py index 52dc07ab1..2d9de6d5b 100755 --- a/version.py +++ b/version.py @@ -5,9 +5,10 @@ # # Usage: version [wasi-sdk|llvm|llvm-major|dump] [--llvm-dir=] -import sys import argparse +import os import subprocess +import sys # The number of characters to use for the abbreviated Git revision. GIT_REF_LEN = 12 @@ -75,7 +76,11 @@ def parse_cmake_set(line): def llvm_cmake_version(llvm_dir): - with open(f'{llvm_dir}/llvm/CMakeLists.txt') as file: + path = f'{llvm_dir}/cmake/Modules/LLVMVersion.cmake' + if not os.path.exists(path): + # Handle older LLVM versions; see #399. + path = f'{llvm_dir}/llvm/CMakeLists.txt' + with open(path) as file: for line in file: line = line.strip() if line.startswith('set(LLVM_VERSION_MAJOR'):