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.
This commit is contained in:
Martin Storsjö committed 2025-06-25 11:51:06 +03:00
1 parent 839b37219e
commit d69ccd33a7
1 file changed
+24 -4
+24 -4
View File
@@ -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