Skip to content

Commit

Permalink
Handle new LLVM version path
Browse files Browse the repository at this point in the history
In WebAssembly#399, @glandium points out that newer versions of LLVM will place
their version information at a different path. This change adapts WebAssembly#399
to the new Python version script.
  • Loading branch information
abrown authored and PiCoPress committed Mar 22, 2024
1 parent 737a19f commit 5edca8a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
#
# Usage: version [wasi-sdk|llvm|llvm-major|dump] [--llvm-dir=<non-project 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
Expand Down Expand Up @@ -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'):
Expand Down

0 comments on commit 5edca8a

Please sign in to comment.