Skip to content

Commit 62332bd

Browse files
committed
executables: Allow any vars in enabled_if for executables
We allow any vars in enabled_if within the library stanza, but only common_vars within the executable stanza. This commit fixes that and allows any vars within the executable stanza too. Signed-off-by: Puneeth Chaganti <punchagan@muse-amuse.in>
1 parent 204c0d1 commit 62332bd

2 files changed

Lines changed: 3 additions & 15 deletions

File tree

  • src/dune_rules/stanzas
  • test/blackbox-tests/test-cases/enabled_if/enabled_if-exec-read.t

src/dune_rules/stanzas/executables.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,9 +494,8 @@ let common =
494494
fname)
495495
and+ project_root = Dune_project.get_exn () >>| Dune_project.root
496496
and+ enabled_if =
497-
let allowed_vars = Enabled_if.common_vars ~since:(2, 3) in
498497
let is_error = Dune_lang.Syntax.Version.Infix.(dune_version >= (2, 6)) in
499-
Enabled_if.decode ~allowed_vars ~is_error ~since:(Some (2, 3)) ()
498+
Enabled_if.decode ~allowed_vars:Any ~is_error ~since:(Some (2, 3)) ()
500499
in
501500
fun names ~multi ->
502501
let has_public_name = Names.has_public_name names in

test/blackbox-tests/test-cases/enabled_if/enabled_if-exec-read.t/run.t

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,10 @@ Test that `enabled_if` fields work as expected for executables with read pform.
33
Check that the executable is correctly enabled:
44

55
$ dune exec ./main.exe
6-
File "dune", line 5, characters 16-50:
7-
5 | (enabled_if (= %{read:./config/enable_executable} "true")))
8-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9-
Error: Only architecture, system, model, os_type, ccomp_type, profile,
10-
ocaml_version, context_name, arch_sixtyfour and env variables are allowed in
11-
this 'enabled_if' field. Please upgrade your dune language to at least 3.15.
12-
[1]
6+
hello
137

148
Check that the executable is correctly disabled:
159

1610
$ dune exec ./disabled.exe
17-
File "dune", line 5, characters 16-50:
18-
5 | (enabled_if (= %{read:./config/enable_executable} "true")))
19-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20-
Error: Only architecture, system, model, os_type, ccomp_type, profile,
21-
ocaml_version, context_name, arch_sixtyfour and env variables are allowed in
22-
this 'enabled_if' field. Please upgrade your dune language to at least 3.15.
11+
Error: Program './disabled.exe' not found!
2312
[1]

0 commit comments

Comments
 (0)