From d69ccd33a756e94763e1e91002e4663c3bc0d852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Thu, 8 May 2025 16:55:49 +0300 Subject: [PATCH] build-lldb-mi: Fix finding the build directory As build-llvm now can create a larger variety of build dir names, enumerating all possible suffixes becomes problematic (especially as they don't necessarily appear in one canonical order). Instead, iterate over potential matches. If cross compiling, it is easy as we can require the directory to contain the expected suffix. If not cross compiling, we have no explicit suffix to look for, but we can check that the directory doesn't match common cross compilation triples. --- build-lldb-mi.sh | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/build-lldb-mi.sh b/build-lldb-mi.sh index 7c22821..ebc4db0 100755 --- a/build-lldb-mi.sh +++ b/build-lldb-mi.sh @@ -75,12 +75,32 @@ export LLVM_DIR="$PREFIX" LLVM_SRC="$(pwd)/llvm-project/llvm" if [ -d "$LLVM_SRC" ]; then SUFFIX=${HOST+-}$HOST - for base in build build-asserts; do - if [ -d "$LLVM_SRC/$base$SUFFIX" ]; then - export LLVM_DIR="$LLVM_SRC/$base$SUFFIX" - break + DIRS="" + cd llvm-project/llvm + for dir in build*$SUFFIX; do + if [ -z "$SUFFIX" ]; then + case $dir in + *linux*|*mingw32*) + continue + ;; + esac + fi + if [ -d "$dir" ]; then + DIRS="$DIRS $dir" fi done + if [ -n "$DIRS" ]; then + dir="$(ls -td $DIRS | head -1)" + export LLVM_DIR="$LLVM_SRC/$dir" + echo Using $LLVM_DIR as LLVM build dir + break + else + # No build directory found; this is ok if the installed prefix is a + # full (development) install of LLVM. Warn that we didn't find what + # we were looking for. + echo Warning, did not find a suitable LLVM build dir, assuming $PREFIX contains LLVM development files >&2 + fi + cd ../.. fi if [ -n "$HOST" ]; then