forked from ocaml/dune
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(engine): move some dap code into separate module (ocaml#10770)
This code has been eliminated in the JS fork. Action execution is easier to sync if the removed bits live in a separate file. Signed-off-by: Rudi Grinberg <[email protected]>
- Loading branch information
1 parent
0bcec48
commit 2443bd5
Showing
3 changed files
with
58 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
open Import | ||
module DAP = Dune_action_plugin.Private.Protocol | ||
|
||
let to_dune_dep_set = | ||
let of_DAP_dep ~loc ~working_dir : DAP.Dependency.t -> Dep.t = | ||
let to_dune_path = Path.relative working_dir in | ||
function | ||
| File fn -> Dep.file (to_dune_path fn) | ||
| Directory dir -> | ||
let dir = to_dune_path dir in | ||
let selector = File_selector.of_glob ~dir Glob.universal in | ||
Dep.file_selector selector | ||
| Glob { path; glob } -> | ||
let dir = to_dune_path path in | ||
let glob = Glob.of_string_exn loc glob in | ||
let selector = File_selector.of_glob ~dir glob in | ||
Dep.file_selector selector | ||
in | ||
fun set ~loc ~working_dir -> | ||
DAP.Dependency.Set.to_list_map set ~f:(of_DAP_dep ~loc ~working_dir) | ||
|> Dep.Set.of_list | ||
;; | ||
|
||
type done_or_more_deps = | ||
| Done | ||
(* This code assumes that there can be at most one 'dynamic-run' within single | ||
action. [DAP.Dependency.t] stores relative paths so name clash would be | ||
possible if multiple 'dynamic-run' would be executed in different | ||
subdirectories that contains targets having the same name. *) | ||
| Need_more_deps of (DAP.Dependency.Set.t * Dep.Set.t) | ||
|
||
let done_or_more_deps_union x y = | ||
match x, y with | ||
| Done, Done -> Done | ||
| Done, Need_more_deps x | Need_more_deps x, Done -> Need_more_deps x | ||
| Need_more_deps (deps1, dyn_deps1), Need_more_deps (deps2, dyn_deps2) -> | ||
Need_more_deps | ||
(DAP.Dependency.Set.union deps1 deps2, Dep.Set.union dyn_deps1 dyn_deps2) | ||
;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
open Import | ||
module DAP := Dune_action_plugin.Private.Protocol | ||
|
||
type done_or_more_deps = | ||
| Done | ||
(* This code assumes that there can be at most one 'dynamic-run' within single | ||
action. [DAP.Dependency.t] stores relative paths so name clash would be | ||
possible if multiple 'dynamic-run' would be executed in different | ||
subdirectories that contains targets having the same name. *) | ||
| Need_more_deps of (DAP.Dependency.Set.t * Dep.Set.t) | ||
|
||
val to_dune_dep_set : DAP.Dependency.Set.t -> loc:Loc.t -> working_dir:Path.t -> Dep.Set.t | ||
val done_or_more_deps_union : done_or_more_deps -> done_or_more_deps -> done_or_more_deps |