Avoid using the nonstandard "which" command

This command isn't a standard tool; different distributions have
different implementations, and e.g. Fedora doesn't ship it by
default.

Settle on using "command -v $tool >/dev/null" for tests about whether
a tool is available. (We could also use "hash $tool 2>/dev/null" as we
already had in build-all.sh, but settling on using "command -v"
everywhere, for consistency and simplicity.)
This commit is contained in:
Martin Storsjö committed 2022-08-02 15:17:24 +03:00
1 parent f2ebd644ae
commit 3d4e36806a
11 files changed
+15 -15

No files matched your search

+1 -1
View File
@@ -60,7 +60,7 @@ if [ -z "$PREFIX" ]; then
fi
for dep in git curl cmake; do
if ! hash $dep 2>/dev/null; then
if ! command -v $dep >/dev/null; then
echo "$dep not installed. Please install it and retry" 1>&2
exit 1
fi
+1 -1
View File
@@ -47,7 +47,7 @@ if [ ! -d llvm-project/compiler-rt ] || [ -n "$SYNC" ]; then
CHECKOUT_ONLY=1 ./build-llvm.sh
fi
if [ -n "$(which ninja)" ]; then
if command -v ninja >/dev/null; then
CMAKE_GENERATOR="Ninja"
NINJA=1
BUILDCMD=ninja
+1 -1
View File
@@ -55,7 +55,7 @@ LLVM_PATH="$(pwd)/llvm"
cd runtimes
if [ -n "$(which ninja)" ]; then
if command -v ninja >/dev/null; then
CMAKE_GENERATOR="Ninja"
NINJA=1
BUILDCMD=ninja
+2 -2
View File
@@ -22,7 +22,7 @@ if [ $# -lt 1 ]; then
fi
MAKE=make
if [ -n "$(which gmake)" ]; then
if command -v gmake >/dev/null; then
MAKE=gmake
fi
@@ -37,7 +37,7 @@ export PATH="$PREFIX/bin:$PATH"
: ${ARCHS:=${TOOLCHAIN_ARCHS-i686 x86_64 armv7 aarch64}}
download() {
if [ -n "$(which wget)" ]; then
if command -v wget >/dev/null; then
if [ -n "$2" ]; then
wget -O "$2" "$1"
else
+1 -1
View File
@@ -51,7 +51,7 @@ if [ -n "$SYNC" ] || [ -n "$CHECKOUT" ]; then
cd ..
fi
if [ -n "$(which ninja)" ]; then
if command -v ninja >/dev/null; then
CMAKE_GENERATOR="Ninja"
NINJA=1
BUILDCMD=ninja
+4 -4
View File
@@ -125,7 +125,7 @@ fi
[ -z "$CHECKOUT_ONLY" ] || exit 0
if [ -n "$(which ninja)" ]; then
if command -v ninja >/dev/null; then
CMAKE_GENERATOR="Ninja"
NINJA=1
BUILDCMD=ninja
@@ -165,8 +165,8 @@ if [ -n "$HOST" ]; then
break
fi
done
if [ -z "$native" ] && [ -n "$(which llvm-tblgen)" ]; then
native="$(dirname $(which llvm-tblgen))"
if [ -z "$native" ] && command -v llvm-tblgen >/dev/null; then
native="$(dirname $(command -v llvm-tblgen))"
suffix=""
if [ -x "$native/llvm-tblgen.exe" ]; then
suffix=".exe"
@@ -191,7 +191,7 @@ if [ -n "$HOST" ]; then
CMAKEFLAGS="$CMAKEFLAGS -DCLANG_PSEUDO_GEN=$native/clang-pseudo-gen$suffix"
fi
fi
CROSS_ROOT=$(cd $(dirname $(which $HOST-gcc))/../$HOST && pwd)
CROSS_ROOT=$(cd $(dirname $(command -v $HOST-gcc))/../$HOST && pwd)
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_FIND_ROOT_PATH=$CROSS_ROOT"
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER"
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY"
+1 -1
View File
@@ -45,7 +45,7 @@ PREFIX="$(cd "$PREFIX" && pwd)"
: ${ARCHS:=${TOOLCHAIN_ARCHS-i686 x86_64 armv7 aarch64}}
download() {
if [ -n "$(which wget)" ]; then
if command -v wget >/dev/null; then
wget "$1"
else
curl -LO "$1"
+1 -1
View File
@@ -49,7 +49,7 @@ fi
cd mingw-w64
MAKE=make
if [ -n "$(which gmake)" ]; then
if command -v gmake >/dev/null; then
MAKE=gmake
fi
+1 -1
View File
@@ -62,7 +62,7 @@ fi
[ -z "$CHECKOUT_ONLY" ] || exit 0
MAKE=make
if [ -n "$(which gmake)" ]; then
if command -v gmake >/dev/null; then
MAKE=gmake
fi
+1 -1
View File
@@ -35,7 +35,7 @@ fi
cd llvm-project/openmp
if [ -n "$(which ninja)" ]; then
if command -v ninja >/dev/null; then
CMAKE_GENERATOR="Ninja"
NINJA=1
BUILDCMD=ninja
+1 -1
View File
@@ -48,7 +48,7 @@ if [ -z "$CHECKOUT_ONLY" ]; then
fi
MAKE=make
if [ -n "$(which gmake)" ]; then
if command -v gmake >/dev/null; then
MAKE=gmake
fi