Skip to content

Commit

Permalink
Merge pull request #88 from rlcee/cpp_230831
Browse files Browse the repository at this point in the history
start custom cppflags option
  • Loading branch information
rlcee authored Aug 31, 2023
2 parents 010640e + 3eff778 commit 8ad0445
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
22 changes: 22 additions & 0 deletions bin/museSetup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ export MUSE_G4ST=""
export MUSE_G4VG=""
export MUSE_TRIGGER=""
export MUSE_ENVSET=""
export MUSE_CPPFLAGS=""


#
# now parse the words
Expand Down Expand Up @@ -678,6 +680,26 @@ if [ "$QWARN" ]; then
echo " inconsistent builds and memory errors."
fi

#
# search .muse files for compiler flags requests
# using the backing directories in reverse order from above
# note that the envset could have also added to the flags
#

for BDIR in $MUSE_BACKING_REV $MUSE_WORK_DIR
do
REPOS=$(/bin/ls -1 $BDIR/*/.muse 2> /dev/null | awk -F/ '{printf "%s ", $(NF-1)}' )
for REPO in $REPOS
do
TEMP="$(cat $BDIR/$REPO/.muse |
awk '{if($1=="CPPFLAGS") {for(i=2;i<=NF;i++) printf "%s ", $i;}}')"
if [ -n "$TEMP" ]; then
[ $MUSE_VERBOSE -gt 0 ] && echo "CPPFLAGS $BDIR/$REPO/.muse adds $TEMP"
export MUSE_CPPFLAGS=${MUSE_CPPFLAGS:+$MUSE_CPPFLAGS" "}$TEMP
fi
done
done

#
# check if we setup an empty directory, if so give a warning
#
Expand Down
4 changes: 4 additions & 0 deletions bin/museStatus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ if [ "$MUSE_PREBUILD" ]; then
[ $MUSE_VERBOSE -gt 0 ] && echo "the pre build command:"
echo " MUSE_PREBUILD = " $MUSE_PREBUILD
fi
if [ "$MUSE_CPPFLAGS" ]; then
[ $MUSE_VERBOSE -gt 0 ] && echo "compile flags requested in .muse files:"
echo " MUSE_CPPFLAGS = " $MUSE_CPPFLAGS
fi

echo

Expand Down
9 changes: 8 additions & 1 deletion python/sconstruct_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,17 @@ def mergeFlags(mu2eOpts):
if nn >= 27 :
std = '-std=c++20'

cppflags = []
flagstr = os.environ.get('MUSE_CPPFLAGS')
if flagstr :
cppflags = flagstr.split()

flags = [std,'-Wall','-Wno-unused-local-typedefs','-g',
'-Werror','-Werror=pedantic',
'-Wl,--no-undefined','-gdwarf-2', '-Wl,--as-needed',
'-Werror=return-type','-Winit-self','-Woverloaded-virtual' ]
'-Werror=return-type','-Winit-self','-Woverloaded-virtual']
flags = flags + cppflags

if build == 'prof':
flags = flags + [ '-O3', '-fno-omit-frame-pointer', '-DNDEBUG' ]
elif build == 'debug':
Expand Down

0 comments on commit 8ad0445

Please sign in to comment.