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

- initial split of wmake-related commands into "plumbing" and
  "porcelain" akin to how git handles things.

- wmakeBuildInfo (very low-level), now relocated to the wmake/scripts
  and accessible for the user as "wmake -build-info".

  This satisfies a long-standing desire to access build information
  in a fashion similar to the api/patch information.

CONFIG: avoid git information when building with a debian/ directory

- when a 'debian/' directory exists, there is a high probability that
  the '.git/' directory is from debian and not from OpenFOAM (ie,
  useless here). This corresponds to an implicit '-no-git', which has
  no effect when building from pristine sources.

ENH: wmakeCheckPwd becomes scripts/wmake-check-dir

- accessible for the user as "wmake -check-dir" and with 1 or 2
  directory names. A wmakeCheckPwd symlink left for compatibility.
This commit is contained in:
Mark Olesen 2020-05-11 10:55:23 +02:00
parent 8bd9f41efd
commit 9e3d06853e
17 changed files with 282 additions and 207 deletions

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# Run from OPENFOAM top-level directory only # Run from OPENFOAM top-level directory only
cd "${0%/*}" || exit cd "${0%/*}" || exit
wmakeCheckPwd "$WM_PROJECT_DIR" 2>/dev/null || { wmake -check-dir "$WM_PROJECT_DIR" 2>/dev/null || {
echo "Error (${0##*/}) : not located in \$WM_PROJECT_DIR" echo "Error (${0##*/}) : not located in \$WM_PROJECT_DIR"
echo " Check your OpenFOAM environment and installation" echo " Check your OpenFOAM environment and installation"
exit 1 exit 1

View File

@ -1,59 +1,60 @@
# META-INFO # META-INFO
Meta-information is for OpenFOAM internal use only. Meta-information is generally for OpenFOAM internal use only.
Do not rely on any files or any file contents in this directory,
or even the existence of this directory.
The format, content and meaning may be changed at anytime without The format, content and meaning may be changed at anytime without
notice. notice. If any of these are changed, these are some of places that
will need to be updated accordingly:
The information is provided here for internal documentation purposes. - bin/foamEtcFile
- bin/tools/foamConfigurePaths
- bin/tools/foamPackRelease
- etc/openfoam
- wmake/scripts/wmake-build-info
## api-info ## api-info
This file and its contents are to be tracked by git. This file and its contents are to be tracked by git.
- File content (api) generated by wmakeBuildInfo from OPENFOAM define - File content (api) generated by `wmake -build-info` from the
in `wmake/rules/General/general` `OPENFOAM` define in `wmake/rules/General/general`
- File content (patch) is manually generated content. - File content (patch) is manually generated content.
## build-info ## build-info
This file is *never* to be tracked by git, but may be present in shipped This file is ***never*** to be tracked by git, but may be present in
source archives. shipped source archives.
- File content (branch, build) generated by wmakeBuildInfo from git - File content (branch, build) generated by `wmake -build-info` from
information and cached from previous wmake (api) git information and cached from previous wmake (api)
## Content types ## Content types
### api ### api
Format: `date +%y%m`
- 4-digit year-month (YYMM) integer corresponding to the major - 4-digit year-month (YYMM) integer corresponding to the major
release or in unusual cases an intermediate release. release or in unusual cases an intermediate release.
Example, `1712` for the Dec-2017 release.
- Format is year-month, as per `date +%y%m`.
Eg, `1712` for the Dec-2017 release.
### patch ### patch
Format: `date +%y%m%d`
- 6-digit year-month-day (YYMMDD) integer corresponding to a patch-level - 6-digit year-month-day (YYMMDD) integer corresponding to a patch-level
for the given **released** API. for the given **released** API.
- The first release can have a patch value of `0` or `1` which
- Format is year-month-day, as per `date +%y%m%d`. indicates that it is unpatched or just released. Alternatively
it can have a patch value corresponding to the release date.
- The first release can have a patch value of `0` (unpatched = just
released) or a patch value corresponding to the release date.
The patch value is only meaningful together with the api value. The patch value is only meaningful together with the api value.
However, for *development* branches, the patch level should not be However, for *development* branches, the patch level should not be
ascribed much meaning -- it can be `0` or have a value corresponding ascribed too much meaning, but will often correspond to the last
to the last merge with a *maintenance* (*eg*, `master`) branch. merge with a *maintenance* (*eg*, `master`) branch.
## Flow of information ## Flow of information
@ -70,9 +71,9 @@ distributions to have a record of the same information.
| build | git | build-info | | build | git | build-info |
The command `wmakeBuildInfo -check` is used to determine if The command `wmake -build-info -check` is used to determine if
the saved information needs synchronization. The command the saved information needs synchronization. The command
`wmakeBuildInfo -update` preforms the synchronitzation. `wmake -build-info -update` performs the synchronization.
## Notes ## Notes
@ -82,4 +83,4 @@ contains more permanent information, whereas the `build-info` is more
transient in nature. transient in nature.
---- ----
2019-01-23 2020-05-05

View File

@ -85,10 +85,10 @@ As can be seen in this example, the git build information is
supplemented by the date when the last change was authored, which can supplemented by the date when the last change was authored, which can
be helpful when the repository contains local changes. If you simply be helpful when the repository contains local changes. If you simply
wish to know the current API and patch levels directly, the wish to know the current API and patch levels directly, the
`wmakeBuildInfo` script provides the relevant information even `wmake -build-info` provides the relevant information even
when OpenFOAM has not yet been compiled: when OpenFOAM has not yet been compiled:
``` ```
$ wmakeBuildInfo $ wmake -build-info
make make
api = 1812 api = 1812
patch = 190531 patch = 190531
@ -207,4 +207,4 @@ ThirdParty directory will contain either an `Allwmake` file or a
- [Community](http://www.openfoam.com/community/), [Governance](http://www.openfoam.com/governance/) - [Community](http://www.openfoam.com/community/), [Governance](http://www.openfoam.com/governance/)
- [Contacting OpenCFD](http://www.openfoam.com/contact/) - [Contacting OpenCFD](http://www.openfoam.com/contact/)
Copyright 2016-2019 OpenCFD Ltd Copyright 2016-2020 OpenCFD Ltd

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# Run from OPENFOAM applications/ directory only # Run from OPENFOAM applications/ directory only
cd "${0%/*}" || exit cd "${0%/*}" || exit
wmakeCheckPwd "$WM_PROJECT_DIR/applications" 2>/dev/null || { wmake -check-dir "$WM_PROJECT_DIR/applications" 2>/dev/null || {
echo "Error (${0##*/}) : not located in \$WM_PROJECT_DIR/applications" echo "Error (${0##*/}) : not located in \$WM_PROJECT_DIR/applications"
echo " Check your OpenFOAM environment and installation" echo " Check your OpenFOAM environment and installation"
exit 1 exit 1

View File

@ -43,9 +43,11 @@
# Note # Note
# This script must exist in the project 'bin' directory # This script must exist in the project 'bin' directory
# #
# The '-show-api' and '-show-patch' options implement partial logic # The '-show-api' and '-show-patch' options extract values from
# from wmake/wmakeBuildInfo. # the "META-INFO/api-info" file
# Make sure that any changes there are also reflected here. #
# SeeAlso
# META-INFO/README.md for other routines that also use META-INFO.
# #
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
printHelp() { printHelp() {

View File

@ -264,7 +264,7 @@ patch="$(git --git-dir="$gitbase/.git" show "$sha1" | sed -ne s/patch=//p)"
[ -n "$api" ] || die "Could resolve api value" [ -n "$api" ] || die "Could resolve api value"
# Determine the BUILD information from git, as per wmakeBuildInfo. # Determine the BUILD information from git, as per `wmake -build-info`
build="$(git --git-dir="$gitbase/.git" log -1 --date=short --format='%h=%ad' 2>/dev/null|sed 's/-//g;s/=/-/')" build="$(git --git-dir="$gitbase/.git" log -1 --date=short --format='%h=%ad' 2>/dev/null|sed 's/-//g;s/=/-/')"
echo "Detected api, patch, build as '$api', '$patch', '$build'" 1>&2 echo "Detected api, patch, build as '$api', '$patch', '$build'" 1>&2

View File

@ -34,6 +34,9 @@
# However, the '-D' options grant more flexibility. For example, # However, the '-D' options grant more flexibility. For example,
# etc/openfoam -DWM_COMPILER=Clang # etc/openfoam -DWM_COMPILER=Clang
# #
# SeeAlso
# META-INFO/README.md for other routines that also use META-INFO.
#
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Auto-detect from location. Do not call from within the etc/directory itself! # Auto-detect from location. Do not call from within the etc/directory itself!
projectDir="$(\cd "$(dirname "${0%/*}")" && \pwd -L)" projectDir="$(\cd "$(dirname "${0%/*}")" && \pwd -L)"

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# Run from OPENFOAM src/ directory only # Run from OPENFOAM src/ directory only
cd "${0%/*}" || exit cd "${0%/*}" || exit
wmakeCheckPwd "$WM_PROJECT_DIR/src" 2>/dev/null || { wmake -check-dir "$WM_PROJECT_DIR/src" 2>/dev/null || {
echo "Error (${0##*/}) : not located in \$WM_PROJECT_DIR/src" echo "Error (${0##*/}) : not located in \$WM_PROJECT_DIR/src"
echo " Check your OpenFOAM environment and installation" echo " Check your OpenFOAM environment and installation"
exit 1 exit 1

View File

@ -6,11 +6,11 @@ touch=true
case "$1" in case "$1" in
-check) -check)
if wmakeBuildInfo -check if wmake -build-info -check
then then
unset touch unset touch
fi fi
;; ;;
esac esac
if [ -n "$touch" ] if [ -n "$touch" ]

View File

@ -4,7 +4,7 @@ SUFFIXES += .Cver
# Update strings in C++ file and in META-INFO files # Update strings in C++ file and in META-INFO files
Cvertoo = \ Cvertoo = \
wmakeBuildInfo -update -filter $< > $(@D)/$(<F).C; \ $(WM_SCRIPTS)/wmake-build-info -update -filter $< > $(@D)/$(<F).C; \
$(CC) $(c++FLAGS) -c $(@D)/$(<F).C -o $@ $(CC) $(c++FLAGS) -c $(@D)/$(<F).C -o $@
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -6,11 +6,10 @@
# \\ / A nd | www.openfoam.com # \\ / A nd | www.openfoam.com
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Copyright (C) 2017-2018 OpenCFD Ltd. # Copyright (C) 2017-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# License # License
# This file is part of OpenFOAM, licensed under GNU General Public License # This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
# <http://www.gnu.org/licenses/>.
# #
# Script # Script
# wcleanBuild, wcleanPlatform # wcleanBuild, wcleanPlatform
@ -88,8 +87,8 @@ done
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Run from OPENFOAM or THIRDPARTY top-level directory only # Run from OPENFOAM or THIRDPARTY top-level directory only
wmakeCheckPwd -q "$WM_PROJECT_DIR" 2>/dev/null || \ wmake -check-dir -quiet "$WM_PROJECT_DIR" 2>/dev/null || \
wmakeCheckPwd -q "$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

View File

@ -12,7 +12,8 @@
# 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
# wmakeBuildInfo # wmake/scripts/wmake-build-info
# Backend for "wmake -build-info"
# #
# Description # Description
# Print the api/version and other build information for the project. # Print the api/version and other build information for the project.
@ -22,10 +23,19 @@
# - WM_PROJECT_VERSION # - WM_PROJECT_VERSION
# - WM_DIR (unset defaults to WM_PROJECT_DIR/wmake) # - WM_DIR (unset defaults to WM_PROJECT_DIR/wmake)
# #
# Files
# - META-INFO/{api-info,build-info}
# - wmake/rules/General/general
# - debian : implicitly disables git queries
#
# Note # Note
# Partial logic is also implemented in the bin/foamEtcFile # When a 'debian/' directory exists, the '.git/' directory is most
# -show-api and -show-patch options. # likely from debian and not from OpenFOAM (ie, useless here).
# Make sure that changes here are also reflected there. # This corresponds to an implicit '-no-git', which has no effect
# when building from pristine sources.
#
# SeeAlso
# META-INFO/README.md for other routines that also use META-INFO.
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Locations # Locations
@ -33,11 +43,9 @@ rulesFile="${WM_DIR:-$WM_PROJECT_DIR/wmake}/rules/General/general"
META_INFO="$WM_PROJECT_DIR/META-INFO" META_INFO="$WM_PROJECT_DIR/META-INFO"
FOAM_GIT_DIR="$WM_PROJECT_DIR/.git" FOAM_GIT_DIR="$WM_PROJECT_DIR/.git"
usage() { printHelp() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE cat<<USAGE
Usage: ${0##*/} [OPTION] Usage: ${0##*/} [OPTION]
${0##*/} [-update] -filter FILE ${0##*/} [-update] -filter FILE
options: options:
@ -56,7 +64,7 @@ options:
-show-patch Print patch value from meta-info and exit -show-patch Print patch value from meta-info and exit
-help Print the usage -help Print the usage
Query/manage status of api,branch,build information. Query/manage status of {api,branch,build} information.
Default without any arguments is the same as '-query-make'. Default without any arguments is the same as '-query-make'.
USAGE USAGE
@ -85,7 +93,7 @@ while [ "$#" -gt 0 ]
do do
case "$1" in case "$1" in
-h | -help*) -h | -help*)
usage printHelp
;; ;;
-cmp | -check) -cmp | -check)
optCheck=true optCheck=true
@ -124,7 +132,7 @@ do
unset FOAM_GIT_DIR unset FOAM_GIT_DIR
;; ;;
*) *)
die "unknown option/argument: '$1'" die "Unknown option/argument: '$1'"
;; ;;
esac esac
shift shift
@ -137,6 +145,11 @@ done
[ -d "$META_INFO" ] || \ [ -d "$META_INFO" ] || \
die "No ${META_INFO##*/}/ directory for project" die "No ${META_INFO##*/}/ directory for project"
# Disable git queries for debian packaging (see notes above)
if [ -d "$WM_PROJECT_DIR/debian" ]
then
unset FOAM_GIT_DIR
fi
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
@ -146,7 +159,7 @@ then
if [ -f "$META_INFO/build-info" ] if [ -f "$META_INFO/build-info" ]
then then
echo "Removing project ${META_INFO##*/}/build-info" 1>&2 echo "Removing project ${META_INFO##*/}/build-info" 1>&2
rm -f "$META_INFO/build-info" 2>/dev/null rm -f "$META_INFO/build-info"
else else
echo "Already removed project ${META_INFO##*/}/build-info" 1>&2 echo "Already removed project ${META_INFO##*/}/build-info" 1>&2
fi fi

134
wmake/scripts/wmake-check-dir Executable file
View File

@ -0,0 +1,134 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# Copyright (C) 2011-2015 OpenFOAM Foundation
# Copyright (C) 2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# wmake/scripts/wmake-check-dir
# Backend for "wmake -check-dir"
#
# wmake/wmakeCheckPwd (1912 and earlier)
#
# Usage
# wmake-check-dir <dir>
# wmake-check-dir <dir> <dir2>
#
# Description
# Check that two directories are identical after resolving the absolute
# paths. If only a single directory is specified, check against the
# working directory.
#
# Exit status 0 when directories are identical.
#
#-------------------------------------------------------------------------------
printHelp() {
cat<<USAGE
Usage: ${0##*/} [OPTION] dir [dir2]
options:
-q | -quiet suppress all normal output
-h | -help display short help and exit
Check that two directories are identical after resolving the absolute paths.
If only a single directory is specified, check against the working directory.
Exit status 0 when directories are identical
Exit status 1 on error
USAGE
exit 0 # A clean exit
}
# Report error and exit
unset optQuiet
die()
{
if [ -z "$optQuiet" ]
then
exec 1>&2
echo "${0##*/}: $1"
shift
while [ "$#" -ge 1 ]; do echo " $1"; shift; done
fi
exit 1
}
#------------------------------------------------------------------------------
# Parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help*)
printHelp
;;
-q | -quiet | -s | -silent)
optQuiet=true
;;
--)
shift
break
;;
-*)
die "Unknown option: '$1'" "See '${0##*/} -help' for usage"
;;
*)
break
;;
esac
shift
done
dirName1="${1%/}"
dirName2="${2%/}"
: "${dirName1:=/}"
: "${dirName2:=$PWD}"
[ "$#" -eq 1 ] || \
[ "$#" -eq 2 ] || \
die "Expected 1 or 2 arguments, was given $#"
# Simple lexical check
[ "$dirName1" = "$dirName2" ] && exit 0
# Check existence
[ -d "$dirName1" ] || die "Directory does not exist '$dirName1'"
resolved1="$(cd "$dirName1" 2>/dev/null && pwd -P)"
if [ "$#" -eq 1 ]
then
resolved2="$(pwd -P)"
else
# Check existence
[ -d "$dirName2" ] || die "Directory does not exist '$dirName2'"
resolved2="$(cd "$dirName2" 2>/dev/null && pwd -P)"
fi
# Compare absolute paths, without symlinks
if [ "$resolved1" = "$resolved2" ]
then
exit 0
fi
if [ "$#" -eq 1 ]
then
die "Current directory is not '$dirName1'"
else
die "Directories are different"
fi
#------------------------------------------------------------------------------

View File

@ -175,15 +175,15 @@ then
-name .git -prune -o -type d -print) -name .git -prune -o -type d -print)
do do
echo " searching: ${d#./}" echo " searching: ${d#./}"
find $d -depth -empty -type d -delete -print find "$d" -depth -empty -type d -delete -print
done done
# Second pass: clean up object directories with WM_PROJECT_DIR that don't # Second pass: clean up object directories with WM_PROJECT_DIR that don't
# have respective source code folders, along with the respective binaries # have respective source code folders, along with the respective binaries
if [ "$(expandPath $PWD)" = "$(expandPath $WM_PROJECT_DIR)" ]
then
objectsDir=$(findObjectDir $PWD 2>/dev/null) || exit 1 # Fatal
if "$scriptsDir"/wmake-check-dir "$WM_PROJECT_DIR" && \
objectsDir=$(findObjectDir . 2>/dev/null)
then
if [ -d "$objectsDir" ] if [ -d "$objectsDir" ]
then then
echo " Removing redundant object directories in $objectsDir" echo " Removing redundant object directories in $objectsDir"

View File

@ -29,8 +29,7 @@
# wmake # wmake
# #
# Description # Description
# General, wrapped make system for multi-platform development with # General, wrapped make system for multi-platform development.
# support for local and network parallel compilation.
# #
# Intermediate object and dependency files retain the tree structure # Intermediate object and dependency files retain the tree structure
# of the original source files, with its location depending on the # of the original source files, with its location depending on the
@ -55,24 +54,27 @@
# #
# See also # See also
# wmakeLnInclude, wmakeLnIncludeAll, wmakeCollect, wdep, wrmdep, wrmo, # wmakeLnInclude, wmakeLnIncludeAll, wmakeCollect, wdep, wrmdep, wrmo,
# wclean, wcleanPlatform, wcleanLnIncludeAll # wclean, wcleanLnIncludeAll
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
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_HEAD 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:
-s | -silent Silent mode (does not echo commands) -s | -silent Silent mode (do not echo commands)
-a | -all wmake all sub-directories, running Allwmake if present -a | -all wmake all sub-directories, running Allwmake if present
-q | -queue wmakeCollect sub-directories, running Allwmake if present -q | -queue wmakeCollect sub-directories, running Allwmake if present
-k | -keep-going Keep going even when errors occur (-non-stop) -k | -keep-going Keep going even when errors occur (-non-stop)
-j | -jN | -j N Compile using all or specified N cores/hyperthreads -j | -jN | -j N Compile using all or specified N cores/hyperthreads
-update Update lnInclude dirs, dep files, remove deprecated files/dirs -update Update lnInclude, dep files, remove deprecated files/dirs
HELP_HEAD HELP_HEAD
if [ -n "$1" ] if [ -n "$1" ]
@ -95,20 +97,36 @@ cat<<HELP_FULL
HELP_FULL HELP_FULL
fi fi
cat<<HELP_TAIL_COMMON cat<<TAIL_OPTIONS
-pwd Print root directory containing a Make/ directory -pwd Print root directory containing a Make/ directory
-version | --version Print version (same as -show-api) -version | --version Print version (same as -show-api)
-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
A general, easy-to-use make system for multi-platform development subcommands (wmake subcommand -help for more information):
with support for local and network parallel compilation. TAIL_OPTIONS
if [ -n "$1" ]
then
cat<<HELP_SUBCOMMANDS
-build-info Query/manage status of {api,branch,build} information
-check-dir Check directory equality
HELP_SUBCOMMANDS
else
cat<<HELP_SUBCOMMANDS
-build-info -check-dir
HELP_SUBCOMMANDS
fi
cat<<HELP_TAIL_COMMON
General, wrapped make system for multi-platform development.
HELP_TAIL_COMMON HELP_TAIL_COMMON
if [ -n "$1" ] if [ -n "$1" ]
then then
cat<<HELP_TAIL_FULL cat<<HELP_TAIL_FULL
Makefile targets: platforms/linux64GccDPInt32Opt/.../fvMesh.o (for example) Makefile targets: platforms/linux64GccDPInt32Opt/.../fvMesh.o (for example)
Special targets: Special targets:
all | queue Same as -all | -queue options all | queue Same as -all | -queue options
@ -116,8 +134,8 @@ Special targets:
lib Compile statically linked archive lib (.a) lib Compile statically linked archive lib (.a)
libo Compile statically linked lib (.o) libo Compile statically linked lib (.o)
libso Compile dynamically linked lib (.so) libso Compile dynamically linked lib (.so)
dep Compile lnInclude and dependencies only dep Create lnInclude and dependencies only
updatedep Compile dependencies only (in case of broken dependencies) updatedep Create dependencies only (in case of broken dependencies)
objects Compile but not link objects Compile but not link
Environment Environment
@ -126,6 +144,7 @@ Environment
HELP_TAIL_FULL HELP_TAIL_FULL
else else
cat<<HELP_TAIL_BRIEF cat<<HELP_TAIL_BRIEF
Some special targets (see -help-full for details): Some special targets (see -help-full for details):
all | queue Same as -all | -queue options all | queue Same as -all | -queue options
exe Executables exe Executables
@ -169,7 +188,12 @@ allCores()
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Default to compiling the local target only # Default to compiling the local target only
unset all update optDebug optShow optPrintRootDir unset optAll optUpdate optDebug optQuiet optShow optPwd
# Consistency with inherited values
if [ "$WM_QUIET" = true ]
then optQuiet=true
fi
while [ "$#" -gt 0 ] while [ "$#" -gt 0 ]
do do
@ -180,7 +204,23 @@ do
-h | -help*) # Short help -h | -help*) # Short help
printHelp printHelp
;; ;;
# Forward to scripts/wmake-build-info
-build-info) shift
exec "$scriptsDir/wmake-build-info" "$@"
exit $?
;;
# Forward to scripts/wmake-check-dir
# Out of order options: (-quiet)
-check-dir) shift
exec "$scriptsDir/wmake-check-dir" \
${optQuiet:+-silent} "$@"
exit $?
;;
-s | -silent) -s | -silent)
optQuiet=true
export WM_QUIET=true export WM_QUIET=true
;; ;;
-debug) -debug)
@ -197,10 +237,10 @@ do
optShow=true optShow=true
;; ;;
-a | -all | all) -a | -all | all)
all=all optAll=all
;; ;;
-q | -queue | queue) -q | -queue | queue)
all=queue optAll=queue
;; ;;
# Parallel compilation on all cores (or specified number of cores) # Parallel compilation on all cores (or specified number of cores)
-j) -j)
@ -231,7 +271,7 @@ do
;; ;;
# Print root directory containing a Make/ directory and exit # Print root directory containing a Make/ directory and exit
-pwd) -pwd)
optPrintRootDir=true optPwd=true
;; ;;
# Meant to be used following a pull, this will: # Meant to be used following a pull, this will:
# - remove dep files that depend on deleted files; # - remove dep files that depend on deleted files;
@ -240,8 +280,8 @@ do
# - remove empty directories, along with deprecated object directories # - remove empty directories, along with deprecated object directories
# and respective binaries. # and respective binaries.
-update) -update)
update=true optUpdate=true
: "${all:=all}" # implies 'all', unless previous set to 'queue' etc. : "${optAll:=all}" # implies 'all', unless previously set
;; ;;
-version | --version) -version | --version)
$make -f $WM_DIR/makefiles/info api $make -f $WM_DIR/makefiles/info api
@ -311,7 +351,7 @@ MakeDir=Make
unset dir unset dir
if [ -n "$optPrintRootDir" ] if [ -n "$optPwd" ]
then then
if [ $# -ge 1 ] if [ $# -ge 1 ]
then then
@ -322,10 +362,7 @@ then
then then
dir="${1%/*}" dir="${1%/*}"
: "${dir:=.}" : "${dir:=.}"
if [ "$dir" = "$1" ] [ "$dir" != "$1" ] || dir="."
then
dir="."
fi
else else
echo "$Script error: not a file or directory" 1>&2 echo "$Script error: not a file or directory" 1>&2
exit 1 exit 1
@ -395,7 +432,7 @@ unset dir
# Recurse the source tree to update all # Recurse the source tree to update all
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
if [ "$update" = true ] if [ "$optUpdate" = true ]
then then
wrmdep -update wrmdep -update
wrmdep -old wrmdep -old
@ -405,13 +442,13 @@ then
fi fi
unset exitCode
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Recurse the source tree to compile "all" targets # Recurse the source tree to compile "all" targets
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
unset exitCode if [ "$optAll" = all ]
if [ "$all" = all ]
then then
if [ -e Allwmake.override ] if [ -e Allwmake.override ]
then then
@ -467,12 +504,11 @@ fi
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Recurse the source tree to compile "all" targets using wmakeCollect # Recurse source tree to compile "all" targets using wmakeCollect
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
if [ "$optAll" = queue ]
if [ "$all" = queue ]
then then
[ "$update" = true ] || wmakeLnIncludeAll $parOpt [ "$optUpdate" = true ] || wmakeLnIncludeAll $parOpt
( (
export WM_COLLECT_DIR="$WM_PROJECT_DIR/build/${WM_OPTIONS}/${PWD////_}" export WM_COLLECT_DIR="$WM_PROJECT_DIR/build/${WM_OPTIONS}/${PWD////_}"

View File

@ -1,114 +0,0 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# Copyright (C) 2011-2015 OpenFOAM Foundation
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
#
# Script
# wmakeCheckPwd
#
# Usage
# wmakeCheckPwd <dir>
#
# Description
# Check that the current working directory is the directory <dir>.
# Exit status 0 when the directories are identical
#
#-------------------------------------------------------------------------------
Script=${0##*/}
unset optQuiet
exec 1>&2 # No stdout, stderr only
usage() {
[ "$optQuiet" = true ] && exit 1
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
Usage: $Script [OPTION] dirName
options:
-q | -quiet suppress all normal output
Check that the current working directory is the directory <dir>
Exit status 0 when the directories are identical
Exit status 1 on error
USAGE
exit 1
}
error()
{
if [ "$optQuiet" != true ]
then
echo "$Script error: $1"
shift
while [ "$#" -ge 1 ]; do echo " $1"; shift; done
fi
exit 1
}
#------------------------------------------------------------------------------
# Parse arguments and options
#------------------------------------------------------------------------------
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help*)
usage
;;
-q | -quiet)
optQuiet=true
shift
;;
-*)
usage "Unknown option: '$1'"
;;
*)
break
;;
esac
done
[ "$#" -eq 1 ] || usage "Incorrect number of arguments"
dirName="$1"
# Simple lexical check against PWD
[ "$PWD" = "$dirName" ] && exit 0
# Check existence of <dir>
[ -d "$dirName" ] || error "Directory does not exist '$dirName'"
# Compare absolute paths, without symlinks
[ "$(cd $dirName 2>/dev/null && pwd -P)" = "$(pwd -P)" ] || \
error "Current directory is not '$dirName'"
exit 0 # clean exit
#------------------------------------------------------------------------------

1
wmake/wmakeCheckPwd Symbolic link
View File

@ -0,0 +1 @@
scripts/wmake-check-dir

View File

@ -7,7 +7,7 @@
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation # Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2018 OpenCFD Ltd. # Copyright (C) 2018-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# License # License
# This file is part of OpenFOAM. # This file is part of OpenFOAM.
@ -102,7 +102,7 @@ done
# project directory: {applications,src} directories # project directory: {applications,src} directories
if [ "$#" -eq 0 ] if [ "$#" -eq 0 ]
then then
if wmakeCheckPwd "$WM_PROJECT_DIR" 2>/dev/null if wmake -check-dir "$WM_PROJECT_DIR" 2>/dev/null
then then
set -- applications src set -- applications src
else else