ENH: add 'subcommand' handling to wclean (#1693)

- wcleanBuild, wcleanPlatform now accessible as "wclean -build" and
  "wclean -platform", respectively
This commit is contained in:
Mark Olesen
2020-05-11 11:06:01 +02:00
parent 9e3d06853e
commit f99561700b
6 changed files with 53 additions and 19 deletions

1
wmake/scripts/wclean-build Symbolic link
View File

@ -0,0 +1 @@
wcleanObjects

View File

@ -0,0 +1 @@
wcleanObjects

View File

@ -12,10 +12,11 @@
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
# #
# Script # Script
# wcleanBuild, wcleanPlatform # wmake/scripts/wcleanObjects
# Backend for "wclean -build", "wclean -platform"
# #
# Usage # Usage
# wcleanBuild <option | platform> [.. <option | platform>] # wclean-build <option | platform> [.. <option | platform>]
# #
# Description # Description
# Deletes the specified 'build/' object files directories from the # Deletes the specified 'build/' object files directories from the
@ -34,10 +35,9 @@
# tutorials # tutorials
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
Script="${0##*/}"
targetDir=build # Safe default - override based on script name targetDir=build # Safe default - override based on script name
case "$Script" in case "${0##*/}" in
(*[Pp]latform*) (*[Pp]latform*)
targetDir=platforms targetDir=platforms
;; ;;
@ -57,15 +57,15 @@ usage() {
Usage: ${0##*/} <option | platform> [.. <option | platform>] Usage: ${0##*/} <option | platform> [.. <option | platform>]
options: options:
-a, -all Same as 'all' -a | -all Same as 'all'
-curr, -current Use \$WM_OPTIONS ($WM_OPTIONS) -curr | -current Use \$WM_OPTIONS ($WM_OPTIONS)
-comp, -compiler Use \$WM_ARCH\$WM_COMPILER* ($WM_ARCH$WM_COMPILER) -comp | -compiler Use \$WM_ARCH\$WM_COMPILER* ($WM_ARCH$WM_COMPILER)
-compiler=NAME Use \$WM_ARCH<NAME>* ($WM_ARCH<NAME>*) -compiler=NAME Use \$WM_ARCH<NAME>* ($WM_ARCH<NAME>*)
-h, -help Print the usage -h | -help Print the usage
Deletes specified $targetDir object file directories from project top-level:
Deletes the specified $targetDir/ object file directories from the project Project: $WM_PROJECT_DIR
top-level $targetDir/ directory $WM_PROJECT_DIR. Directory: $targetDir/
special platforms: special platforms:
all Remove all platforms$extraText all Remove all platforms$extraText
@ -90,7 +90,7 @@ done
wmake -check-dir -quiet "$WM_PROJECT_DIR" 2>/dev/null || \ wmake -check-dir -quiet "$WM_PROJECT_DIR" 2>/dev/null || \
wmake -check-dir -quiet "$WM_THIRD_PARTY_DIR" 2>/dev/null || \ wmake -check-dir -quiet "$WM_THIRD_PARTY_DIR" 2>/dev/null || \
{ {
cat<<ERROR cat<<ERROR
${0##*/}: Error incorrect top-level directory ${0##*/}: Error incorrect top-level directory
Not in Project: $WM_PROJECT_DIR Not in Project: $WM_PROJECT_DIR

View File

@ -31,30 +31,51 @@
# Usage # Usage
# wclean [OPTION] [dir] # wclean [OPTION] [dir]
# wclean [OPTION] target [dir [MakeDir]] # wclean [OPTION] target [dir [MakeDir]]
# wclean -subcommand ...
# #
# Description # Description
# Clean up the wmake control directory Make/\$WM_OPTIONS and remove the # Clean up the wmake control directory Make/\$WM_OPTIONS and remove the
# lnInclude directories generated for libraries. # lnInclude directories generated for libraries.
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
Script="${0##*/}" # Use 'Script' for error messages in wmakeFunctions Script="${0##*/}" # Need 'Script' for wmakeFunctions messages
. "${0%/*}"/scripts/wmakeFunctions # Source wmake functions scriptsDir="${0%/*}"/scripts # wmake/scripts directory
. "$scriptsDir"/wmakeFunctions # Source wmake functions
printHelp() { printHelp() {
cat<<HELP_INFO cat<<HELP_HEAD
Usage: $Script [OPTION] [dir] Usage: $Script [OPTION] [dir]
$Script [OPTION] target [dir [MakeDir]] $Script [OPTION] target [dir [MakeDir]]
$Script -subcommand ...
options: options:
-a | -all All subdirectories, uses Allwclean, Allclean if they exist -a | -all All subdirectories, uses Allwclean, Allclean if they exist
-s | -silent Ignored - for compatibility with wmake -s | -silent Silent mode (ignored - for compatibility with wmake)
-h | -help Display short help and exit -h | -help Display short help and exit
-help-full Display full help and exit -help-full Display full help and exit
subcommands (wclean subcommand -help for more information):
HELP_HEAD
if [ -n "$1" ]
then
cat<<HELP_SUBCOMMANDS
-build Remove specified build/ object directories
-platform Remove specified platforms/ object directories
HELP_SUBCOMMANDS
else
cat<<HELP_SUBCOMMANDS
-build -platform
HELP_SUBCOMMANDS
fi
cat<<HELP_TAIL_COMMON
Clean up the wmake control directory Make/\$WM_OPTIONS and remove the Clean up the wmake control directory Make/\$WM_OPTIONS and remove the
lnInclude directories generated for libraries. lnInclude directories generated for libraries.
HELP_INFO HELP_TAIL_COMMON
cat<<HELP_TAIL_FULL cat<<HELP_TAIL_FULL
Special targets: Special targets:
@ -99,6 +120,19 @@ do
-h | -help*) # Short help -h | -help*) # Short help
printHelp printHelp
;; ;;
# Forward to scripts/wclean-build
-build) shift
exec "$scriptsDir/wclean-build" "$@"
exit $?
;;
# Forward to scripts/wclean-platform
-platform*) shift
exec "$scriptsDir/wclean-platform" "$@"
exit $?
;;
-a | -all | all) -a | -all | all)
targetType=all targetType=all
;; ;;

View File

@ -1 +0,0 @@
scripts/wcleanObjects

View File

@ -1 +0,0 @@
scripts/wcleanObjects