Skip to content
Snippets Groups Projects
Commit 8624d65c authored by Mark OLESEN's avatar Mark OLESEN
Browse files

ENH: support alternative build-root location (#2286)

- specify any of these

    ./Allwmake -build-root=...
    wmake -build-root=...
    FOAM_BUILDROOT=... wmake

  these specify an alternative root where build artifacts are to land.
  Currently only used as an alternative for the 'build/' hierarchy
  since the 'platforms/' target normally includes inputs as well.

  Possible use:
  ```
  (
      export WM_MPLIB="%{foam_mplib}"
      export FOAM_MPI="%{foam_mpi}"
      export MPI_ARCH_PATH="%{mpi_prefix}"

      export FOAM_BUILDROOT=/tmp/mpibuild
      export FOAM_MPI_LIBBIN="$FOAM_BUILDROOT/platforms/$WM_OPTIONS/lib/$FOAM_MPI"

      src/Pstream/Allwmake-mpi
   )
   ```
parent 27e57c29
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Copyright (C) 2014-2017 OpenFOAM Foundation # Copyright (C) 2014-2017 OpenFOAM Foundation
# Copyright (C) 2019-2020 OpenCFD Ltd. # Copyright (C) 2019-2021 OpenCFD Ltd.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# License # License
# 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.
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
# Parsed options (wmake) # Parsed options (wmake)
# -debug # -debug
# -q | -queue # -q | -queue
# -build-root=...
# Exports FOAM_BUILDROOT value.
# -module-prefix=... # -module-prefix=...
# Exports FOAM_MODULE_PREFIX value. # Exports FOAM_MODULE_PREFIX value.
# Unsets FOAM_MODULE_APPBIN, FOAM_MODULE_LIBBIN. # Unsets FOAM_MODULE_APPBIN, FOAM_MODULE_LIBBIN.
...@@ -107,6 +109,13 @@ do ...@@ -107,6 +109,13 @@ do
# Pass onwards to other Allwmake scripts # Pass onwards to other Allwmake scripts
;; ;;
-build-root=*)
# Alternative location for build intermediates
export FOAM_BUILDROOT="${arg#*=}"
echo "Build-root = ${FOAM_BUILDROOT:-[]}" 1>&2
continue # Argument handled, remove it
;;
-module-prefix=* | -prefix=* | --prefix=*) -module-prefix=* | -prefix=* | --prefix=*)
# As per setModulePrefix (wmakeFunctions) # As per setModulePrefix (wmakeFunctions)
export FOAM_MODULE_PREFIX="${arg#*=}" export FOAM_MODULE_PREFIX="${arg#*=}"
......
...@@ -214,7 +214,7 @@ cdSource() ...@@ -214,7 +214,7 @@ cdSource()
# - the objectsDir # - the objectsDir
# #
# Global variables used: # Global variables used:
# - WM_PROJECT_DIR, WM_OPTIONS # - FOAM_BUILDROOT, WM_PROJECT_DIR, WM_OPTIONS
findObjectDir() findObjectDir()
{ {
local project="$(expandPath "$WM_PROJECT_DIR")" local project="$(expandPath "$WM_PROJECT_DIR")"
...@@ -225,8 +225,13 @@ findObjectDir() ...@@ -225,8 +225,13 @@ findObjectDir()
relativeDir="${absdir#${project}/}" relativeDir="${absdir#${project}/}"
if [ "$relativeDir" != "$absdir" ] if [ "$relativeDir" != "$absdir" ]
then then
[ -w "$WM_PROJECT_DIR" ] && \ if [ -n "$FOAM_BUILDROOT" ] && [ -w "$FOAM_BUILDROOT" ]
then
objectsDir="${FOAM_BUILDROOT}/build/${WM_OPTIONS}/${relativeDir}"
elif [ -w "$WM_PROJECT_DIR" ]
then
objectsDir="${WM_PROJECT_DIR}/build/${WM_OPTIONS}/${relativeDir}" objectsDir="${WM_PROJECT_DIR}/build/${WM_OPTIONS}/${relativeDir}"
fi
fi fi
# Default (local) build directory # Default (local) build directory
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
# 3. (OR) descend into each sub-directory and repeat. # 3. (OR) descend into each sub-directory and repeat.
# #
# Environment # Environment
# FOAM_BUILDROOT
# FOAM_EXTRA_CFLAGS FOAM_EXTRA_CXXFLAGS FOAM_EXTRA_LDFLAGS # FOAM_EXTRA_CFLAGS FOAM_EXTRA_CXXFLAGS FOAM_EXTRA_LDFLAGS
# FOAM_MODULE_PREFIX # FOAM_MODULE_PREFIX
# #
...@@ -69,6 +70,7 @@ if [ -n "$1" ] ...@@ -69,6 +70,7 @@ if [ -n "$1" ]
then then
cat<<HELP_FULL cat<<HELP_FULL
-debug Define c++DBUG='-DFULLDEBUG -g' as override -debug Define c++DBUG='-DFULLDEBUG -g' as override
-build-root=PATH Specify FOAM_BUILDROOT for compilation intermediates
-module-prefix=PATH Specify FOAM_MODULE_PREFIX as absolute/relative path -module-prefix=PATH Specify FOAM_MODULE_PREFIX as absolute/relative path
-module-prefix=TYPE Specify FOAM_MODULE_PREFIX as predefined type -module-prefix=TYPE Specify FOAM_MODULE_PREFIX as predefined type
(u,user | g,group | o,openfoam) (u,user | g,group | o,openfoam)
...@@ -250,6 +252,11 @@ do ...@@ -250,6 +252,11 @@ do
optDebug=true optDebug=true
;; ;;
-build-root=*)
export FOAM_BUILDROOT="${1#*=}"
echo "Build-root = ${FOAM_BUILDROOT:-[]}" 1>&2
;;
-module-prefix=*) -module-prefix=*)
setModulePrefix "${1#*=}" setModulePrefix "${1#*=}"
;; ;;
...@@ -599,15 +606,20 @@ fi ...@@ -599,15 +606,20 @@ fi
# files and options being built in parallel # files and options being built in parallel
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Mini-version of findObjectDir # Mini-version of findObjectDir (from wmakeFunctions)
unset objectsDir unset objectsDir
# Handle project/{applications,src} as out-of-source build # Handle project/{applications,src} as out-of-source build.
relativeDir="${PWD#${WM_PROJECT_DIR}/}" relativeDir="${PWD#${WM_PROJECT_DIR}/}"
if [ "$relativeDir" != "$PWD" ] if [ "$relativeDir" != "$PWD" ]
then then
[ -w "$WM_PROJECT_DIR" ] && \ if [ -n "$FOAM_BUILDROOT" ] && [ -w "$FOAM_BUILDROOT" ]
then
objectsDir="${FOAM_BUILDROOT}/build/${WM_OPTIONS}/${relativeDir}"
elif [ -w "$WM_PROJECT_DIR" ]
then
objectsDir="${WM_PROJECT_DIR}/build/${WM_OPTIONS}/${relativeDir}" objectsDir="${WM_PROJECT_DIR}/build/${WM_OPTIONS}/${relativeDir}"
fi
fi fi
# Default (local) build directory # Default (local) build directory
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment