Making sure to cd back
[WPS.git] / cleanCMake.sh
blob9ea2b1800b9e4bf09cb0ed1d9c6a3b4ef700f6c4
1 #!/bin/sh
2 BUILD_DIR=_build
3 INSTALL_DIR=run
4 TEST_DIR=test/
6 function help()
8 echo "./cleanCMake.sh [options]"
9 echo " -c Basic cmake clean functionality [cmake --build ${BUILD_DIR} -j 1 --target clean]"
10 echo " -i Remove cmake binary installs [xargs rm < ${BUILD_DIR}/install_manifest.txt]"
11 # echo " -l Remove symlinks (WPS) [ find ${TEST_DIR} -type l -exec rm {} \; ]"
12 echo " -f Remove build & install folders (WPS) [ rm ${BUILD_DIR} -r; rm ${INSTALL_DIR}/ -r ]"
13 echo " -a Remove all (WPS), equivalent to -f (more specifically -c -i -f)"
16 CLEAN_BASIC_BUILD=FALSE
17 CLEAN_BASIC_INSTALL=FALSE
18 CLEAN_LINKS=FALSE
19 CLEAN_FOLDERS=FALSE
20 CLEAN_ALL=FALSE
22 while getopts "hcilfa" opt; do
23 case ${opt} in
25 CLEAN_BASIC_BUILD=TRUE
28 CLEAN_BASIC_INSTALL=TRUE
31 CLEAN_LINKS=TRUE
34 CLEAN_FOLDERS=TRUE
37 CLEAN_ALL=TRUE
39 h) help; exit 0 ;;
40 *) help; exit 1 ;;
41 :) help; exit 1 ;;
42 \?) help; exit 1 ;;
43 esac
44 done
46 if [[ $OPTIND -eq 1 ]]; then
47 # Do basic clean I guess
48 CLEAN_BASIC_BUILD=TRUE
51 if [[ "${CLEAN_BASIC_BUILD}" == "TRUE" || "${CLEAN_ALL}" == "TRUE" ]]; then
52 echo "Doing cmake make clean"
53 OLD_DIR=$PWD
54 cd ${BUILD_DIR} && make -j 1 clean; cd $OLD_DIR
57 if [[ "${CLEAN_BASIC_INSTALL}" == "TRUE" || "${CLEAN_ALL}" == "TRUE" ]]; then
58 echo "Removing binary installs"
59 xargs rm < ${BUILD_DIR}/install_manifest.txt
62 # if [[ "${CLEAN_LINKS}" == "TRUE" || "${CLEAN_ALL}" == "TRUE" ]]; then
63 # echo "Removing all symlinks in ${TEST_DIR}"
64 # find ${TEST_DIR} -type l -exec rm {} \;
65 # fi
67 if [[ "${CLEAN_FOLDERS}" == "TRUE" || "${CLEAN_ALL}" == "TRUE" ]]; then
68 echo "Deleting ${BUILD_DIR} & ${INSTALL_DIR}/"
69 rm ${BUILD_DIR} -r; rm ${INSTALL_DIR}/ -r