Skip to content

Commit

Permalink
Building: revert to the version using the global environment variables.
Browse files Browse the repository at this point in the history
* The user does not need to specify the paths inside the script anymore.
* If a dependency (e.g. yaml-cpp) is installed in a non-standard directory, it should be defined in the global paths. These are the CPLUS_INCLUDE_PATH for the header files and LIBRARY_PATH or LD_LIBRARY_PATH for the libraries.
* It has been tested with preCICE as a shared or as a static library and yaml-cpp installed from source or from the Ubuntu repositories.
* This closes #1.
  • Loading branch information
MakisH committed Dec 19, 2017
2 parents 3b46a88 + a350b71 commit c5b76e0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 25 deletions.
52 changes: 30 additions & 22 deletions Allwmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@
cd ${0%/*} || exit 1 # Run from this directory

########## CONFIGURATION - You may want to change these ########################
# Note: system paths such as LD_LIBRARY_PATH, LIBRARY_PATH, or CPLUS_INCLUDE_PATH
# are currently NOT searched. Using these variables here also does not work.
# You need to specify the exact directories, without any list separators.

# YAML-CPP include path - the PARENT of yaml-cpp/ (try running "locate yaml.h")
ADAPTER_YAML_CPP_INC="/usr/include/"
# YAML-CPP library path (try running "locate libyaml-cpp.")
ADAPTER_YAML_CPP_LIB="/usr/lib/x86_64-linux-gnu/"

# preCICE root path (should be already globally set)
ADAPTER_PRECICE_ROOT="${PRECICE_ROOT}"

Expand All @@ -19,13 +10,8 @@ ADAPTER_PRECICE_ROOT="${PRECICE_ROOT}"
# specify its dependncies.
# For an up-to-date list of dependencies,
# look at https://github.com/precice/precice/wiki/Building
# C++ Boost library path - required from preCICE (try running "locate libboost_log.")
ADAPTER_BOOST_LIB="/usr/local/lib"
# PETSc library path - if required from preCICE (try running "locate libpetsc.")
ADAPTER_PETSC_LIB="${PETSC_DIR}/${PETSC_ARCH}/lib"
# Uncomment to use preCICE as a static library: preCICE dependencies
# ADAPTER_PRECICE_DEP="-L${ADAPTER_PETSC_LIB} -lpetsc -lmpi_cxx -L${ADAPTER_BOOST_LIB} -lboost_system -lboost_filesystem -lboost_log -lboost_log_setup -lboost_thread -lboost_program_options -lpthread -lpython2.7"

ADAPTER_PRECICE_DEP="-lpetsc -lmpi_cxx -lboost_system -lboost_filesystem -lboost_log -lboost_log_setup -lboost_thread -lboost_program_options -lpthread -lpython2.7 -lxml2"

# Optional: Preprocessor flags ("-DADAPTER_DEBUG_MODE" enables debug messages)
ADAPTER_PREP_FLAGS="-DADAPTER_DEBUG_MODE"
Expand All @@ -41,32 +27,54 @@ ADAPTER_TARGET_DIR="${FOAM_USER_LIBBIN}"

# Information header
echo "Building the OpenFOAM adapter for preCICE..."
echo "Make sure that all the required dependencies (mainly yaml-cpp and preCICE) are installed and their paths set in this file are correct. System paths such as LD_LIBRARY_PATH are NOT searched.\n"
echo "Make sure that all the required dependencies (mainly yaml-cpp and preCICE) are installed.\n"

# What is going on here:
# 1. get the colon-separated paths (e.g. the CPLUS_INCLUDE_PATH),
# 2. translate all the colons to new line characters, i.e. move each entry to a new line,
# 3. remove the empty lines. These would result from ":path" or "path:" or "path::path".
# 4. add the respective "-I" or "-L" in the beginning of the line,
# 5. translate the new line characters to "\", i.e. make everything again one line.

# Extract the paths from the CPLUS_INCLUDE_PATH list and convert them to a sequence of "-I/path/ \"
if [ "${CPLUS_INCLUDE_PATH}" ]; then
ADAPTER_GLOBAL_CPLUS_INC_PATHS=$(echo $CPLUS_INCLUDE_PATH | tr ':' '\n' | sed '/^$/d' | sed 's/^/-I/' | tr '\n' ' \\')
fi

# Extract the paths from the LD_LIBRARY_PATH list and convert them to a sequence of "-L/path/ \"
if [ "${LD_LIBRARY_PATH}" ]; then
ADAPTER_GLOBAL_LD_LIBRARY_PATHS=$(echo $LD_LIBRARY_PATH | tr ':' '\n' | sed '/^$/d' | sed 's/^/-L/' | tr '\n' ' \\')
fi

# Extract the paths from the LIBRARY_PATH list and convert them to a sequence of "-L/path/ \"
if [ "${LIBRARY_PATH}" ]; then
ADAPTER_GLOBAL_LIBRARY_PATHS=$(echo $LIBRARY_PATH | tr ':' '\n' | sed '/^$/d' | sed 's/^/-L/' | tr '\n' ' \\')
fi

# Export the environment variables
export ADAPTER_YAML_CPP_INC
export ADAPTER_YAML_CPP_LIB
export ADAPTER_PRECICE_ROOT
export ADAPTER_PRECICE_DEP
export ADAPTER_PREP_FLAGS
export ADAPTER_TARGET_DIR
export ADAPTER_GLOBAL_CPLUS_INC_PATHS
export ADAPTER_GLOBAL_LD_LIBRARY_PATHS
export ADAPTER_GLOBAL_LIBRARY_PATHS

# Inform the user about the environment
echo "Using the following environment variables:"
echo " ADAPTER_YAML_CPP_INC = ${ADAPTER_YAML_CPP_INC}"
echo " ADAPTER_YAML_CPP_LIB = ${ADAPTER_YAML_CPP_LIB}"
echo " ADAPTER_PRECICE_ROOT = ${ADAPTER_PRECICE_ROOT}"
if [ "${ADAPTER_PRECICE_DEP}" ]; then
echo " preCICE dependencies:"
echo " ADAPTER_PETSC_LIB = ${ADAPTER_PETSC_LIB}"
echo " ADAPTER_BOOST_LIB = ${ADAPTER_BOOST_LIB}"
echo " ADAPTER_PRECICE_DEP = ${ADAPTER_PRECICE_DEP}"
else
echo " preCICE dependencies: not specified (ok if shared library)"
fi
echo " ADAPTER_PREP_FLAGS = ${ADAPTER_PREP_FLAGS}"
echo " ADAPTER_TARGET_DIR = ${ADAPTER_TARGET_DIR}"
echo " ADAPTER_WMAKE_OPTIONS = ${ADAPTER_WMAKE_OPTIONS}"
echo " ADAPTER_GLOBAL_CPLUS_INC_PATHS = ${ADAPTER_GLOBAL_CPLUS_INC_PATHS}"
echo " ADAPTER_GLOBAL_LD_LIBRARY_PATHS = ${ADAPTER_GLOBAL_LD_LIBRARY_PATHS}"
echo " ADAPTER_GLOBAL_LIBRARY_PATHS = ${ADAPTER_GLOBAL_LIBRARY_PATHS}"
echo ""

# Run wmake (build the adapter) and check the exit code
Expand Down
7 changes: 4 additions & 3 deletions Make/options
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ EXE_INC = \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
$(ADAPTER_GLOBAL_CPLUS_INC_PATHS) \
-I$(ADAPTER_PRECICE_ROOT)/src/precice \
-I${ADAPTER_YAML_CPP_INC} \
-I../ \
$(ADAPTER_PREP_FLAGS)

Expand All @@ -17,8 +17,9 @@ LIB_LIBS = \
-lmeshTools \
-lcompressibleTurbulenceModels \
-lincompressibleTurbulenceModels \
$(ADAPTER_GLOBAL_LIBRARY_PATHS) \
$(ADAPTER_GLOBAL_LD_LIBRARY_PATHS) \
-L$(ADAPTER_PRECICE_ROOT)/build/last \
-lprecice \
${ADAPTER_PRECICE_DEP} \
-L${ADAPTER_YAML_CPP_LIB} \
$(ADAPTER_PRECICE_DEP) \
-lyaml-cpp

0 comments on commit c5b76e0

Please sign in to comment.