mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
New version of wmake supporting out-of-tree object and dependency files
This commit is contained in:
154
wmake/scripts/AllwmakeParseArguments
Normal file
154
wmake/scripts/AllwmakeParseArguments
Normal file
@ -0,0 +1,154 @@
|
||||
#----------------------------------*-sh-*--------------------------------------
|
||||
# ========= |
|
||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
# \\ / O peration |
|
||||
# \\ / A nd | Copyright (C) 2014 OpenFOAM Foundation
|
||||
# \\/ 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/>.
|
||||
#
|
||||
# File
|
||||
# wmake/scripts/AllwmakeParseArguments
|
||||
#
|
||||
# Description
|
||||
# Allwmake argument parser
|
||||
#
|
||||
# Usage
|
||||
# # Declare the targetType and set to default for library building
|
||||
# targetType=libso # lib, libo or libso
|
||||
#
|
||||
# # Declare genDoc and set to default if documentation building is supported
|
||||
# genDoc=0 # 0 or 1
|
||||
#
|
||||
# # Parse the arguments by sourcing this script
|
||||
# . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
Script=${0##*/}
|
||||
|
||||
usage() {
|
||||
exec 1>&2
|
||||
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
||||
|
||||
# Print normal usage options
|
||||
cat<<USAGE
|
||||
|
||||
Usage: $Script [OPTIONS]
|
||||
|
||||
options:
|
||||
-h or -help Print list of Allwmake options
|
||||
-k or -non-stop Compile without stopping when errors occur
|
||||
-j Compile using all local cores/hyperthreads
|
||||
-jN or -j N Compile using N cores/hyperthreads
|
||||
-no-scheduler Compile without wmakeScheduler
|
||||
USAGE
|
||||
|
||||
# Print options for building code documentation
|
||||
test -n "$genDoc" && cat<<USAGE_DOC
|
||||
doc Compile code documentation (requires Doxygen)
|
||||
USAGE_DOC
|
||||
|
||||
# Print options for building libraries
|
||||
test -n "$targetType" && cat<<USAGE_LIB
|
||||
lib Compile statically linked archive lib (.a)
|
||||
libo Compile statically linked lib (.o)
|
||||
libso Compile dynamically linked lib (.so)
|
||||
dep Compile dependency files
|
||||
USAGE_LIB
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Set WM_NCOMPPROCS to number of cores on local machine
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
setWM_NCOMPPROCS()
|
||||
{
|
||||
if [ -r /proc/cpuinfo ]
|
||||
then
|
||||
WM_NCOMPPROCS=$(egrep "^processor" /proc/cpuinfo | wc -l)
|
||||
else
|
||||
WM_NCOMPPROCS=1
|
||||
fi
|
||||
|
||||
export WM_NCOMPPROCS
|
||||
}
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Parse the arguments and options
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
while [ "$#" -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
# Print help
|
||||
-h | -help)
|
||||
usage
|
||||
;;
|
||||
# Parallel compilation on all cores of local machine
|
||||
-j)
|
||||
setWM_NCOMPPROCS
|
||||
test $# -ge 2 && expr $2 + 1 > /dev/null 2>&1 \
|
||||
&& shift && export WM_NCOMPPROCS=$1
|
||||
echo "Compiling enabled on $WM_NCOMPPROCS cores"
|
||||
;;
|
||||
# Parallel compilation on specified number of cores
|
||||
-j*)
|
||||
export WM_NCOMPPROCS=${1#-j}
|
||||
echo "Compiling enabled on $WM_NCOMPPROCS cores"
|
||||
;;
|
||||
# Non-stop compilatio, ignoring errors
|
||||
-k | -non-stop)
|
||||
export WM_CONTINUE_ON_ERROR=1
|
||||
;;
|
||||
# Disable scheduled parallel compilation
|
||||
-no-scheduler)
|
||||
unset WM_SCHEDULER
|
||||
;;
|
||||
# Generate documentation
|
||||
doc)
|
||||
test -n "$genDoc" || usage "invalid option '$1'"
|
||||
genDoc=1
|
||||
;;
|
||||
# Specify target type
|
||||
lib | libo | libso | dep)
|
||||
test -n "$targetType" || usage "invalid option '$1'"
|
||||
targetType=$1
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
-* | *)
|
||||
usage "invalid option '$1'"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Cleanup local variables and functions
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
unset Script usage setWM_NCOMPPROCS
|
||||
|
||||
|
||||
# ----------------------------------------------------------------- end-of-file
|
||||
@ -1,64 +0,0 @@
|
||||
#!/bin/sh
|
||||
#------------------------------------------------------------------------------
|
||||
# ========= |
|
||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
# \\ / O peration |
|
||||
# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
# \\/ 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
|
||||
# addCompile
|
||||
#
|
||||
# Description
|
||||
# Cleans up the dependency list and add the compilation statement.
|
||||
#
|
||||
# Usage: wmkdep <fileName> | addCompile <fileName>
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
sourceName=${1##*/}
|
||||
objectName=${sourceName%.*}.o
|
||||
className=${sourceName%.*}.class
|
||||
sub=${1##*.}
|
||||
depName=${1%.*}.dep
|
||||
|
||||
sourceDir=${1%/*}
|
||||
|
||||
if [ "$sourceDir" = "$sourceName" ]
|
||||
then
|
||||
sourceDir=.
|
||||
fi
|
||||
|
||||
if [ "$WM_PROJECT_DIR" ]
|
||||
then
|
||||
sed -e s%$WM_PROJECT_DIR%'$(WM_PROJECT_DIR)'% > $depName
|
||||
else
|
||||
cat > $depName
|
||||
fi
|
||||
|
||||
sed -e s%".*.o.*:"%'$(OBJECTS_DIR)/'"$objectName\:"% \
|
||||
-e s%$WM_PROJECT_DIR%'$(WM_PROJECT_DIR)'% \
|
||||
>> $depName
|
||||
|
||||
echo '$(OBJECTS_DIR)/'$objectName': $(EXE_DEP)' >> $depName
|
||||
echo '$(OBJECTS_DIR)/'$objectName':' >> $depName
|
||||
echo ' @SOURCE_DIR='$sourceDir >> $depName
|
||||
echo ' SOURCE='$1' ; $('$sub'too)' >> $depName
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@ -1,133 +0,0 @@
|
||||
#!/bin/sh
|
||||
#------------------------------------------------------------------------------
|
||||
# ========= |
|
||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
# \\ / O peration |
|
||||
# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
# \\/ 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
|
||||
# makeDerivedFiles
|
||||
#
|
||||
# Description
|
||||
# Constructs all the file list for make given the source file list,
|
||||
# written by hand or using makeFilesAndOptions.
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
[ -d "$WM_OPTIONS" ] || {
|
||||
echo "The '$WM_OPTIONS' directory does not exist, exiting" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# change to the $WM_OPTIONS directory
|
||||
cd "$WM_OPTIONS" 2>/dev/null || {
|
||||
echo "Could not change to directory '$WM_OPTIONS'" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Find and keep macro definitions in files list
|
||||
grep "=" files > filesMacros
|
||||
|
||||
# Remove all macro definitions from the files list
|
||||
grep -v "=" files > filesPlusBlank
|
||||
|
||||
# Add a newline to files to ensure the last line is followed by a newline
|
||||
echo "" >> filesPlusBlank
|
||||
|
||||
|
||||
# Remove commented lines, blank lines, and trailing blanks from files
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
sed -e '/^#/ d' \
|
||||
-e '/^[ \t]*$/ d' \
|
||||
-e 's/[ \t]*$//' \
|
||||
filesPlusBlank > files.$$
|
||||
|
||||
rm filesPlusBlank
|
||||
|
||||
|
||||
# make sourceFiles
|
||||
# ~~~~~~~~~~~~~~~~
|
||||
echo "SOURCE = " > tmpSourceFile
|
||||
cat files.$$ >> tmpSourceFile
|
||||
|
||||
sed -e 's/$/\\/' \
|
||||
-e '$s/\\//' \
|
||||
tmpSourceFile > sourceFiles
|
||||
|
||||
rm tmpSourceFile
|
||||
|
||||
|
||||
# make objectFiles
|
||||
# ~~~~~~~~~~~~~~~~
|
||||
sed -e 's%.*/%%' \
|
||||
-e 's%^%$(OBJECTS_DIR)/%' \
|
||||
-e 's%\.[a-zA-Z]*$%\.o%' \
|
||||
files.$$ > tmpObjectFiles
|
||||
|
||||
echo "OBJECTS = " > tmpObjectFiles2
|
||||
cat tmpObjectFiles >> tmpObjectFiles2
|
||||
|
||||
sed -e 's/$/\\/' \
|
||||
-e '$s/\\//' \
|
||||
tmpObjectFiles2 > objectFiles
|
||||
|
||||
rm tmpObjectFiles tmpObjectFiles2
|
||||
|
||||
|
||||
# make localObjectFiles
|
||||
# ~~~~~~~~~~~~~~~~~~~~~
|
||||
sed -e 's%.*/%%' \
|
||||
-e 's%\.[a-zA-Z]*$%\.o%' \
|
||||
files.$$ > tmpLocalObjectFiles
|
||||
|
||||
echo "LOCAL_OBJECTS = " > tmpLocalObjectFiles2
|
||||
cat tmpLocalObjectFiles >> tmpLocalObjectFiles2
|
||||
|
||||
sed -e 's/$/\\/' \
|
||||
-e '$s/\\//' \
|
||||
tmpLocalObjectFiles2 > localObjectFiles
|
||||
|
||||
rm tmpLocalObjectFiles tmpLocalObjectFiles2
|
||||
|
||||
|
||||
# make dependencyFiles
|
||||
# ~~~~~~~~~~~~~~~~~~~~
|
||||
sed 's/\.[a-zA-Z]*$/\.dep/' \
|
||||
files.$$ > tmpDependencyFiles
|
||||
|
||||
echo "DEPENDENCIES = " > tmpDependencyFiles2
|
||||
cat tmpDependencyFiles >> tmpDependencyFiles2
|
||||
|
||||
sed -e 's/$/\\/' \
|
||||
-e '$s/\\//' \
|
||||
tmpDependencyFiles2 > dependencyFiles
|
||||
|
||||
rm tmpDependencyFiles tmpDependencyFiles2
|
||||
|
||||
|
||||
# make includeDeps
|
||||
# ~~~~~~~~~~~~~~~~
|
||||
sed -e 's/\.[a-zA-Z]*$/.dep/' \
|
||||
-e 's/^/include /' \
|
||||
files.$$ > includeDeps
|
||||
|
||||
rm files.$$
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@ -1,40 +0,0 @@
|
||||
#!/bin/sh
|
||||
#------------------------------------------------------------------------------
|
||||
# ========= |
|
||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
# \\ / O peration |
|
||||
# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
# \\/ 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
|
||||
# makeDir
|
||||
#
|
||||
# Description
|
||||
# Script to make directories that do not already exist
|
||||
# Usage : makeDir <dir> [.. <dirN>]
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
for dir
|
||||
do
|
||||
[ -d "$dir" ] || mkdir -p "$dir"
|
||||
done
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
Reference in New Issue
Block a user