From a95c7724aa7d5252bf8a5acabf5f5a76521d02f5 Mon Sep 17 00:00:00 2001 From: Ali Caglayan Date: Wed, 21 Jun 2023 18:01:15 +0200 Subject: [PATCH] feature: allow arch_sixtyfour in enabled_if Signed-off-by: Ali Caglayan --- CHANGES.md | 3 ++ src/dune_rules/enabled_if.ml | 2 ++ .../enabled_if/eif-arch_sixtyfour.t/dune | 4 +++ .../enabled_if/eif-arch_sixtyfour.t/hello.ml | 1 + .../enabled_if/eif-arch_sixtyfour.t/run.t | 31 +++++++++++++++++++ 5 files changed, 41 insertions(+) create mode 100644 test/blackbox-tests/test-cases/enabled_if/eif-arch_sixtyfour.t/dune create mode 100644 test/blackbox-tests/test-cases/enabled_if/eif-arch_sixtyfour.t/hello.ml create mode 100644 test/blackbox-tests/test-cases/enabled_if/eif-arch_sixtyfour.t/run.t diff --git a/CHANGES.md b/CHANGES.md index 27c6ecba7e16..46a89ae1e6d5 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/dune b/test/blackbox-tests/test-cases/enabled_if/eif-arch_sixtyfour.t/dune new file mode 100644 index 000000000000..7e52945737e4 --- /dev/null +++ b/test/blackbox-tests/test-cases/enabled_if/eif-arch_sixtyfour.t/dune @@ -0,0 +1,4 @@ +(executable + (name hello) + (enabled_if + (= %{arch_sixtyfour} %{arch_sixtyfour}))) 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..0bb98ca8c5d8 --- /dev/null +++ b/test/blackbox-tests/test-cases/enabled_if/eif-arch_sixtyfour.t/run.t @@ -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.