diff --git a/contrib/devtools/build_autotools.sh b/contrib/devtools/build_autotools.sh index e4b00e3b8..36d93455a 100755 --- a/contrib/devtools/build_autotools.sh +++ b/contrib/devtools/build_autotools.sh @@ -1,27 +1,27 @@ #!/usr/bin/env bash export LC_ALL=C set -euxo pipefail : "${TOPLEVEL:=$(git rev-parse --show-toplevel)}" : "${BUILD_DIR:=${TOPLEVEL}/build}" # Default to nothing : "${CONFIGURE_FLAGS:=}" : "${THREADS:=$(nproc || sysctl -n hw.ncpu)}" # Generate necessary autoconf files cd ${TOPLEVEL} ./autogen.sh mkdir -p "${BUILD_DIR}" cd ${BUILD_DIR} rm -f build.status test_bitcoin.xml read -a CONFIGURE_FLAGS <<< "$CONFIGURE_FLAGS --prefix=$(pwd)" -../configure --enable-deprecated-build-system "${CONFIGURE_FLAGS[@]}" +"${TOPLEVEL}"/configure --enable-deprecated-build-system "${CONFIGURE_FLAGS[@]}" # Run build make -j "${THREADS}" "$@" diff --git a/contrib/devtools/build_cmake.sh b/contrib/devtools/build_cmake.sh index a581793a8..41ca413a7 100755 --- a/contrib/devtools/build_cmake.sh +++ b/contrib/devtools/build_cmake.sh @@ -1,87 +1,87 @@ #!/usr/bin/env bash export LC_ALL=C set -euxo pipefail : "${TOPLEVEL:=$(git rev-parse --show-toplevel)}" : "${BUILD_DIR:=${TOPLEVEL}/build}" function usage() { echo "Usage: $0 [--Werror] [targets]" echo "Build the targets using cmake and ninja." echo "If no target is provided the default (all) target is built." echo echo "Options:" echo " --clang: build with clang/clang++" echo " --gcc: build with gcc/g++" echo " --Werror: add -Werror to the compiler flags" echo "Environment variables:" echo " CMAKE_FLAGS: array of the CMAKE flags to use for the build" echo " BUILD_DIR: the build directory, (default: ${BUILD_DIR}})" echo " TOPLEVEL: the project root directory, (default: ${TOPLEVEL}})" } # Default to nothing : "${CMAKE_FLAGS:=}" mkdir -p "${BUILD_DIR}" cd ${BUILD_DIR} git clean -xffd read -a CMAKE_FLAGS <<< "${CMAKE_FLAGS}" TARGETS=() while [[ $# -gt 0 ]]; do case $1 in --clang) CMAKE_FLAGS+=( "-DCMAKE_C_COMPILER=clang" "-DCMAKE_CXX_COMPILER=clang++" ) shift ;; --gcc) CMAKE_FLAGS+=( "-DCMAKE_C_COMPILER=gcc" "-DCMAKE_CXX_COMPILER=g++" ) shift ;; --Werror) CMAKE_FLAGS+=( "-DCMAKE_C_FLAGS=-Werror" "-DCMAKE_CXX_FLAGS=-Werror" ) shift ;; *) TARGETS+=("$1") shift ;; esac done -cmake -GNinja .. "${CMAKE_FLAGS[@]}" +cmake -GNinja "${TOPLEVEL}" "${CMAKE_FLAGS[@]}" # If valid targets are given, use them, otherwise default to "all". if [ ${#TARGETS[@]} -eq 0 ]; then TARGETS=("all") else mapfile -t VALID_TARGETS < <(ninja -t targets all | cut -d ':' -f 1) # "all" is not part of the targets exported by ninja, so add it. VALID_TARGETS+=("all") IFS=" " for TARGET in "${TARGETS[@]}" do # The array prints as a space delimited word list, surround the target with # spaces to avoid partial match. if [[ ! " ${VALID_TARGETS[*]} " =~ \ ${TARGET}\ ]]; then echo "Trying to build an invalid target: ${TARGET}" exit 2 fi done fi # Run build ninja "${TARGETS[@]}"