Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion bin/alias.ml
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,17 @@ let dep_on_alias_rec_multi_contexts ~dir:src_dir ~name ~contexts =
| true -> Action_builder.return ()
| false ->
let* load_dir =
let selected = !Dune_engine.Clflags.selected_context in
let hint_contexts =
match List.filter contexts ~f:(Context_name.equal selected) with
| [] ->
(match contexts with
| [] -> []
| ctx :: _ -> [ ctx ])
| ctxs -> ctxs
in
Action_builder.all
@@ List.map contexts ~f:(fun ctx ->
@@ List.map hint_contexts ~f:(fun ctx ->
let dir =
Source_tree.Dir.path dir
|> Path.Build.append_source (Context_name.build_dir ctx)
Expand Down
1 change: 1 addition & 0 deletions src/dune_engine/clflags.ml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ let display = ref Display.Quiet
let can_go_in_shared_cache_default = ref false
let diff_command = ref None
let wait_for_filesystem_clock = ref false
let selected_context = ref Context_name.default
3 changes: 3 additions & 0 deletions src/dune_engine/clflags.mli
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ val diff_command : string option ref
(** Wait for the filesystem clock to advance rather than dropping cached digest
entries *)
val wait_for_filesystem_clock : bool ref

(** The build context selected by the user on the command line *)
val selected_context : Context_name.t ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Alias hint generation should only use the selected build context in a
multi-context workspace. Aliases from other build contexts should not appear
as hints.

$ cat > dune-project << EOF
> (lang dune 3.17)
> EOF

$ cat > dune-workspace << EOF
> (lang dune 3.17)
> (context default)
> (context (default (name other)))
> EOF

$ cat > dune << EOF
> (rule
> (alias foo)
> (action (echo "foo"))
> (enabled_if (= %{context_name} "default")))
> (rule
> (alias foe)
> (action (echo "foe"))
> (enabled_if (= %{context_name} "other")))
> EOF

We have "foo" in the default context and "foe" in the "other" context. When
building a misspelled alias "@fou", hints should only come from the default
context, so only "foo" (not "foe") should be suggested.

$ dune build @fou
Error: Alias "fou" specified on the command line is empty.
It is not defined in . or any of its descendants.
Hint: did you mean fmt or foo?
[1]
Loading