From 57c799c7e6f685cbb2fd0b2639c30bb4e9cc3bd3 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 --- doc/changes/8023.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 | 22 +++++++++++++++++++ .../enabled_if/eif-exec-forbidden_var.t/run.t | 12 +++++----- .../eif-install-forbidden_var.t/run.t | 6 ++--- 7 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 doc/changes/8023.md 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/doc/changes/8023.md b/doc/changes/8023.md new file mode 100644 index 000000000000..a042cd8c7861 --- /dev/null +++ b/doc/changes/8023.md @@ -0,0 +1,3 @@ + +- `enabled_if` now supports `arch_sixtyfour` variable (#8023, fixes #7997, + @Alizter) \ No newline at end of file diff --git a/src/dune_rules/enabled_if.ml b/src/dune_rules/enabled_if.ml index fe9f06a1983f..1bcd31a69a53 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" ] ;; @@ -27,6 +28,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) ;; 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..777b5f44290c --- /dev/null +++ b/test/blackbox-tests/test-cases/enabled_if/eif-arch_sixtyfour.t/run.t @@ -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] diff --git a/test/blackbox-tests/test-cases/enabled_if/eif-exec-forbidden_var.t/run.t b/test/blackbox-tests/test-cases/enabled_if/eif-exec-forbidden_var.t/run.t index dc37336201ae..34501f0f02b0 100644 --- a/test/blackbox-tests/test-cases/enabled_if/eif-exec-forbidden_var.t/run.t +++ b/test/blackbox-tests/test-cases/enabled_if/eif-exec-forbidden_var.t/run.t @@ -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 @@ -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] diff --git a/test/blackbox-tests/test-cases/enabled_if/eif-install-forbidden_var.t/run.t b/test/blackbox-tests/test-cases/enabled_if/eif-install-forbidden_var.t/run.t index a3c62dc62bb5..c075f3a6e46c 100644 --- a/test/blackbox-tests/test-cases/enabled_if/eif-install-forbidden_var.t/run.t +++ b/test/blackbox-tests/test-cases/enabled_if/eif-install-forbidden_var.t/run.t @@ -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]