Skip to content

Commit

Permalink
refactor(odoc): delay program resolution (ocaml#9196)
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <[email protected]>
  • Loading branch information
rgrinberg authored Nov 16, 2023
1 parent 0a48200 commit a03116f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/dune_rules/odoc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,13 @@ let odoc_base_flags sctx quiet build_dir =

let odoc_program sctx dir =
Super_context.resolve_program sctx ~dir "odoc" ~loc:None ~hint:"opam install odoc"
|> Action_builder.of_memo
;;

let run_odoc sctx ~dir command ~quiet ~flags_for args =
let build_dir = Super_context.context sctx |> Context.build_dir in
let open Memo.O in
let* program = odoc_program sctx build_dir in
let program = odoc_program sctx build_dir in
let+ base_flags =
match flags_for with
| None -> Memo.return Command.Args.empty
Expand All @@ -244,7 +245,7 @@ let run_odoc sctx ~dir command ~quiet ~flags_for args =
let deps = Action_builder.env_var "ODOC_SYNTAX" in
let open Action_builder.With_targets.O in
Action_builder.with_no_targets deps
>>> Command.run ~dir program [ A command; base_flags; S args ]
>>> Command.run_dyn_prog ~dir program [ A command; base_flags; S args ]
;;

let module_deps (m : Module.t) ~obj_dir ~(dep_graphs : Dep_graph.Ml_kind.t) =
Expand Down
2 changes: 1 addition & 1 deletion src/dune_rules/odoc.mli
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module Scope_key : sig
end

val lib_unique_name : Lib.t -> string
val odoc_program : Super_context.t -> Path.Build.t -> Action.Prog.t Memo.t
val odoc_program : Super_context.t -> Path.Build.t -> Action.Prog.t Action_builder.t

val check_mlds_no_dupes
: pkg:Dune_lang.Package_name.t
Expand Down
4 changes: 2 additions & 2 deletions src/dune_rules/odoc_new.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1059,11 +1059,11 @@ let external_module_deps_rule sctx ~all a =
let ctx = Super_context.context sctx in
let deps_file = Path.Build.set_extension (Artifact.odoc_file a) ~ext:".deps" in
let+ () =
let* odoc = Odoc.odoc_program sctx (Paths.root ctx ~all) in
let odoc = Odoc.odoc_program sctx (Paths.root ctx ~all) in
Super_context.add_rule
sctx
~dir:(Paths.root ctx ~all)
(Command.run
(Command.run_dyn_prog
odoc
~dir:(Path.parent_exn (Path.build deps_file))
~stdout_to:deps_file
Expand Down

0 comments on commit a03116f

Please sign in to comment.