Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safety and simplification updates for devclean.sh #12

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Changes based on initial round of comments:
 - Default case (no flags provided) now does nothing except print usage
and exit
 - Include "--build" flag to remove build artifacts
 - Include short aliases for all the removal options
mkavulich committed Aug 16, 2024
commit 70b8a9d6ffedb4e6fd5550aca6d50f3368e54c81
33 changes: 22 additions & 11 deletions devclean.sh
Original file line number Diff line number Diff line change
@@ -4,8 +4,7 @@
usage () {
cat << EOF_USAGE

Clean the UFS-SRW Application build. If no arguments are provided, will only delete standard build
artifacts; to delete submodules and/or conda, see optional arguments below.
Clean the UFS-SRW Application build.

NOTE: If user included custom directories at build time, those directories must be deleted manually

@@ -20,11 +19,14 @@ OPTIONS
provide more verbose output

-a, --all
removes all build artifacts, including conda and submodules
--conda
removes all build artifacts, conda and submodules (equivalent to \`-b -c -s\`)
-b, --build
removes build directories and artifacts: build/ exec/ share/ include/ lib/ lib64/
-c, --conda
removes "conda" directory and conda_loc file in SRW
--sub-modules
remove sub-module directories. They will need to be checked out again by running "\${SRW_DIR}/manage_externals/checkout_externals" before attempting subsequent builds
-s, --sub-modules
remove sub-module directories. They will need to be checked out again by running
"./manage_externals/checkout_externals" before attempting subsequent builds

EOF_USAGE
}
@@ -55,18 +57,20 @@ VERBOSE=false

# default clean options
REMOVE=false
REMOVE_BUILD=false
REMOVE_CONDA=false
REMOVE_SUB_MODULES=false

# process arguments
while :; do
case $1 in
--help|-h) usage; exit 0 ;;
--all|-a) REMOVE_CONDA=true; REMOVE_SUB_MODULES=true ;;
--conda) REMOVE_CONDA=true ;;
--all|-a) REMOVE_BUILD=true; REMOVE_CONDA=true; REMOVE_SUB_MODULES=true ;;
--build|-b) REMOVE_BUILD=true ;;
--conda|-c) REMOVE_CONDA=true ;;
--force) REMOVE=true ;;
--force=?*|--force=) usage_error "$1 argument ignored." ;;
--sub-modules) REMOVE_SUB_MODULES=true ;;
--sub-modules|-s) REMOVE_SUB_MODULES=true ;;
--sub-modules=?*|--sub-modules=) usage_error "$1 argument ignored." ;;
--verbose|-v) VERBOSE=true ;;
# unknown
@@ -82,9 +86,10 @@ if [ "${VERBOSE}" = true ] ; then
settings
fi

# Populate "removal_list" as an array of files/directories to remove
# Populate "removal_list" as an array of files/directories to remove, based on user selections

# Standard build artifacts
# Clean standard build artifacts
if [ ${REMOVE_BUILD} == true ]; then
removal_list=( \
"${SRW_DIR}/build" \
"${SRW_DIR}/exec" \
@@ -93,6 +98,7 @@ fi
"${SRW_DIR}/lib" \
"${SRW_DIR}/lib64" \
)
fi

# Clean all the submodules if requested.
if [ ${REMOVE_SUB_MODULES} == true ]; then
@@ -121,6 +127,11 @@ if [ "${REMOVE_CONDA}" = true ] ; then
fi
fi

# If array is empty, that means user has not selected any removal options
if [ ${#removal_list[@]} -eq 0 ]; then
usage_error "No removal options specified"
fi

while [ ${REMOVE} == false ]; do
# Make user confirm deletion of directories unless '--force' option was provided
printf "The following files/directories will be deleted:\n\n"