diff --git a/bin/museSetup.sh b/bin/museSetup.sh index 3fc4980..4409d59 100755 --- a/bin/museSetup.sh +++ b/bin/museSetup.sh @@ -231,6 +231,8 @@ export MUSE_G4ST="" export MUSE_G4VG="" export MUSE_TRIGGER="" export MUSE_ENVSET="" +export MUSE_CPPFLAGS="" + # # now parse the words @@ -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 # diff --git a/bin/museStatus.sh b/bin/museStatus.sh index ff45796..c076a2f 100755 --- a/bin/museStatus.sh +++ b/bin/museStatus.sh @@ -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 diff --git a/python/sconstruct_helper.py b/python/sconstruct_helper.py index 93f3200..f48d8fa 100644 --- a/python/sconstruct_helper.py +++ b/python/sconstruct_helper.py @@ -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':