Skip to content

Commit 23f275c

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. The dune lang version would need to be bumped for this to work, though. Signed-off-by: Puneeth Chaganti <punchagan@muse-amuse.in>
1 parent 0e68eb2 commit 23f275c

2 files changed

Lines changed: 9 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: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,13 @@ 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
498+
let allowed_common_vars = Enabled_if.common_vars ~since:(2, 3) in
499+
let allowed_vars =
500+
if Dune_lang.Syntax.Version.Infix.(dune_version >= (3, 25))
501+
then Enabled_if.Any
502+
else allowed_common_vars
503+
in
499504
Enabled_if.decode ~allowed_vars ~is_error ~since:(Some (2, 3)) ()
500505
in
501506
fun names ~multi ->

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

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,12 @@ stanza in older dune lang versions:
2626

2727
Check that the executable is correctly enabled:
2828

29-
$ make_dune_project 3.24
29+
$ make_dune_project 3.25
3030
$ dune exec ./main.exe
31-
File "dune", line 5, characters 16-50:
32-
5 | (enabled_if (= %{read:./config/enable_executable} "true")))
33-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
34-
Error: Only architecture, system, model, os_type, ccomp_type, profile,
35-
ocaml_version, context_name, arch_sixtyfour and env variables are allowed in
36-
this 'enabled_if' field. Please upgrade your dune language to at least 3.15.
37-
[1]
31+
hello
3832

3933
Check that the executable is correctly disabled:
4034

4135
$ dune exec ./disabled.exe
42-
File "dune", line 5, characters 16-50:
43-
5 | (enabled_if (= %{read:./config/enable_executable} "true")))
44-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
45-
Error: Only architecture, system, model, os_type, ccomp_type, profile,
46-
ocaml_version, context_name, arch_sixtyfour and env variables are allowed in
47-
this 'enabled_if' field. Please upgrade your dune language to at least 3.15.
36+
Error: Program './disabled.exe' not found!
4837
[1]

0 commit comments

Comments
 (0)