Skip to content

Commit

Permalink
deploy_modulefiles.sh.in: add '' after -i for each of the sed command…
Browse files Browse the repository at this point in the history
…s to avoid writing the NCEPLIBS .lua-e file (macOS only)
  • Loading branch information
climbfuji committed Oct 19, 2020
1 parent b706b48 commit 5cd71f9
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions deploy_modulefiles.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ DFLAT="@FLAT@"

[[ $DFLAT == "ON" ]] && FLAT="Y" || FLAT="N"

# Account for differences in the sed command on Linux and macOS
if [[ "@CMAKE_SYSTEM_NAME@" == "Darwin" ]]; then
sedI="-i ''"
else
sedI="-i"
fi

# All module load commands for the umbrella module
moduleLoadCommands=""

Expand Down Expand Up @@ -52,7 +59,7 @@ for libName in $(ls -1 $tmplModulefilesDir); do
repl=$(echo ${prefix} | sed -e "s#/#\\\/#g")

# Replace #NCEPLIBS_ROOT# from template with $nceplibsInstallDir
sed -i -e "s/#NCEPLIBS_ROOT#/${repl}/g" $dstModulefile
sed $sedI -e "s/#NCEPLIBS_ROOT#/${repl}/g" $dstModulefile

# Add to module load commands for umbrella module
moduleLoadCommands="${moduleLoadCommands}
Expand All @@ -74,22 +81,19 @@ mkdir -p $modulesDestDir/NCEPLIBS

# Replace #NCEPLIBS_ROOT# from template with $nceplibsInstallDir
repl=$(echo ${nceplibsInstallDir} | sed -e "s#/#\\\/#g")
sed -i -e "s/#NCEPLIBS_ROOT#/${repl}/g" $dstModulefile
sed $sedI -e "s/#NCEPLIBS_ROOT#/${repl}/g" $dstModulefile

# Set compiler environment variables for the umbrella modulefile
repl=$(echo "@CMAKE_C_COMPILER@" | sed -e "s#/#\\\/#g")
sed -i -e "s/#CC#/${repl}/g" $dstModulefile
sed $sedI -e "s/#CC#/${repl}/g" $dstModulefile
repl=$(echo "@CMAKE_CXX_COMPILER@" | sed -e "s#/#\\\/#g")
sed -i -e "s/#CXX#/${repl}/g" $dstModulefile
sed $sedI -e "s/#CXX#/${repl}/g" $dstModulefile
repl=$(echo "@CMAKE_Fortran_COMPILER@" | sed -e "s#/#\\\/#g")
sed -i -e "s/#FC#/${repl}/g" $dstModulefile
sed $sedI -e "s/#FC#/${repl}/g" $dstModulefile

# Append all module load commands to umbrella module
echo "${moduleLoadCommands}" >> $dstModulefile

# Temporary workaround: if exists, remove .lua-e file that gets created by sed for a reason I don't understand
rm -vf ${dstModulefile}-e

echo "Done deploying modules ..."

echo "Generating shell scripts ..."
Expand Down

0 comments on commit 5cd71f9

Please sign in to comment.