-
Notifications
You must be signed in to change notification settings - Fork 409
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] Order-only dependencies #5514
Comments
Do you have an idea of the rough API that would give? |
At the level of the build engine, we already have the dune/src/dune_engine/action_builder0.mli Lines 70 to 74 in 4bc7629
This API in principle seems sufficient, although one could imagine packaging it up into a more explicit combinator, with some associated documentation/examples. I haven't yet had time to think about how that combinator would look like -- any suggestions are welcome! We could also consider exposing order-only dependencies at the level of the |
I tried to make this work a bit but got stuck, perhaps we can have a look during the next dev meeting. |
The order only part is only the first part, we need a way to add the actual dependency as dependency of the |
@bobot We already have this one :) dune/src/dune_engine/action_builder.mli Line 84 in 4bc7629
|
I'm not sure it is enough, because
|
I think we can use For example, consider this snippet of code: let if_then_else path_bool path_true path_false : string Action_builder.t =
let open Action_builder.O in
(* Declare some order-only dependencies at first *)
let* () =
Action_builder.goal
(Action_builder.paths [ path_bool; path_true; path_false ])
in
(* Now start depending on actual paths as needed. *)
let* bool = Action_builder.contents path_bool in
match bool with
| "true" -> Action_builder.contents path_true
| _ -> Action_builder.contents path_false I think this will create order-only dependencies for all three paths Does this make sense? (It's been a while since I looked at |
I think this example is too much simplified because only The code would be more similar to:
Perhaps my understand of |
It is sometimes useful to specify dependencies of a build action in two steps:
Before executing the action, specify the set of its possible dependencies P. The set P is used only for scheduling, i.e., everything in P must be built before running the action. Such dependencies are often called order-only dependencies.
After executing the action, specify the set of its actual dependencies A, where A must be a subset of P. These dependencies are used to determine when the action will need to be rebuilt.
Here are a couple of use-cases:
It is common to depend on all C headers in a project (i.e.
headers/*.h
), to make sure they are up-to-date, and then compile C sources usinggcc
with the flags-MMD -MF
to obtain the set of actual headers that were needed for compilation.A recently discussed use-case in OCaml is to improve build incrementality with respect to library dependencies. For example, if a library B depends on a library A, we can use order-only dependencies to ensure that all modules of A have been built before compiling modules of B, and then use
ocamldep
to find actual dependencies of each module of B, to avoid recompiling all B's modules whenever any module of A changes.Order-only dependencies are not new, for example, the Shake build system provides orderOnly and needed primitives to specify order-only and actual dependencies, respectively. See Section 3.5 of this paper for more details.
For now, this RFC only describes the idea but I'll update it with more details after we figure out how to add this feature to Dune.
The text was updated successfully, but these errors were encountered: