-
Notifications
You must be signed in to change notification settings - Fork 392
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
[RFC] Allow to pass more information to ppx rewriters #2020
Comments
I feel that using the profile to encode information is a bad pattern. We have for example multiple profiles that are equivalent to release. The ppx has no way to guess that those other profiles should be treated like release. |
That makes sense. I suppose we could have a new parameter In that case, we don't even need to implement the full generic proposal right now, we can only pass |
I thought about this a bit more, and I'm wondering if this is at all necessary with link time code gen. We can very easily create a little dune library that dune can generate on every build with information such as |
That's a good point. The feature described in this issues has been added to dune BTW, so we can safely close it. |
In retrospect, using link time code gen is a bad idea here. We don't want to rebuild the ppx binary just because context/profile changed. I'd much prefer if there was a simple way to pass these values at runtime. |
This proposal describes a way to pass more information from dune to ppx rewriters.
Description
We extend the
ppx_rewriter
andppx_deriver
library kinds to take acookies
parameter. This parameters describe a list of cookies that dune should pass to the ppx rewriter. The argument ofcookies
is a list of cookie definition of the form(<name> <string-with-variables>)
, such as(profile %{profile})
.For instance:
(library (name ppx_inline_test) (kind (ppx_rewriter (cookies (profile "\"%{profile\""})))))
When invoking the final ppx driver that links all the ppx rewriter, dune will collect all the cookies requested by the various ppx rewriters and pass them via the command line as follow:
When two ppx rewriters request the same cookie, the associated value must be equal. Otherwise dune will error out.
To match the current behavior, dune will also add the following cookie to this list:
(library-name \"%{library-name}\")
.The text was updated successfully, but these errors were encountered: