Commit 79fc6157 authored by Mark Olesen's avatar Mark Olesen
Browse files

STYLE: reorganize some legacy and less frequently used components

- older emacs tools into legacy
- old process tools

* Less frequently used scripts into bin/tools/

  - findEmptyMake
  - foamAllHC
  - foamUpdateCaseFileHeader

* Infrastructure file (only used by foamNewApp)

  - wmake/wmakeFilesAndOptions -> wmake/scripts/wmakeFilesAndOptions

* Merge wmakeRoot convenience as 'wmake -pwd'
* Remove obsolete wmakePrintBuild (superseded by wmakeBuildInfo)
* Remove unused mergeHistory file
parent cfa8accf
......@@ -110,7 +110,7 @@ else
if [ "$subType" = App -a ! -d Make ]
then
"${WM_DIR:-$WM_PROJECT_DIR/wmake}/wmakeFilesAndOptions"
"${WM_DIR:-$WM_PROJECT_DIR/wmake}/scripts/wmakeFilesAndOptions"
fi
fi
......
Date SHA1 Commit message
2015-12-02 9a536b0 fvOptions: Reorganized and updated to simplify use in sub-models and maintenance
......@@ -69,8 +69,8 @@ then
fi
mkdir Make
[ -e Make/files ] || "${0%/*}"/scripts/makeFiles
[ -e Make/options ] || "${0%/*}"/scripts/makeOptions
[ -e Make/files ] || "${0%/*}/makeFiles"
[ -e Make/options ] || "${0%/*}/makeOptions"
exit 0 # clean exit
......
......@@ -72,6 +72,7 @@ options:
-j Compile using all local cores/hyperthreads
-jN or -j N Compile using N cores/hyperthreads
-no-scheduler Disable scheduled parallel compilation
-pwd Print root directory containing a Make/ directory and exit
-update Update lnInclude directories, dep files, remove deprecated
files and directories
-h | -help Print the usage
......@@ -118,7 +119,7 @@ allCores()
#------------------------------------------------------------------------------
# Default to compiling the local target only
unset all update
unset all update optPrintRootDir
while [ "$#" -gt 0 ]
do
......@@ -159,6 +160,10 @@ do
-no-scheduler)
unset WM_SCHEDULER
;;
# Print root directory containing a Make/ directory and exit
-pwd)
optPrintRootDir=true
;;
# Meant to be used following a pull, this will:
# - remove dep files that depend on deleted files;
# - remove stale dep files;
......@@ -224,42 +229,79 @@ fi
unset targetType
MakeDir=Make
if [ $# -ge 1 ]
unset dir
if [ -n "$optPrintRootDir" ]
then
unset dir
if [ -d "$1" ]
if [ $# -ge 1 ]
then
dir="${1%/}"
elif [ -f "$1" ]
then
dir="${1%/*}"
: "${dir:=.}"
else
targetType="$1"
fi
# Specified directory name:
[ $# -ge 2 ] && dir="${2%/}"
# Specified alternative name for the Make sub-directory:
[ $# -ge 3 ] && MakeDir="${3%/}"
if [ -d "$1" ]
then
dir="${1%/}"
elif [ -f "$1" ]
then
dir="${1%/*}"
: "${dir:=.}"
else
echo "$Script error: not a file or directory" 1>&2
exit 1
fi
if [ -n "$dir" ]
then
cd $dir 2>/dev/null || {
cd "$dir" 2>/dev/null || {
echo "$Script error: could not change to directory '$dir'" 1>&2
exit 1
}
elif [ -f "$MakeDir/files" ]
fi
# Locate target with Make/ directory
if dir="$(findTarget .)"
then
dir="(${PWD##*/})" # Implicit directory information
(cd "$dir" && pwd -L)
exit 0
else
exit 2
fi
# Print command
echo "$Script $targetType${targetType:+ }$dir"
unset dir
else
if [ $# -ge 1 ]
then
if [ -d "$1" ]
then
dir="${1%/}"
elif [ -f "$1" ]
then
dir="${1%/*}"
: "${dir:=.}"
else
targetType="$1"
fi
# Specified directory name:
[ $# -ge 2 ] && dir="${2%/}"
# Specified alternative name for the Make sub-directory:
[ $# -ge 3 ] && MakeDir="${3%/}"
if [ -n "$dir" ]
then
cd $dir 2>/dev/null || {
echo "$Script error: could not change to directory '$dir'" 1>&2
exit 1
}
elif [ -f "$MakeDir/files" ]
then
dir="(${PWD##*/})" # Implicit directory information
fi
# Print command
echo "$Script $targetType${targetType:+ }$dir"
unset dir
fi
fi
unset dir
#------------------------------------------------------------------------------
# Recurse the source tree to update all
......
......@@ -26,7 +26,7 @@
# wmakeLnInclude
#
# Usage
# wmakeLnInclude [OPTION] [-root | <dir>]
# wmakeLnInclude [OPTION] [-pwd | <dir>]
#
# Description
# Link all the source files in the <dir> directory into <dir>/lnInclude
......@@ -46,12 +46,12 @@ usage() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
Usage: $Script [OPTION] [-root | dir]
Usage: $Script [OPTION] [-pwd | dir]
options:
-u | -update Update
-s | -silent Use 'silent' mode (do not echo command)
-root Locate root directory containing a Make/ directory.
-pwd Locate root directory containing a Make/ directory.
-h | -help Print the usage
Link all the source files in the <dir> into <dir>/lnInclude
......@@ -72,7 +72,7 @@ USAGE
# Option for 'ln'
optLink="-s"
unset update optQuiet optRoot
unset update optQuiet optFindRootDir
while [ "$#" -gt 0 ]
do
......@@ -87,8 +87,8 @@ do
-s | -silent)
optQuiet=true
;;
-root)
optRoot=true
-pwd)
optFindRootDir=true
;;
-*)
usage "unknown option: '$1'"
......@@ -100,7 +100,7 @@ do
shift
done
[ "$optRoot" = true ] || [ "$#" -eq 1 ] || \
[ "$optFindRootDir" = true ] || [ "$#" -eq 1 ] || \
usage "Error: incorrect number of arguments"
#------------------------------------------------------------------------------
......@@ -109,7 +109,7 @@ unset dir
baseDir="$1"
# With -root, go on discovery
if [ "$optRoot" = true ]
if [ "$optFindRootDir" = true ]
then
if [ -n "$baseDir" ]
then
......
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
#-------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
#
# Script
# wmakePrintBuild
#
# Description
# Print the version used when building the project
#
#------------------------------------------------------------------------------
# Environment defaults
: "${WM_DIR:-$WM_PROJECT_DIR/wmake}"
#--------
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
Usage: ${0##*/} [OPTION]
options:
-check check the git head commit vs. \$WM_PROJECT_DIR/.build
(exit code 0 for no changes)
-major report \$WM_PROJECT_VERSION only and exit
-update update \$WM_PROJECT_DIR/.build from the git information
-pkg TAG specify packager/release tag ('none' marks an empty packager)
-short report short version information (ie, without pkg tag)
-version VER specify an alternative version
-api report wmake value of OPENFOAM/OPENFOAM_API/OPENFOAM_PLUS
-help
Print the version used when building the project, in this order of precedence:
* the git head commit
* \$WM_PROJECT_DIR/.build
* \$WM_PROJECT_VERSION
USAGE
exit 1
}
# Report error and exit
die()
{
exec 1>&2
echo
echo "Error encountered:"
while [ "$#" -ge 1 ]; do echo " $1"; shift; done
echo
echo "See '${0##*/} -help' for usage"
echo
exit 1
}
#------------------------------------------------------------------------------
cat << WARN_OBSOLETE 1>&2
###############################################################################
## The wmakePrintBuild utility is OBSOLETE (Dec-2018). ##
## The wmakeBuildInfo utility is to be used instead. ##
###############################################################################
WARN_OBSOLETE
#------------------------------------------------------------------------------
# Parse arguments and options
#------------------------------------------------------------------------------
unset checkOnly update package version optApi optShort
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help*)
usage
;;
-c | -check)
checkOnly=true
;;
-major)
echo ${WM_PROJECT_VERSION:-unknown}
exit 0
;;
-u | -update)
update=true
;;
-pkg | -package)
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
# Mark empty as 'none', disallow '!' in string
package=$(echo "${2:-none}" | sed -e 's/!//g')
shift
;;
-short)
optShort=true
;;
-v | -version)
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
version="$2"
shift
;;
-api | -plus)
optApi=true
break
;;
*)
die "unknown option/argument: '$1'"
;;
esac
shift
done
#------------------------------------------------------------------------------
# Persistent build tag
build="$WM_PROJECT_DIR/.build"
#------------------------------------------------------------------------------
# Retrieve old values from the $WM_PROJECT_DIR/.build cache, stored as
# version [packager]
#------------------------------------------------------------------------------
unset oldPackage oldVersion
getOldValues()
{
set -- $(tail -1 $build 2>/dev/null)
oldVersion="$1"
[ "$#" -gt 0 ] && shift
oldPackage="$@"
[ "${oldPackage:-none}" = none ] && unset oldPackage
}
#------------------------------------------------------------------------------
# printTag - output the build tag, reuses the old -package tag if needed
#------------------------------------------------------------------------------
printTag()
{
if [ "${package:-${oldPackage:-none}}" = none ]
then
echo "$version"
else
echo "$version ${package:-$oldPackage}"
fi
}
#------------------------------------------------------------------------------
# Get the version
#------------------------------------------------------------------------------
if [ -n "$optApi" ]
then
# Extract API version from $WM_DIR/rules/General/general
# Any of OPENFOAM=<digits>, OPENFOAM_API=<digits>, OPENFOAM_COM=<digits>
# OPENFOAM_PLUS=<digits>
version=$(
sed -ne 's@^.*OPENFOAM\(_API\|_COM\|_PLUS\)*=\([0-9][0-9]*\).*@\2@p' \
$WM_DIR/rules/General/general 2>/dev/null
)
if [ -n "$version" ]
then
echo "$version"
exit 0
else
echo "no wmake definition for OPENFOAM API" 1>&2
exit 1
fi
elif [ -n "$version" ]
then
# Specified a version - no error possible
rc=0
else
# Abbrev commit hash + data
# Date format (YYMMDD) for authoring of the commit
version="$(git --git-dir=$WM_PROJECT_DIR/.git log -1 --date='format:%y%m%d' --format='%h-%ad' 2>/dev/null)"
test -n "$version"
rc=$?
fi
# Retrieve old values (oldPackage oldVersion)
getOldValues
if [ -n "$optShort" ]
then
unset package oldPackage
fi
#------------------------------------------------------------------------------
# Update persistent build tag if possible
#------------------------------------------------------------------------------
if [ $rc -eq 0 -a -n "$update" ]
then
if [ "$version:$package" != "$oldVersion:$oldPackage" ]
then
if [ -w "$build" -o \( -w "$WM_PROJECT_DIR" -a ! -e "$build" \) ]
then
printTag >| "$build" 2>/dev/null
fi
fi
fi
#------------------------------------------------------------------------------
# Check git vs. persistent build tag
#------------------------------------------------------------------------------
if [ -n "$checkOnly" ]
then
if [ $rc -eq 0 ]
then
test "$version:${package:-$oldPackage}" = "$oldVersion:$oldPackage"
rc=$?
if [ $rc -eq 0 ]
then
echo "same version as previous build" 1>&2
else
echo "version changed from previous build" 1>&2
fi
exit $rc
else
echo "no git description found" 1>&2
exit 0
fi
fi
#------------------------------------------------------------------------------
# Cannot get git information or -version version
#------------------------------------------------------------------------------
if [ $rc -ne 0 ]
then
if [ -n "$oldVersion" ]
then
# Use previous version info
version="$oldVersion"
else
# Fallback to WM_PROJECT_VERSION alone
version="${WM_PROJECT_VERSION:-unknown}"
fi
fi
#------------------------------------------------------------------------------
# Output the tag
#------------------------------------------------------------------------------
printTag
#------------------------------------------------------------------------------
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# 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
# wmakeRoot
#
# Description
# Locate the root directory that has a Make/ directory.
#
# See Also
# wmake
#
#------------------------------------------------------------------------------
Script="${0##*/}" # Use 'Script' for error messages in wmakeFunctions
. "${0%/*}/scripts/wmakeFunctions" # Source wmake functions
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
Usage: $Script [OPTION] [dir]
options:
-h | -help Print the usage
Locate the root directory that has a Make/ directory.
USAGE
exit 1
}
#------------------------------------------------------------------------------
# Parse arguments and options
#------------------------------------------------------------------------------
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help*)
usage
;;
--)
shift
break
;;
-*)
usage "unknown option: '$1'"
;;
*)
break
;;
esac
shift
done
#------------------------------------------------------------------------------
unset dir
if [ $# -ge 1 ]
then
if [ -d "$1" ]
then
dir="${1%/}"
elif [ -f "$1" ]
then
dir="${1%/*}"
: "${dir:=.}"
else
echo "$Script error: not a file or directory" 1>&2
exit 1
fi
cd "$dir" 2>/dev/null || {
echo "$Script error: could not change to directory '$dir'" 1>&2
exit 1
}
fi
# Locate target with Make/ directory
if dir="$(findTarget .)"
then
(cd "$dir" && pwd -L)
else
exit 2
fi
#------------------------------------------------------------------------------
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment