-
Notifications
You must be signed in to change notification settings - Fork 412
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
Watermaking in dune build
#1539
Comments
My understanding is that during build process vcs info might not be available (building from the release tarball). |
I guess we never considered it. In the release tarball, the VCS info are indeed not available, however the version number could be set in the opam file or somewhere else (I believe dune-release does that). The idea would basically be to rewrite files on the fly as we copy them to |
I would like such a feature. But it's not necessarily a Dune feature. And you're right about locations in the source tree. Which makes me think of a PPX that would read OCaml strings in the document and replace the placeholders by the same values. But there are a few scary things:
Or, considering that this a mainly for small replacements (like the name or the version of the package), one can say that the location issue is not really a severe issue and decide to still apply |
If it's only for the ml code, what about simply generating a plain .ml file with the value expanded? i.e. generate something that looks like this: let version = "..."
let vcs_id = "..."
... |
That's my usage yes. And that's a good idea, I could just add a Dune rule to generate a file like this (and maybe a small OPAM plugin?)… |
I guess we could add a new action that would perform the same substitutions as (rule (with-stdout-to info.ml (dune-subst file.ml.in))) where let version = "%%VERSION%%"
let vcs_commit_id = "%%VCS_COMMIT_ID%%"
... |
How would it work with nested projects/workspace that can be in different git/hg/... repos? I have the feeling that such a feature could replace a ugly hack I had to write to include version information in our projects |
The information would be obtained from the project the call to
|
I just ran into that exact situation and the I'd be happy to contribute a PR if you still think that'd be an improvement to dune! |
One thing to keep in mind is that using this feature will hurt incremental builds. I wonder if it makes no make the |
If it were to hurt incremental builds, it could make sense to make it a no-op in the dev profile. But why would it? As long as the |
Well if you commit anything even to a README you need to rerun |
Hum, it's true that every single commit would invalidate all the files containing |
Yh, there is the same issue with #880. I'm not sure the same behaviour will suit all users, so we could have an option to simply mask the exact VCS info wherever we use them. We can document all this in the |
Anyway, regarding the implementation, it will become easier once we have properly integrated the memoization system everywhere as this requires memoizing a few things such as the output of |
I like @jeremiedimino’s proposal to replace |
Hello,
I wanted to use watermarking (in the doc) in my project but I was expecting it to happen in
dune build @install
. Apparently not.dune-release
anddune subst
and not indune build @install
?dune subst
on all my files during the build process?-- Niols
The text was updated successfully, but these errors were encountered: