diff --git a/CHANGES.md b/CHANGES.md index 27c6ecba7e16..c89a55ebf07d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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) diff --git a/src/dune_rules/enabled_if.ml b/src/dune_rules/enabled_if.ml index dd5d8d85c83f..83270f03ac23 100644 --- a/src/dune_rules/enabled_if.ml +++ b/src/dune_rules/enabled_if.ml @@ -18,6 +18,7 @@ let common_vars_list = ; "profile" ; "ocaml_version" ; "context_name" + ; "arch_sixtyfour" ] let common_vars ~since = @@ -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) diff --git a/test/blackbox-tests/test-cases/enabled_if/eif-arch_sixtyfour.t/hello.ml b/test/blackbox-tests/test-cases/enabled_if/eif-arch_sixtyfour.t/hello.ml new file mode 100644 index 000000000000..0b94899688b6 --- /dev/null +++ b/test/blackbox-tests/test-cases/enabled_if/eif-arch_sixtyfour.t/hello.ml @@ -0,0 +1 @@ +let () = Printf.printf "Hello, World!\n" diff --git a/test/blackbox-tests/test-cases/enabled_if/eif-arch_sixtyfour.t/run.t b/test/blackbox-tests/test-cases/enabled_if/eif-arch_sixtyfour.t/run.t new file mode 100644 index 000000000000..b2ba6784b88e --- /dev/null +++ b/test/blackbox-tests/test-cases/enabled_if/eif-arch_sixtyfour.t/run.t @@ -0,0 +1,37 @@ +Testing %{arch_sixtyfour} in enabled_if + + $ cat > dune-project << EOF + > (lang dune 3.9) + > EOF + +This will always build + $ cat > dune << EOF + > (executable + > (name hello) + > (enabled_if (= %{arch_sixtyfour} %{arch_sixtyfour}))) + > EOF + + $ dune exec -- ./hello.exe + Hello, World! + +Testing the version guard + + $ cat > dune-project << EOF + > (lang dune 3.8) + > EOF + +The parser does not understand blang expressions with unknown variables and can +only guard on single variables. + $ cat > dune << EOF + > (executable + > (name hello) + > (enabled_if %{arch_sixtyfour})) + > EOF + + $ dune exec -- ./hello.exe + 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]