-
Notifications
You must be signed in to change notification settings - Fork 413
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
Vendored code support #2318
Vendored code support #2318
Conversation
This is just a draft for now and only the alias resolution part is implemented. I added blackbox I went for a The way it currently works is that As I said my concerns are mostly about the implementation and not so much about the current
If the approach seems good to you I've already noted a few things that I wanted to do but skipped
Next is the profile thing and if possible the warning one. I think the profile one is essential Let me know what you think! |
Make data_only_dirs and vendored mutually exclusive seems fine to me. I agree that data only should take precendence over pretty much everything else.
I suggest not to worry about this for now. Ignoring, data only, and vendoring is something that will need to be controlled via workspace or the command line. There's no need to specifically solve this problem for vendoring. |
Perhaps we should just include the loc for decode predicate_lang's? It's quite annoying to keep track of this manually and remember to pass this around. |
How about the following instead: module Status : sig
type t = Data_only | Normal | Vendored
module Or_ignored : sig
type nonrec t = Ignored | Status of t
end
end we don't really use polymorphic variants in dune. This use case doesn't seem like a strong enough reason to introduce them. |
Yeah I think you're right, my reasoning was that I didn't want it to be a world of pain for
works just as good and simplifies the code. I guess the only thing that it won't let you do is:
but I guess that's fine for now.
Yeah I just realised that after some |
9ee57eb
to
08d8e3b
Compare
I haven't thought about it until now but what should we do about My guess would be not to generate them but they can be quite convenient when browsing code sometime so I'm not so sure. I guess one can always force their generation by building the libraries on its own using the I realized that because I tried running |
Hmm ok nevermind the last bit. The unremoved |
I pushed some new commits! I removed the custom behaviour when explicitly specifying vendored directories to Now vendored code is built with a I'm not familiar enough with the flag computation logic but that seemed like the right place to do so without overwriting some other important flags. I think the only things left are:
Let me know what you think! |
I should also probably add a bit of documentation. |
Generating the .merlin files in the vendored dirs certainly seems desirable. It would be quite nice to be able to jump to vendored code automatically. |
+1 to merlin files in vendored dirs! I'm using this patch in the dune-universe/opam-overlays CI to generate static binaries of vendored ocamlformat and duniverse itself. Hurrah! |
@NathanReb looking good so far. I believe this is no longer a draft. Do you think you can change the dune code base to use this new vendored stanza? We currently have a |
Yeah sure! I think it's indeed ready, except for that data-only + vendored error. I tried to do it naively and it turned out to be a bit tedious so I'll try to think of something else but I guess it's okay if we merge it with a non located error at first. @emillon had an interesting suggestion regarding
I'm just writing this down here for future reference, not intending to implement it right now. I'm undrafting but I'll still work on:
|
The suggestion seems fine to me. Can this be done in a backwards compatible way however? It really is just an "aesthetic" change, so I think users might not be too happy if their stanza breaks for no tangible benefit. |
I tried adding a
But unfortunately it seems like the predicate language isn't available during bootstrap, see the error:
Should I make a small subset of |
You can use the same hack we use for the data only dirs and the examples directory:
|
@NathanReb did you forget to promote? |
I think I did ! |
It seems to be a bit trickier for the vendored directories as they still need to be traversed by the bootstrapped dune meaning I can't hide the I might be missing something though! |
Hmm, we might be talking about something else. I was thinking that you would add a function like:
and would hardcode it to the vendor dir in the bootstrap implementation ( |
Ok, I removed the commit! Last remaining things I believe are:
What do you think? |
What's the issue with 2? |
Personally I think that even 1) can be skipped. I think we are leaning too much towards the pessimistic side without much justification. We didn't go through any of this process with dirs, ignored_subdirs and other similar features and things turned out fine. The dune language was sufficient to allow a smooth transition. With this new stanza, I don't see a reason why we might not be able to support it in future versions of dune in its current form. So in the end:
While the benefits seem dubious. I'd say this another case of YAGNI |
There should be no issue. I think you should set |
I just learned about YAGNI :) In my mind, one reason to mark this experimental initially is the following: when we discussed about it, we were not sure whether it was better to use a If we go ahead with the Marking the feature as experimental initially is relatively cheap in terms of additional development time and gives us a bit more time to make small breaking adjustments without having to think about backward compatibility. |
I think I came off harsher than I intended. If there are concrete breaking changes that are being considered, then making it experimental is obviously desirable. But doing it because we are trying to preempt something unknown is not enough of a reason.
I think we have enough experience to conclude here that adding more types of dune files is more confusing than adding new stanzas. Workspace files are quite confusing (but very useful) to users and we learned some lessons from
Perhaps we should make it even cheaper. I wonder if all we really need is a |
Yeah, that's a good point. Plus thinking about it more, there is no reason to make a special case for vendored dirs and not other kinds of directories. No objection to release this directly without going through an experimental phase then.
That's an interesting idea. I like it. Thought I'd ague that the second stage should be a hard error, otherwise we risk having leftover |
That works for this particular warning but not for others which can't be disabled as conveniently AFAICT. Not making it an extension is perfectly fine by me! |
Ok nevermind the two particular warnings I had in mind or indeed pretty easy to disable in vendored code so I'll just silence them and we can figure out if other warnings need the same treatment. We should be good after that! |
7d8588e
to
e785783
Compare
And done! |
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 pushed a commit that cleans up the types a bit and wraps the documentation at 80 chars. LGTM from me. Thanks for this very useful feature.
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Fixes #2259, fixes #2260 and fixes #1016.
This PR adds a stanza to allow one to mark directories as containing vendored code so they can be
treated accordingly by dune.
When resolving aliases, such directories are not traversed. That means that by default installable
targets won't be built in there (unless required by an actual target), tests won't be run, code
won't be formatted or linted and so on.
Anything in a vendored directory is built with the release profile and any warnings are silenced to
prevent pollution of the standard output.
Note that the above behaviour doesn't apply if the user explicitly asked for a target within a
vendored dir.