Open gonsie opened 7 years ago
Update: It's the actually the bash scripts that get a hard coded path. We are doing the right thing, the scripts get the 'install' location.
We just need a better solution than a hard coded path. OR, we could hard-code the path in scr_run and pass that value to the subsequent scripts.
Another approach is to not use paths and require that the user add the bin directory to their $PATH. I had avoided that to begin with since it's easy for users to get that mixed up, but we could look at changing that.
This stack overflow post mentions a bunch of solutions: https://stackoverflow.com/questions/4774054/reliable-way-for-a-bash-script-to-get-the-full-path-to-itself
There are only 6 scripts which use bindir
:
If we modify pre-run and post-run to take the bindir as a parameter, the users would only need to ensure it is properly defined in the version of scr run.
I was wrong. Those 6 are the only bash scripts to use bindir. There are 13 perl scripts which use it as well. With Perl we could make proper 'modules' which I think allow Perl to call co-located scripts (similar to python import statements).
You can get the script's own location in the $0
variable in bash and the directory is then $(dirname $0)
, for Perl scripts there is the FindBin package (part of perl): https://perldoc.perl.org/FindBin.html which directly gives the directory.
https://github.com/rhaas80/scr/commit/d60ecdacf3cfb6789e57f9ca8917bf1f483fa263 uses $0
and FindBin::Bin
to get the location of bindir
, datadir
and libdir
as a path constructed from the Perl script / bash script location.
This is not perfect since the relative directory layout is different in the BUILD directory and in the INSTALL directory so one still must run 'make install' before one can run the tests. Right now I have not tried to weed out files with *.in
handling that no longer have @FOO@
replacements.
Is this roughly what you had in mind?
The way we build our perl scripts is currently broken. The scripts need to be configured with the path to the other perl scripts. This path at build time (thus at
make test
time) is different from the path needed at install time. We need to re-configure our scripts when a user runsmake install