Skip to content

Commit

Permalink
feature: allow arch_sixtyfour in enabled_if
Browse files Browse the repository at this point in the history
Signed-off-by: Ali Caglayan <alizter@gmail.com>
  • Loading branch information
Alizter committed Jul 7, 2023
1 parent 9c1c460 commit 5704f23
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ Unreleased
- Add `dune build --dump-gc-stats FILE` argument to dump Garbage Collection
stats to a named file. (#8072, @Alizter)

- `enabled_if` now supports `arch_sixtyfour` variable (#8023, fixes #7997,
@Alizter)

3.9.0 (2023-06-28)
------------------

Expand Down
2 changes: 2 additions & 0 deletions src/dune_rules/enabled_if.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ let common_vars_list =
; "profile"
; "ocaml_version"
; "context_name"
; "arch_sixtyfour"
]

let common_vars ~since =
Expand All @@ -26,6 +27,7 @@ let common_vars ~since =
~f:(fun var ->
match var with
| "context_name" -> (var, (2, 7))
| "arch_sixtyfour" -> (var, (3, 10))
| _ -> (var, since))
common_vars_list)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(executable
(name hello)
(enabled_if
(= %{arch_sixtyfour} %{arch_sixtyfour})))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let () = Printf.printf "Hello, World!\n"
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Testing %{arch_sixtyfour} in enabled_if

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

$ dune exec -- ./hello.exe
Hello, World!

Testing the version guard

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

$ dune exec -- ./hello.exe
File "dune", line 4, characters 5-22:
4 | (= %{arch_sixtyfour} %{arch_sixtyfour})))
^^^^^^^^^^^^^^^^^
Error: %{arch_sixtyfour} is only available since version 3.10 of the dune
language. Please update your dune-project file to have (lang dune 3.10).
[1]
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ The next ones use forbidden variables For dune 2.3 -> 2.5 it is a warning
3 | (enabled_if (<> %{project_root} "")))
^^^^^^^^^^^^^^^
Warning: Only architecture, system, model, os_type, ccomp_type, profile,
ocaml_version and context_name variables are allowed in this 'enabled_if'
field. If you think that project_root should also be allowed, please file an
issue about it.
ocaml_version, context_name and arch_sixtyfour variables are allowed in this
'enabled_if' field. If you think that project_root should also be allowed,
please file an issue about it.
bar

For dune >= 2.6 it is an error
Expand All @@ -22,7 +22,7 @@ For dune >= 2.6 it is an error
3 | (enabled_if (<> %{project_root} "")))
^^^^^^^^^^^^^^^
Error: Only architecture, system, model, os_type, ccomp_type, profile,
ocaml_version and context_name variables are allowed in this 'enabled_if'
field. If you think that project_root should also be allowed, please file an
issue about it.
ocaml_version, context_name and arch_sixtyfour variables are allowed in this
'enabled_if' field. If you think that project_root should also be allowed,
please file an issue about it.
[1]
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tests for enabled_if in install stanza using forbidden variable.
6 | (enabled_if (= %{project_root} ""))
^^^^^^^^^^^^^^^
Error: Only architecture, system, model, os_type, ccomp_type, profile,
ocaml_version and context_name variables are allowed in this 'enabled_if'
field. If you think that project_root should also be allowed, please file an
issue about it.
ocaml_version, context_name and arch_sixtyfour variables are allowed in this
'enabled_if' field. If you think that project_root should also be allowed,
please file an issue about it.
[1]

0 comments on commit 5704f23

Please sign in to comment.