From 8c8dbd1e12f8d15c2538bb5d4728798c2c265361 Mon Sep 17 00:00:00 2001 From: Makis Chourdakis Date: Thu, 14 Dec 2017 00:19:01 +0100 Subject: [PATCH 1/3] Build script: do not create empty entries for -I, -L The "hack" works like this now: 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. Before, this was resulting sometimes in empty "-I " or "-L ", which behaved weirdly in some scenarios. --- Allwmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Allwmake b/Allwmake index 58950da4..5a974e06 100755 --- a/Allwmake +++ b/Allwmake @@ -31,17 +31,17 @@ echo "Make sure that all the required dependencies (mainly yaml-cpp and preCICE) # 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 's/^/-I/' | tr '\n' ' \\') + 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 's/^/-L/' | tr '\n' ' \\') + 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 's/^/-L/' | tr '\n' ' \\') + ADAPTER_GLOBAL_LIBRARY_PATHS=$(echo $LIBRARY_PATH | tr ':' '\n' | sed '/^$/d' | sed 's/^/-L/' | tr '\n' ' \\') fi # Export the environment variables From a4bfdf6ca29024b7515a3f3b7ee33bb7c9e02f71 Mon Sep 17 00:00:00 2001 From: Makis Chourdakis Date: Thu, 14 Dec 2017 00:31:47 +0100 Subject: [PATCH 2/3] Build: move the ADAPTER_GLOBAL_CPLUS_INC_PATHS to the EXE_INC. I previously thought it would be a good idea to have CPLUS_INCLUDE_PATH in the SYS_INC. However, this is not common practice. Additionally, this is just before the `-fPIC` flag and an empty `-I` would aparently make the linker not read the `-fPIC` flag. --- Make/options | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Make/options b/Make/options index 365092af..6b594583 100644 --- a/Make/options +++ b/Make/options @@ -7,13 +7,11 @@ 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_PREP_FLAGS) -SYS_INC += \ - $(ADAPTER_GLOBAL_CPLUS_INC_PATHS) - LIB_LIBS = \ -lfiniteVolume \ -lmeshTools \ From a350b71cb8758eb34964a2b6de643e5b16a79708 Mon Sep 17 00:00:00 2001 From: Makis Chourdakis Date: Thu, 14 Dec 2017 00:39:53 +0100 Subject: [PATCH 3/3] Build script: add description for the conversion of paths. --- Allwmake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Allwmake b/Allwmake index 5a974e06..17e71dee 100755 --- a/Allwmake +++ b/Allwmake @@ -29,6 +29,13 @@ ADAPTER_TARGET_DIR="${FOAM_USER_LIBBIN}" echo "Building the OpenFOAM adapter for preCICE..." 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' ' \\')