Skip to content

Commit a50a641

Browse files
committed
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.
1 parent c376c9c commit a50a641

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

version.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
#
66
# Usage: version [wasi-sdk|llvm|llvm-major|dump] [--llvm-dir=<non-project dir>]
77

8-
import sys
98
import argparse
9+
import os
1010
import subprocess
11+
import sys
1112

1213
# The number of characters to use for the abbreviated Git revision.
1314
GIT_REF_LEN = 12
@@ -75,7 +76,11 @@ def parse_cmake_set(line):
7576

7677

7778
def llvm_cmake_version(llvm_dir):
78-
with open(f'{llvm_dir}/llvm/CMakeLists.txt') as file:
79+
path = f'{llvm_dir}/cmake/Modules/LLVMVersion.cmake'
80+
if not os.path.exists(path):
81+
# Handle older LLVM versions; see #399.
82+
path = f'{llvm_dir}/llvm/CMakeLists.txt'
83+
with open(path) as file:
7984
for line in file:
8085
line = line.strip()
8186
if line.startswith('set(LLVM_VERSION_MAJOR'):

0 commit comments

Comments
 (0)