From 1fa5da78c5fd53e1d53b21d2d547d9e56384a816 Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Thu, 21 Mar 2024 17:36:04 -0700 Subject: [PATCH] fix: read the processed file in Ocamldep.read_immediate_deps_of Signed-off-by: Antonio Nuno Monteiro --- src/dune_rules/ocamldep.ml | 9 ++++++--- .../test-cases/melange/unexpected-ocamldep-output.t | 5 ----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/dune_rules/ocamldep.ml b/src/dune_rules/ocamldep.ml index a4c06c83c7e2..3c07e3d4c2a2 100644 --- a/src/dune_rules/ocamldep.ml +++ b/src/dune_rules/ocamldep.ml @@ -153,13 +153,16 @@ let read_deps_of ~obj_dir ~modules ~ml_kind unit = ;; let read_immediate_deps_of ~obj_dir ~modules ~ml_kind unit = - match Module.source ~ml_kind unit with + match + let ml = Module.ml_source unit in + Module.file ml ~ml_kind + with | None -> Action_builder.return [] - | Some source -> + | Some file -> let ocamldep_output = Obj_dir.Module.dep obj_dir (Immediate (unit, ml_kind)) in Action_builder.lines_of (Path.build ocamldep_output) |> Action_builder.map ~f:(fun lines -> - parse_deps_exn ~file:(Module.File.path source) lines + parse_deps_exn ~file lines |> parse_module_names ~dir:(Obj_dir.dir obj_dir) ~unit ~modules) |> Action_builder.memoize (Path.Build.to_string ocamldep_output) ;; diff --git a/test/blackbox-tests/test-cases/melange/unexpected-ocamldep-output.t b/test/blackbox-tests/test-cases/melange/unexpected-ocamldep-output.t index 2cbaf40dd96c..42202ba94f98 100644 --- a/test/blackbox-tests/test-cases/melange/unexpected-ocamldep-output.t +++ b/test/blackbox-tests/test-cases/melange/unexpected-ocamldep-output.t @@ -30,9 +30,4 @@ file after any dialects have run > let name = "Zoe" > EOF $ dune build @mel - Error: ocamldep returned unexpected output for _build/default/lib/foo.myd: - > lib/foo.myd.ml: Bar - -> required by _build/default/output/lib/foo.js - -> required by alias mel - [1]