Use alternative etc config locations
As of OpenFOAM-v2006 (commit 5ba2cbc5) there is support for specifying alternative config file locations (actually for an alternative OpenFOAM etc/ layer). This was specifically added to handle systems like MacOS and mingw cross-compilation.
For this you would probably want to try something like this (pseudo-code):
- cd openfoam-project-dir
- mkdir -p "etc-macos/config.sh"
- echo 'export FOAM_CONFIG_ETC="etc-macos"' >> etc/prefs.sh
- copy/rsync etc/config.sh/{adios2,boost,CGAL, ....} to etc-macos/config.sh
- run bin/tools/foamConfigurePaths (can specify the -etc=... option for more certainty) and the rest of your configure.sh file
This way most of the changes will be encapsulated within the directory: making the changes more transparent and preserving them after a git update of OpenFOAM.
For good measure I would normally also add the alternative config location into its own file as well. For example,
echo 'export FOAM_CONFIG_ETC="etc-macos"' >> etc/etc-macos/prefs.sh
This enables use of 'source etc/bashrc etc-macos/prefs.sh' from the command-line (eg, for testing) and does no harm otherwise.
Interesting. Would a plain source etc/bashrc still work (and load the right configuration) in that case? Otherwise, that'd be a dealbreaker.
BTW, I appreciate someone from "upstream" commenting on my project. Hope you folks like what I'm doing here, and thanks for promptly dealing with my issue reports! 👍
Interesting. Would a plain
source etc/bashrcstill work (and load the right configuration) in that case? Otherwise, that'd be a dealbreaker.
If you stuff the export FOAM_CONFIG_ETC="xyz" into the etc/prefs.sh, this will be seen before any other sourcing occurs: it should work OK.
BTW, I appreciate someone from "upstream" commenting on my project. Hope you folks like what I'm doing here, and thanks for promptly dealing with my issue reports! +1
Since we don't have any Apple machines for developing ourselves, we need your input/feedback.
I'm curious as to what exactly this would imply.
- copy/rsync etc/config.sh/{adios2,boost,CGAL, ....} to etc-macos/config.sh
Do I need to copy the entire etc/config.sh and etc/config.csh trees, or will it fall back to the base config at etc for any files that weren't copied?
- run bin/tools/foamConfigurePaths (can specify the -etc=... option for more certainty) and the rest of your configure.sh file
Would this let me forgo the configure.sh step, by checking the new config layer directly into the repo and then using that?
Right now, configure.sh mixes foamConfigurePaths (for changes supported by that script) with manual file writes/patching (for stuff that can't be done with foamConfigurePaths). Ideally, I'd like it to only have to do one of the two.
- only rsync stuff that you actually need to generate or overwrite
- the foamEtcFile searching will still follow the order (see
foamEtcFile -list)
If you are happy with your replacement file contents (generated manually), there is no need to use foamConfigurePaths. If you take a look at the spack recipe for openfoam you will see that is exactly what we do there - except that for spack we simply overwrite the files and don't try to preserve the original ones (the alternative etc specification is too new and spack goes back to 1612 or so).