ENH: improvements for handling update of build information

- When building OpenFOAM for different platform combinations
  (single/double, int32/int64) the build information that is compiled
  into the OpenFOAM lib can become out of sync.

  This is because the update trigger (wmakeBuildInfo -check) is
  independent of the targetted platform. The added file
  'src/OpenFOAM/Alltouch' provides a direct means of forcing a rebuild
  of the version information. Eg,

      src/OpenFOAM/Alltouch
      wmake src/OpenFOAM

  Also provide an additional 'wmakeBuildInfo -remove' to forcibly
  remove META-INFO/build-info, if that is desired.
This commit is contained in:
Mark Olesen 2019-07-30 09:54:02 +02:00 committed by Andrew Heather
parent d4454ab6b4
commit 59b867b7af
5 changed files with 104 additions and 59 deletions

View File

@ -30,19 +30,19 @@ Mingw*)
# 2nd pass: link Pstream.dll against libOpenFOAM.dll # 2nd pass: link Pstream.dll against libOpenFOAM.dll
Pstream/Allwmake $targetType $* Pstream/Allwmake $targetType $*
# Relink libOpenFOAM.dll against libPstream.dll # Force relink libOpenFOAM.dll against libPstream.dll
wrmo OpenFOAM/global/global.o 2>/dev/null OpenFOAM/Alltouch 2>/dev/null
wmake $targetType OpenFOAM
;; ;;
*) *)
Pstream/Allwmake $targetType $* Pstream/Allwmake $targetType $*
# Trigger update of version info (as required) # Update version info (as required)
wmakeBuildInfo -check || wrmo OpenFOAM/global/global.o 2>/dev/null OpenFOAM/Alltouch -check 2>/dev/null
wmake $targetType OpenFOAM
;; ;;
esac esac
wmake $targetType OpenFOAM
wmake $targetType fileFormats wmake $targetType fileFormats
wmake $targetType surfMesh wmake $targetType surfMesh
wmake $targetType meshTools wmake $targetType meshTools

24
src/OpenFOAM/Alltouch Executable file
View File

@ -0,0 +1,24 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
#------------------------------------------------------------------------------
touch=true
case "$1" in
-check)
if wmakeBuildInfo -check
then
unset touch
fi
;;
esac
if [ -n "$touch" ]
then
# Triggers update of version info
wrmo global/global.Cver 2>/dev/null
fi
exit 0 # clean exit
#------------------------------------------------------------------------------

View File

@ -55,9 +55,9 @@ options:
-diff Display differences between make and meta information -diff Display differences between make and meta information
(exit code 0 for no changes) (exit code 0 for no changes)
-dry-run In combination with -update -dry-run In combination with -update
-filter FILE Filter @API@, @BUILD@ tags in file with make information
-remove Remove meta-info build information and exit
-update Update meta-info from make information -update Update meta-info from make information
-filter FILE Filter/replace @API@, @BUILD@ tags in specified file
with corresponding make information
-query Report make-info and meta-info -query Report make-info and meta-info
-query-make Report make-info values (api, branch, build) -query-make Report make-info values (api, branch, build)
-query-meta Report meta-info values (api, branch, build) -query-meta Report meta-info values (api, branch, build)
@ -105,6 +105,10 @@ do
-dry-run) -dry-run)
optDryRun=true optDryRun=true
;; ;;
-remove)
optUpdate=remove
break # Stop now
;;
-update) -update)
optUpdate=true optUpdate=true
;; ;;
@ -132,10 +136,31 @@ do
shift shift
done done
# Check environment variables
[ -d "$WM_PROJECT_DIR" ] || \
die "Bad or unset environment variable: \$WM_PROJECT_DIR"
[ -d "$WM_PROJECT_DIR/META-INFO" ] || \
die "No META-INFO/ directory for project"
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
if [ "$optFilter" = true ] if [ "$optUpdate" = remove ]
then then
if [ -f "$metaInfoDir/build-info" ]
then
echo "Removing project META-INFO/build-info" 1>&2
rm -f "$metaInfoDir/build-info" 2>/dev/null
else
echo "Already removed project META-INFO/build-info" 1>&2
fi
exit 0
elif [ "$optFilter" = true ]
then
[ -f "$1" ] || { [ -f "$1" ] || {
echo "Error in ${0##*/}: file not found '$1'" 1>&2 echo "Error in ${0##*/}: file not found '$1'" 1>&2
exit 2 exit 2
@ -143,7 +168,9 @@ then
# Disable other methods that generate output to stdout # Disable other methods that generate output to stdout
unset optCheck optQuery unset optCheck optQuery
else else
[ "$#" -eq 0 ] || die "Unexpected option/arguments $@" [ "$#" -eq 0 ] || die "Unexpected option/arguments $@"
# Nothing specified? Default to -query-make # Nothing specified? Default to -query-make
@ -151,6 +178,7 @@ else
then then
optQuery="make" optQuery="make"
fi fi
fi fi

View File

@ -3,7 +3,7 @@
# ========= | # ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration | # \\ / O peration |
# \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. # \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# | Copyright (C) 2015-2016 OpenFOAM Foundation # | Copyright (C) 2015-2016 OpenFOAM Foundation
@ -65,9 +65,9 @@ Usage:
$Script [-a | -all | all] [file1 [..fileN]] $Script [-a | -all | all] [file1 [..fileN]]
Remove all .dep files or remove .dep files referring to <file> Remove all .dep files or remove .dep files referring to <file>.
With the -a/-all/all option the .dep files are removed for all With the 'all' option the .dep files are removed for all platforms
platforms rather than just the current platform ($WM_OPTIONS). rather than just the current platform ($WM_OPTIONS).
$Script [-o | -old] [dir1 [..dirN]] $Script [-o | -old] [dir1 [..dirN]]
@ -79,9 +79,9 @@ $Script [-o | -old] [dir1 [..dirN]]
$Script -update $Script -update
Search all the "src" and "application" directories of the project for Search "src" and "application" directories of the project for broken
broken symbolic links for source code files and then remove all .dep symbolic links for source code files and remove all .dep files related
files that relate to files that no longer exist. to files that no longer exist.
Must be executed in the project top-level directory: Must be executed in the project top-level directory:
$WM_PROJECT_DIR $WM_PROJECT_DIR
@ -98,27 +98,22 @@ USAGE
rmdepMode=files rmdepMode=files
# Default to processing only the current platform # Default to processing only the current platform
unset all unset platform
while [ "$#" -gt 0 ] while [ "$#" -gt 0 ]
do do
case "$1" in case "$1" in
# Print help
-h | -help*) -h | -help*)
usage usage
;; ;;
# All platforms -a | -all | all) # All platforms
-a | -all | all) platform=all
all=all
shift
;; ;;
-o | -old) -o | -old)
rmdepMode=oldFolders rmdepMode=oldFolders
shift
;; ;;
-update) -update)
rmdepMode=updateMode rmdepMode=updateMode
shift
;; ;;
-*) -*)
usage "unknown option: '$1'" usage "unknown option: '$1'"
@ -127,13 +122,14 @@ do
break break
;; ;;
esac esac
shift
done done
#------------------------------------------------------------------------------
# Check environment variables # Check environment variables
checkEnv checkEnv
#------------------------------------------------------------------------------
case "$rmdepMode" in case "$rmdepMode" in
files) files)
@ -143,22 +139,21 @@ files)
objectsDir=$(findObjectDir .) || exit 1 # Fatal objectsDir=$(findObjectDir .) || exit 1 # Fatal
# With the -a/-all option replace the current platform with a wildcard # With -a/-all option: replace the current platform with a wildcard
if [ "$all" = all ] if [ "$platform" = all ]
then then
objectsDir=$(echo $objectsDir | sed s%$WM_OPTIONS%*% ) objectsDir=$(echo "$objectsDir" | sed "s%$WM_OPTIONS%*%")
fi fi
if [ "$#" -eq 0 ] if [ "$#" -eq 0 ]
then then
echo "removing all .dep files ..." echo "Removing all .dep files ..." 1>&2
find $objectsDir -name '*.dep' -type f -delete -print find "$objectsDir" -name '*.dep' -type f -delete -print
else else
echo "removing .o files corresponding to" echo "Removing .dep files for: $*" 1>&2
echo " $@ ..."
for file for file
do do
find $objectsDir -name '*.dep' -type f \ find "$objectsDir" -name '*.dep' -type f \
-exec grep -q "$file" {} \; -delete -print -exec grep -q "$file" {} \; -delete -print
done done
fi fi
@ -168,29 +163,29 @@ oldFolders)
# Default is the current directory # Default is the current directory
[ "$#" -gt 0 ] || set -- . [ "$#" -gt 0 ] || set -- .
echo "Removing dep files that refer to source files that no longer exist..." echo "Removing dep files for non-existent source files ..." 1>&2
for checkDir for checkDir
do do
objectsDir=$(findObjectDir $checkDir) objectsDir=$(findObjectDir "$checkDir")
if [ -d "$objectsDir" ] if [ -d "$objectsDir" ]
then then
echo " searching: $objectsDir" echo " searching: $objectsDir" 1>&2
else else
echo " skipping non-dir: $objectsDir" echo " skipping non-dir: $objectsDir" 1>&2
continue continue
fi fi
find $objectsDir -name '*.dep' -type f -print | while read depFile find "$objectsDir" -name '*.dep' -type f -print | while read depFile
do do
sourceFile=$(depToSource $depFile) sourceFile=$(depToSource "$depFile")
# Check C++ or Flex source file exists # Check C++ or Flex source file exists
if [ ! -r "$sourceFile" ] if [ ! -r "$sourceFile" ]
then then
echo " rm $depFile" echo " rm $depFile" 1>&2
rm -f $depFile 2>/dev/null rm -f "$depFile" 2>/dev/null
fi fi
done done
done done
@ -199,24 +194,24 @@ oldFolders)
updateMode) updateMode)
if [ "$PWD" != "$WM_PROJECT_DIR" ] if [ "$PWD" != "$WM_PROJECT_DIR" ]
then then
echo "Cannot 'update', not in the project top-level directory" 1>&2 echo "Cannot 'update', not in project top-level directory" 1>&2
exit 1 exit 1
fi fi
echo "Removing dep files corresponding to source files that no longer exist..." echo "Removing dep files for non-existent source files ..." 1>&2
fileNameList=$(find -L src applications -name '*.[CHL]' -type l) fileNameList=$(find -L src applications -name '*.[CHL]' -type l)
for filePathAndName in $fileNameList for filePathAndName in $fileNameList
do do
fileName=$(basename $filePathAndName) fileName=$(basename "$filePathAndName")
for subdir in src applications for subdir in src applications
do do
echo " '$subdir': $fileName" echo " '$subdir': $fileName" 1>&2
(cd $subdir && $Script -a $fileName) (cd $subdir && $Script -all "$fileName")
done done
# Just in case, remove the symbolic link as the last step # Just in case, remove the symbolic link as the last step
unlink $filePathAndName unlink "$filePathAndName"
done done
;; ;;

View File

@ -3,7 +3,7 @@
# ========= | # ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration | # \\ / O peration |
# \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. # \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# | Copyright (C) 2015 OpenFOAM Foundation # | Copyright (C) 2015 OpenFOAM Foundation
@ -47,7 +47,7 @@ usage() {
Usage: $Script [OPTION] [file1 [... fileN]] Usage: $Script [OPTION] [file1 [... fileN]]
options: options:
-a | -all All platforms (current: $WM_OPTIONS) -a | -all | all All platforms (current: $WM_OPTIONS)
-h | -help Print the usage -h | -help Print the usage
Remove all .o files or remove .o file corresponding to <file> Remove all .o files or remove .o file corresponding to <file>
@ -70,10 +70,8 @@ do
-h | -help*) -h | -help*)
usage usage
;; ;;
# All platforms -a | -all | all) # All platforms
-a | -all | all)
platform=all platform=all
shift
;; ;;
-*) -*)
usage "unknown option: '$1'" usage "unknown option: '$1'"
@ -82,6 +80,7 @@ do
break break
;; ;;
esac esac
shift
done done
# Check environment variables # Check environment variables
@ -94,22 +93,21 @@ checkEnv
objectsDir=$(findObjectDir .) || exit 1 # Fatal objectsDir=$(findObjectDir .) || exit 1 # Fatal
# With the -a/-all option replace the current platform with a wildcard # With -a/-all option: replace the current platform with a wildcard
if [ "$platform" = all ] if [ "$platform" = all ]
then then
objectsDir=$(echo $objectsDir | sed s%$WM_OPTIONS%*% ) objectsDir=$(echo "$objectsDir" | sed "s%$WM_OPTIONS%*%")
fi fi
if [ "$#" -eq 0 ] if [ "$#" -eq 0 ]
then then
echo "removing all .o files ..." echo "Removing all .o files ..." 1>&2
find $objectsDir -name '*.o' -type f -delete find "$objectsDir" -name '*.o' -type f -delete
else else
echo "removing .o files corresponding to" echo "Removing .o files for: $*" 1>&2
echo " $@ ..."
for file for file
do do
rm $objectsDir/${file%%.*}.o rm -f "$objectsDir/${file%%.*}.o" 2>/dev/null
done done
fi fi