Skip to content

Commit 21aed88

Browse files
committed
feat(deps): Add little helper function to check for availability of commands
Signed-off-by: Steffen Vogel <[email protected]>
1 parent 908d9e5 commit 21aed88

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

packaging/deps.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ should_build() {
6262
return 0
6363
}
6464

65+
has_command() {
66+
command -v "$1" >/dev/null 2>&1
67+
68+
return $?
69+
}
70+
6571
## Build configuration
6672

6773
# Use shallow git clones to speed up downloads
@@ -424,7 +430,7 @@ if ! pkg-config "nice >= 0.1.16" && \
424430
# Create sub-shell to constrain meson venv and ninja PATH to this build
425431
(
426432
# Install meson
427-
if ! command -v meson; then
433+
if ! has_command meson; then
428434
python3 -m venv venv
429435
. venv/bin/activate
430436
python3 -m pip install --upgrade pip setuptools
@@ -435,7 +441,7 @@ if ! pkg-config "nice >= 0.1.16" && \
435441
fi
436442

437443
# Install ninja
438-
if ! command -v ninja; then
444+
if ! has_command ninja; then
439445
wget https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-linux.zip
440446
unzip ninja-linux.zip
441447
export PATH=${PATH}:.
@@ -492,7 +498,7 @@ if ! find /usr/{local/,}{lib,bin} -name "libOpenDSSC.so" | grep -q . &&
492498
for i in ${SOURCE_DIR}/patches/*-opendssc-*.patch; do patch --strip=1 --binary < "$i"; done
493499
popd
494500
pushd OpenDSS-C/build
495-
if command -v g++-14 2>&1 >/dev/null; then
501+
if has_command g++-14; then
496502
# OpenDSS rev 4020 is not compatible with GCC 15
497503
OPENDSS_CMAKE_OPTS="-DCMAKE_C_COMPILER=gcc-14 -DCMAKE_CXX_COMPILER=g++-14"
498504
else

0 commit comments

Comments
 (0)