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 Jun 22, 2023
1 parent aa75e75 commit a95c772
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Unreleased
- Add `dune show` command group which is an alias of `dune describe`. (#7946,
@Alizter)

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

- Include source tree scans in the traces produced by `--trace-file` (#7937,
@rgrinberg)

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, 9))
| _ -> (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,31 @@
Testing %{arch_sixtyfour} in enabled_if

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

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

Testing the version guard

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

$ dune exec -- ./hello.exe
File "dune", line 4, characters 2-41:
4 | (= %{arch_sixtyfour} %{arch_sixtyfour})))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Unexpected list
[1]

The error message is not ideal. It should say something like this instead:

File "dune", line 3, characters 13-30:
3 | (enabled_if %{arch_sixtyfour}))
Error: %{arch_sixtyfour} is only available since version 3.9 of the dune
language. Please update your dune-project file to have (lang dune 3.9).
[1]

However, for now, the version guard works.

0 comments on commit a95c772

Please sign in to comment.