From f210f95f991fc0f9e0699d8b62cf17e26c5d682e Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Tue, 26 Dec 2023 21:23:20 -0500 Subject: [PATCH] Use a temporary folder for the builds. --- .../build_all_feature_flag_combinations.bash | 39 +++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/scripts/build_all_feature_flag_combinations.bash b/scripts/build_all_feature_flag_combinations.bash index 0897c890..b8d90841 100755 --- a/scripts/build_all_feature_flag_combinations.bash +++ b/scripts/build_all_feature_flag_combinations.bash @@ -7,7 +7,40 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" : ${PROFILE:="debug"} +############## Setup ######################### + +function cleanup { + for f in "${folders[@]}"; do + log "Deleting $f" + rm -rf "$f" + done +} +folders=() +for sig in EXIT INT QUIT HUP TERM; do + trap "set +e; cleanup" "$sig" +done + +function die { + local status_code="$1" + shift + (>&2 echo "${@}") + exit "$status_code" +} + +function log { + (>&2 echo "${@}") +} + +############## Program ######################### + function main { + if [ "$#" -gt 0 ]; then + export CARGO_TARGET_DIR="$1" + else + local work_directory=$(mktemp -d -t 'organic.XXXXXX') + folders+=("$work_directory") + export CARGO_TARGET_DIR="$work_directory" + fi local features=(compare foreign_document_test tracing event_count wasm wasm_test) ENABLED_FEATURES= for_each_combination "${features[@]}" } @@ -27,16 +60,16 @@ function for_each_combination { if [ "$#" -gt 0 ]; then ENABLED_FEATURES="$ENABLED_FEATURES" for_each_combination "${@}" elif [ -z "$ENABLED_FEATURES" ]; then - (cd "$DIR/../" && echo "\n\n\n========== no features ==========\n\n\n" && set -x && cargo build "${additional_flags[@]}" --no-default-features) + (cd "$DIR/../" && printf "\n\n\n========== no features ==========\n\n\n" && set -x && cargo build "${additional_flags[@]}" --no-default-features) else - (cd "$DIR/../" && echo "\n\n\n========== ${ENABLED_FEATURES:1} ==========\n\n\n" && set -x && cargo build "${additional_flags[@]}" --no-default-features --features "${ENABLED_FEATURES:1}") + (cd "$DIR/../" && printf "\n\n\n========== %s ==========\n\n\n" "${ENABLED_FEATURES:1}" && set -x && cargo build "${additional_flags[@]}" --no-default-features --features "${ENABLED_FEATURES:1}") fi ENABLED_FEATURES="$ENABLED_FEATURES,$flag" if [ "$#" -gt 0 ]; then ENABLED_FEATURES="$ENABLED_FEATURES" for_each_combination "${@}" else - (cd "$DIR/../" && echo "\n\n\n========== ${ENABLED_FEATURES:1} ==========\n\n\n" && set -x && cargo build "${additional_flags[@]}" --no-default-features --features "${ENABLED_FEATURES:1}") + (cd "$DIR/../" && printf "\n\n\n========== %s ==========\n\n\n" "${ENABLED_FEATURES:1}" && set -x && cargo build "${additional_flags[@]}" --no-default-features --features "${ENABLED_FEATURES:1}") fi }