Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use alternative etc config locations #167

Open
olesenm opened this issue Jun 27, 2023 · 7 comments
Open

Use alternative etc config locations #167

olesenm opened this issue Jun 27, 2023 · 7 comments
Labels
enhancement New feature or request

Comments

@olesenm
Copy link

olesenm commented Jun 27, 2023

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.

@olesenm
Copy link
Author

olesenm commented Jun 27, 2023

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.

@gerlero
Copy link
Owner

gerlero commented Jun 27, 2023

Interesting. Would a plain source etc/bashrc still work (and load the right configuration) in that case? Otherwise, that'd be a dealbreaker.

@gerlero
Copy link
Owner

gerlero commented Jun 27, 2023

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! 👍

@olesenm
Copy link
Author

olesenm commented Jun 28, 2023

Interesting. Would a plain source etc/bashrc still 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.

@olesenm
Copy link
Author

olesenm commented Jun 28, 2023

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.

@gerlero gerlero added the enhancement New feature or request label Jun 29, 2023
@gerlero
Copy link
Owner

gerlero commented Jun 29, 2023

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.

@olesenm
Copy link
Author

olesenm commented Jul 3, 2023

  • 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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants