-
Notifications
You must be signed in to change notification settings - Fork 17
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
feat: Add support for user-defined builtins with Dune plugins #214
base: master
Are you sure you want to change the base?
Conversation
In retrospect, I am not 100% sure this is a good idea. I did this initially to have an example of usage of the plugin mechanism, but ended up writing two example plugins ( |
This was causing build failures on the CI so no longer part of the PR. Instead there is support for builtin extensions when loading them at the CLI level. |
I did some late cleanup but this should be ready to review @Gbury |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this looks good.
Note: you can rebase on current master to fix the CI bugs.
src/bin/options.ml
Outdated
Result.map (fun ext -> (ext, kind)) (find_ext name) | ||
in | ||
let print ppf _p = Fmt.pf ppf "" in | ||
Arg.conv (parse, print) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is enough code to warrant it being mostly in a new file (extensions.ml
?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough, will do.
src/bin/options.ml
Outdated
add_plugin ok err e @@ parse_ext_opt e | ||
) (builtin_extensions, []) (Dolmen.Sites.Plugins.Plugins.list ()) | ||
in | ||
merge_extensions ok, List.fast_sort String.compare err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm... I'm a bit worried by the cost of computing the list of all extensions systematically at startup (particularly since listing all dune plugins might involve a number of system calls).
Intuitively, we should only need that we want want to list all extensions, i.e. when a user asks for a list of extensions (or in error messages), but when loading an extension, we should be able to not need the lis tof all extensions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I did it this way because I initially wanted to preserve the behavior where the list of all available extensions is provided as an enum
to Cmdliner. Since this is no longer the case (and there is --list-extensions
instead), it makes sense to perform the listing lazily; will change.
This patch adds support for model extensions in `Dolmen_loop` using a similar mechanism to typing extensions. Model extensions and typing extensions are now loaded by the binary through Dune's plugin mechanism, and the existing `bvconv` extension is moved to use the plugin mechanism. Fixes Gbury#203
- Move code dealing with extensions out of the Options module and into a new Extensions module - Clean up examples (notably avoid an almost-empty plugin in abs_real_split by defining the builtin in the typing plugin; it does not make sense to use the model plugin without the typing plugin) - Load dune plugins lazily - Use a hash table to find binary extensions (but not typing extensions/model extensions) - Allow override of builtin extensions by dune plugins
Made the requested changes + some others following (old) offline discussions:
|
@Gbury ping |
This patch adds support for model extensions in
Dolmen_loop
using a similar mechanism to typing extensions.Model extensions and typing extensions are now loaded by the binary through Dune's plugin mechanism, and the existing
bvconv
extension is moved to use the plugin mechanism.Fixes #203