diff --git a/src/dune_lang/ordered_set_lang.ml b/src/dune_lang/ordered_set_lang.ml index 73d968e6ca3d..d0f52277e93f 100644 --- a/src/dune_lang/ordered_set_lang.ml +++ b/src/dune_lang/ordered_set_lang.ml @@ -411,7 +411,13 @@ module Unexpanded = struct let* sexp = let* path = expand_template fn ~mode:Single in let path = Value.to_path path ?error_loc:(Some loc) ~dir in - Action_builder.read_sexp path + Action_builder.push_stack_frame + ~human_readable_description:(fun () -> + Pp.textf + "(:include %s) at %s" + (Path.to_string path) + (Loc.to_file_colon_line loc)) + (fun () -> Action_builder.read_sexp path) in let t = Decoder.parse decode context sexp in expand t.ast ~allow_include:false diff --git a/src/dune_lang/ordered_set_lang_intf.ml b/src/dune_lang/ordered_set_lang_intf.ml index 71629d2ebbef..8980a6dcd71c 100644 --- a/src/dune_lang/ordered_set_lang_intf.ml +++ b/src/dune_lang/ordered_set_lang_intf.ml @@ -46,6 +46,11 @@ module type Action_builder = sig val all : 'a t list -> 'a list t val read_sexp : Path.t -> Dune_sexp.Ast.t t + val push_stack_frame + : human_readable_description:(unit -> User_message.Style.t Pp.t) + -> (unit -> 'a t) + -> 'a t + module O : sig val ( let+ ) : 'a t -> ('a -> 'b) -> 'b t val ( and+ ) : 'a t -> 'b t -> ('a * 'b) t diff --git a/src/dune_rules/ml_sources.ml b/src/dune_rules/ml_sources.ml index 62976e1d0554..df2b6cda2e67 100644 --- a/src/dune_rules/ml_sources.ml +++ b/src/dune_rules/ml_sources.ml @@ -469,9 +469,6 @@ let make ~include_subdirs:(loc_include_subdirs, (include_subdirs : Dune_file.Include_subdirs.t)) ~dirs = - Memo.push_stack_frame ~human_readable_description:(fun () -> - Pp.textf "Finding source files in directory %s" (Path.Build.to_string dir)) - @@ fun () -> let+ modules_of_stanzas = let modules = let dialects = Dune_project.dialects project in diff --git a/src/dune_rules/modules_field_evaluator.ml b/src/dune_rules/modules_field_evaluator.ml index ff82d31a459d..5707074434dc 100644 --- a/src/dune_rules/modules_field_evaluator.ml +++ b/src/dune_rules/modules_field_evaluator.ml @@ -405,7 +405,7 @@ let eval = let open Memo.O in Memo.push_stack_frame ~human_readable_description:(fun () -> - Pp.textf "Evaluating modules field in directory %s" (Path.Build.to_string src_dir)) + Pp.textf "(modules) field at %s" (Loc.to_file_colon_line stanza_loc)) @@ fun () -> let* modules0 = eval0 ~expander ~loc:stanza_loc ~all_modules ~standard:all_modules settings.modules diff --git a/test/blackbox-tests/test-cases/modules-expansion.t b/test/blackbox-tests/test-cases/modules-expansion.t index cb0ff86479bc..a873e8d91a1c 100644 --- a/test/blackbox-tests/test-cases/modules-expansion.t +++ b/test/blackbox-tests/test-cases/modules-expansion.t @@ -151,10 +151,9 @@ Interaction with `(include_subdirs)` when the dependencies are in the subtree: $ dune build --display short Error: Dependency cycle between: - Finding source files in directory _build/default + (modules) field at dune:2 -> %{read-lines:gen/lst} at dune:4 - -> Evaluating modules field in directory _build/default - -> Finding source files in directory _build/default + -> (modules) field at dune:2 [1] Let's move the gen subdirectory out of the hierarchy: @@ -197,9 +196,9 @@ appears. We need to handle this cycle gracefully and report it to the user. $ dune exec ./mod.exe Error: Dependency cycle between: - Finding source files in directory _build/default - -> Evaluating modules field in directory _build/default - -> Finding source files in directory _build/default + (modules) field at dune:2 + -> (:include _build/default/lst) at dune:2 + -> (modules) field at dune:2 [1] Let's do one example with a generated source file: