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
# Run from OPENFOAM top-level directory only
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 " Check your OpenFOAM environment and installation"
exit 1

View File

@ -1,59 +1,60 @@
# META-INFO
Meta-information is 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.
Meta-information is generally for OpenFOAM internal use only.
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
This file and its contents are to be tracked by git.
- File content (api) generated by wmakeBuildInfo from OPENFOAM define
in `wmake/rules/General/general`
- File content (api) generated by `wmake -build-info` from the
`OPENFOAM` define in `wmake/rules/General/general`
- File content (patch) is manually generated content.
## build-info
This file is *never* to be tracked by git, but may be present in shipped
source archives.
This file is ***never*** to be tracked by git, but may be present in
shipped source archives.
- File content (branch, build) generated by wmakeBuildInfo from git
information and cached from previous wmake (api)
- File content (branch, build) generated by `wmake -build-info` from
git information and cached from previous wmake (api)
## Content types
### api
Format: `date +%y%m`
- 4-digit year-month (YYMM) integer corresponding to the major
release or in unusual cases an intermediate release.
- Format is year-month, as per `date +%y%m`.
Eg, `1712` for the Dec-2017 release.
Example, `1712` for the Dec-2017 release.
### patch
Format: `date +%y%m%d`
- 6-digit year-month-day (YYMMDD) integer corresponding to a patch-level
for the given **released** API.
- Format is year-month-day, as per `date +%y%m%d`.
- The first release can have a patch value of `0` (unpatched = just
released) or a patch value corresponding to the release date.
- The first release can have a patch value of `0` or `1` which
indicates that it is unpatched or just released. Alternatively
it can have a patch value corresponding to the release date.
The patch value is only meaningful together with the api value.
However, for *development* branches, the patch level should not be
ascribed much meaning -- it can be `0` or have a value corresponding
to the last merge with a *maintenance* (*eg*, `master`) branch.
ascribed too much meaning, but will often correspond to the last
merge with a *maintenance* (*eg*, `master`) branch.
## Flow of information
@ -70,9 +71,9 @@ distributions to have a record of the same information.
| 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
`wmakeBuildInfo -update` preforms the synchronitzation.
`wmake -build-info -update` performs the synchronization.
## Notes
@ -82,4 +83,4 @@ contains more permanent information, whereas the `build-info` is more
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
be helpful when the repository contains local changes. If you simply
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:
```
$ wmakeBuildInfo
$ wmake -build-info
make
api = 1812
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/)
- [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
# Run from OPENFOAM applications/ directory only
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 " Check your OpenFOAM environment and installation"
exit 1

View File

@ -43,9 +43,11 @@
# Note
# This script must exist in the project 'bin' directory
#
# The '-show-api' and '-show-patch' options implement partial logic
# from wmake/wmakeBuildInfo.
# Make sure that any changes there are also reflected here.
# The '-show-api' and '-show-patch' options extract values from
# the "META-INFO/api-info" file
#
# SeeAlso
# META-INFO/README.md for other routines that also use META-INFO.
#
#-------------------------------------------------------------------------------
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"
# 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/=/-/')"
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,
# 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!
projectDir="$(\cd "$(dirname "${0%/*}")" && \pwd -L)"

View File

@ -1,7 +1,7 @@
#!/bin/sh
# Run from OPENFOAM src/ directory only
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 " Check your OpenFOAM environment and installation"
exit 1

View File

@ -6,7 +6,7 @@ touch=true
case "$1" in
-check)
if wmakeBuildInfo -check
if wmake -build-info -check
then
unset touch
fi

View File

@ -4,7 +4,7 @@ SUFFIXES += .Cver
# Update strings in C++ file and in META-INFO files
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 $@
#------------------------------------------------------------------------------

View File

@ -6,11 +6,10 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2017-2018 OpenCFD Ltd.
# Copyright (C) 2017-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# wcleanBuild, wcleanPlatform
@ -88,8 +87,8 @@ done
#------------------------------------------------------------------------------
# Run from OPENFOAM or THIRDPARTY top-level directory only
wmakeCheckPwd -q "$WM_PROJECT_DIR" 2>/dev/null || \
wmakeCheckPwd -q "$WM_THIRD_PARTY_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 || \
{
cat<<ERROR
${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.
#
# Script
# wmakeBuildInfo
# wmake/scripts/wmake-build-info
# Backend for "wmake -build-info"
#
# Description
# Print the api/version and other build information for the project.
@ -22,10 +23,19 @@
# - WM_PROJECT_VERSION
# - 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
# Partial logic is also implemented in the bin/foamEtcFile
# -show-api and -show-patch options.
# Make sure that changes here are also reflected there.
# When a 'debian/' directory exists, the '.git/' directory is most
# likely 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.
#
# SeeAlso
# META-INFO/README.md for other routines that also use META-INFO.
#
#------------------------------------------------------------------------------
# Locations
@ -33,11 +43,9 @@ rulesFile="${WM_DIR:-$WM_PROJECT_DIR/wmake}/rules/General/general"
META_INFO="$WM_PROJECT_DIR/META-INFO"
FOAM_GIT_DIR="$WM_PROJECT_DIR/.git"
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
printHelp() {
cat<<USAGE
Usage: ${0##*/} [OPTION]
${0##*/} [-update] -filter FILE
options:
@ -56,7 +64,7 @@ options:
-show-patch Print patch value from meta-info and exit
-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'.
USAGE
@ -85,7 +93,7 @@ while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help*)
usage
printHelp
;;
-cmp | -check)
optCheck=true
@ -124,7 +132,7 @@ do
unset FOAM_GIT_DIR
;;
*)
die "unknown option/argument: '$1'"
die "Unknown option/argument: '$1'"
;;
esac
shift
@ -137,6 +145,11 @@ done
[ -d "$META_INFO" ] || \
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" ]
then
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
echo "Already removed project ${META_INFO##*/}/build-info" 1>&2
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)
do
echo " searching: ${d#./}"
find $d -depth -empty -type d -delete -print
find "$d" -depth -empty -type d -delete -print
done
# Second pass: clean up object directories with WM_PROJECT_DIR that don't
# 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" ]
then
echo " Removing redundant object directories in $objectsDir"

View File

@ -29,8 +29,7 @@
# wmake
#
# Description
# General, wrapped make system for multi-platform development with
# support for local and network parallel compilation.
# General, wrapped make system for multi-platform development.
#
# Intermediate object and dependency files retain the tree structure
# of the original source files, with its location depending on the
@ -55,24 +54,27 @@
#
# See also
# wmakeLnInclude, wmakeLnIncludeAll, wmakeCollect, wdep, wrmdep, wrmo,
# wclean, wcleanPlatform, wcleanLnIncludeAll
# wclean, wcleanLnIncludeAll
#
#------------------------------------------------------------------------------
Script="${0##*/}" # Use 'Script' for error messages in wmakeFunctions
. "${0%/*}"/scripts/wmakeFunctions # Source wmake functions
Script="${0##*/}" # Need 'Script' for wmakeFunctions messages
scriptsDir="${0%/*}"/scripts # wmake/scripts directory
. "$scriptsDir"/wmakeFunctions # Source wmake functions
printHelp() {
cat<<HELP_HEAD
Usage: $Script [OPTION] [dir]
$Script [OPTION] target [dir [MakeDir]]
$Script -subcommand ...
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
-q | -queue wmakeCollect sub-directories, running Allwmake if present
-k | -keep-going Keep going even when errors occur (-non-stop)
-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
if [ -n "$1" ]
@ -95,20 +97,36 @@ cat<<HELP_FULL
HELP_FULL
fi
cat<<HELP_TAIL_COMMON
cat<<TAIL_OPTIONS
-pwd Print root directory containing a Make/ directory
-version | --version Print version (same as -show-api)
-h | -help Display short help and exit
-help-full Display full help and exit
A general, easy-to-use make system for multi-platform development
with support for local and network parallel compilation.
subcommands (wmake subcommand -help for more information):
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
if [ -n "$1" ]
then
cat<<HELP_TAIL_FULL
Makefile targets: platforms/linux64GccDPInt32Opt/.../fvMesh.o (for example)
Special targets:
all | queue Same as -all | -queue options
@ -116,8 +134,8 @@ Special targets:
lib Compile statically linked archive lib (.a)
libo Compile statically linked lib (.o)
libso Compile dynamically linked lib (.so)
dep Compile lnInclude and dependencies only
updatedep Compile dependencies only (in case of broken dependencies)
dep Create lnInclude and dependencies only
updatedep Create dependencies only (in case of broken dependencies)
objects Compile but not link
Environment
@ -126,6 +144,7 @@ Environment
HELP_TAIL_FULL
else
cat<<HELP_TAIL_BRIEF
Some special targets (see -help-full for details):
all | queue Same as -all | -queue options
exe Executables
@ -169,7 +188,12 @@ allCores()
#------------------------------------------------------------------------------
# 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 ]
do
@ -180,7 +204,23 @@ do
-h | -help*) # Short help
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)
optQuiet=true
export WM_QUIET=true
;;
-debug)
@ -197,10 +237,10 @@ do
optShow=true
;;
-a | -all | all)
all=all
optAll=all
;;
-q | -queue | queue)
all=queue
optAll=queue
;;
# Parallel compilation on all cores (or specified number of cores)
-j)
@ -231,7 +271,7 @@ do
;;
# Print root directory containing a Make/ directory and exit
-pwd)
optPrintRootDir=true
optPwd=true
;;
# Meant to be used following a pull, this will:
# - remove dep files that depend on deleted files;
@ -240,8 +280,8 @@ do
# - remove empty directories, along with deprecated object directories
# and respective binaries.
-update)
update=true
: "${all:=all}" # implies 'all', unless previous set to 'queue' etc.
optUpdate=true
: "${optAll:=all}" # implies 'all', unless previously set
;;
-version | --version)
$make -f $WM_DIR/makefiles/info api
@ -311,7 +351,7 @@ MakeDir=Make
unset dir
if [ -n "$optPrintRootDir" ]
if [ -n "$optPwd" ]
then
if [ $# -ge 1 ]
then
@ -322,10 +362,7 @@ then
then
dir="${1%/*}"
: "${dir:=.}"
if [ "$dir" = "$1" ]
then
dir="."
fi
[ "$dir" != "$1" ] || dir="."
else
echo "$Script error: not a file or directory" 1>&2
exit 1
@ -395,7 +432,7 @@ unset dir
# Recurse the source tree to update all
#------------------------------------------------------------------------------
if [ "$update" = true ]
if [ "$optUpdate" = true ]
then
wrmdep -update
wrmdep -old
@ -405,13 +442,13 @@ then
fi
unset exitCode
#------------------------------------------------------------------------------
# Recurse the source tree to compile "all" targets
#------------------------------------------------------------------------------
unset exitCode
if [ "$all" = all ]
if [ "$optAll" = all ]
then
if [ -e Allwmake.override ]
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 [ "$all" = queue ]
if [ "$optAll" = queue ]
then
[ "$update" = true ] || wmakeLnIncludeAll $parOpt
[ "$optUpdate" = true ] || wmakeLnIncludeAll $parOpt
(
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 |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2018 OpenCFD Ltd.
# Copyright (C) 2018-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
@ -102,7 +102,7 @@ done
# project directory: {applications,src} directories
if [ "$#" -eq 0 ]
then
if wmakeCheckPwd "$WM_PROJECT_DIR" 2>/dev/null
if wmake -check-dir "$WM_PROJECT_DIR" 2>/dev/null
then
set -- applications src
else