Skip to content

Commit a0f62c5

Browse files
committed
Improve bootstrap script's robustness
Users can now either force the removal of an existing BUILD_DIR by passing BUILD_FORCE_REMOVE to ./bootstrap, or they will be prompted to remove the dir if it already exists. Additionally, the bootstrap script will now exit if there is an error in mkdir or cmake.
1 parent 00a096f commit a0f62c5

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

bootstrap

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,29 @@
22

33
BUILD_TYPE=${1:-Release}
44
BUILD_DIR=${BUILD_DIR:-./build}
5+
BUILD_FORCE_REMOVE=${BUILD_FORCE_REMOVE:-false}
6+
SRC_DIR=$(dirname $0)
57

6-
if [ -d ${BUILD_DIR} ]; then
8+
if [ ${BUILD_FORCE_REMOVE} == "true" ]; then
9+
rm -fr ${BUILD_DIR}
10+
elif [ -d ${BUILD_DIR} ]; then
711
echo "Build system already initialized in ${BUILD_DIR}"
8-
exit
12+
13+
read -n 1 -p "Do you want to remove it (this is IMMEDIATE and PERMANENT), y/n? " choice
14+
echo ""
15+
if [ $choice == "y" ]; then
16+
rm -fr ${BUILD_DIR}
17+
else
18+
exit
19+
fi
920
fi
1021

22+
set -e
23+
set -u
24+
1125
mkdir -p ${BUILD_DIR} && \
1226
cd ${BUILD_DIR} && \
13-
cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE}
27+
cmake ${SRC_DIR} -DCMAKE_BUILD_TYPE=${BUILD_TYPE}
1428

1529
echo "TimescaleDB build system initialized in ${BUILD_DIR}. To compile, do:"
1630
echo -e "\033[1mcd ${BUILD_DIR} && make\033[0m"

0 commit comments

Comments
 (0)