Skip to content

Commit

Permalink
Force rebuild of library when using mklib directly
Browse files Browse the repository at this point in the history
With this commit:
- when using plumed mklib the library is always built, even if already present
- when using LOAD FILE=file.cpp, the library is only built if missing

I think this would avoid version mistake in users calling plumed mklib
directly. In addition, it makes plumed mklib work as in v2.9. The only
exception is when called via LOAD, where we force the use of a versioned
name
  • Loading branch information
GiovanniBussi committed May 13, 2024
1 parent 92216cd commit dfe0657
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions scripts/mklib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if [ "$1" = --help ] ; then
fi

if [ "$1" = --options ] ; then
echo "--description --options --help -o"
echo "--description --options --help -o -n"
exit 0
fi

Expand All @@ -27,6 +27,7 @@ source "$PLUMED_ROOT"/src/config/compile_options.sh

prefix=""
lib=""
no_clobber=""
files=() # empty array
for opt
do
Expand All @@ -37,6 +38,8 @@ do
prefix="--out=";;
(--out=*)
lib="${prefixopt#--out=}";;
(-n)
no_clobber=yes;;
(-*)
echo "ERROR: Unknown option $opt. Use --help for help."
exit 1 ;;
Expand Down Expand Up @@ -66,6 +69,10 @@ do
fi
done

if test -z "$no_clobber" ; then
recompile=yes
fi

if test $recompile = no ; then
echo "$lib is already up to date"
exit 0
Expand Down Expand Up @@ -148,5 +155,9 @@ fi

eval "$link_command" "$PLUMED_MKLIB_LDFLAGS" $objs -o "$tmpdir/$lib"

# || true is necessary with recent coreutils
mv -n "$tmpdir/$lib" $lib || true
if test -n "$no_clobber" ; then
# || true is necessary with recent coreutils
mv -n "$tmpdir/$lib" $lib || true
else
mv "$tmpdir/$lib" $lib
fi
2 changes: 1 addition & 1 deletion src/core/PlumedMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,7 @@ void PlumedMain::load(const std::string& fileName) {
// full path command, including environment setup
// this will work even if plumed is not in the execution path or if it has been
// installed with a name different from "plumed"
std::string cmd=config::getEnvCommand()+" \""+config::getPlumedRoot()+"\"/scripts/mklib.sh -o "+libName+" "+fileName;
std::string cmd=config::getEnvCommand()+" \""+config::getPlumedRoot()+"\"/scripts/mklib.sh -n -o "+libName+" "+fileName;

if(std::getenv("PLUMED_LOAD_ACTION_DEBUG")) log<<"Executing: "<<cmd;
else log<<"Compiling: "<<fileName<<" to "<<libName;
Expand Down

1 comment on commit dfe0657

@PlumedBot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found broken examples in automatic/ANGLES.tmp
Found broken examples in automatic/ANN.tmp
Found broken examples in automatic/CAVITY.tmp
Found broken examples in automatic/CLASSICAL_MDS.tmp
Found broken examples in automatic/CLUSTER_DIAMETER.tmp
Found broken examples in automatic/CLUSTER_DISTRIBUTION.tmp
Found broken examples in automatic/CLUSTER_PROPERTIES.tmp
Found broken examples in automatic/CONSTANT.tmp
Found broken examples in automatic/CONTACT_MATRIX.tmp
Found broken examples in automatic/CONTACT_MATRIX_PROPER.tmp
Found broken examples in automatic/COORDINATIONNUMBER.tmp
Found broken examples in automatic/DFSCLUSTERING.tmp
Found broken examples in automatic/DISTANCE_FROM_CONTOUR.tmp
Found broken examples in automatic/EDS.tmp
Found broken examples in automatic/EMMI.tmp
Found broken examples in automatic/ENVIRONMENTSIMILARITY.tmp
Found broken examples in automatic/FIND_CONTOUR.tmp
Found broken examples in automatic/FIND_CONTOUR_SURFACE.tmp
Found broken examples in automatic/FIND_SPHERICAL_CONTOUR.tmp
Found broken examples in automatic/FOURIER_TRANSFORM.tmp
Found broken examples in automatic/FUNCPATHGENERAL.tmp
Found broken examples in automatic/FUNCPATHMSD.tmp
Found broken examples in automatic/FUNNEL.tmp
Found broken examples in automatic/FUNNEL_PS.tmp
Found broken examples in automatic/GHBFIX.tmp
Found broken examples in automatic/GPROPERTYMAP.tmp
Found broken examples in automatic/HBOND_MATRIX.tmp
Found broken examples in automatic/INCLUDE.tmp
Found broken examples in automatic/INCYLINDER.tmp
Found broken examples in automatic/INENVELOPE.tmp
Found broken examples in automatic/INTERPOLATE_GRID.tmp
Found broken examples in automatic/LOCAL_AVERAGE.tmp
Found broken examples in automatic/MAZE_OPTIMIZER_BIAS.tmp
Found broken examples in automatic/MAZE_RANDOM_ACCELERATION_MD.tmp
Found broken examples in automatic/MAZE_SIMULATED_ANNEALING.tmp
Found broken examples in automatic/MAZE_STEERED_MD.tmp
Found broken examples in automatic/MULTICOLVARDENS.tmp
Found broken examples in automatic/OUTPUT_CLUSTER.tmp
Found broken examples in automatic/PAMM.tmp
Found broken examples in automatic/PCA.tmp
Found broken examples in automatic/PCAVARS.tmp
Found broken examples in automatic/PIV.tmp
Found broken examples in automatic/PLUMED.tmp
Found broken examples in automatic/PYCVINTERFACE.tmp
Found broken examples in automatic/PYTHONFUNCTION.tmp
Found broken examples in automatic/Q3.tmp
Found broken examples in automatic/Q4.tmp
Found broken examples in automatic/Q6.tmp
Found broken examples in automatic/QUATERNION.tmp
Found broken examples in automatic/SPRINT.tmp
Found broken examples in automatic/TETRAHEDRALPORE.tmp
Found broken examples in automatic/TORSIONS.tmp
Found broken examples in automatic/WHAM_WEIGHTS.tmp
Found broken examples in AnalysisPP.md
Found broken examples in CollectiveVariablesPP.md
Found broken examples in MiscelaneousPP.md

Please sign in to comment.