Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: allow arch_sixtyfour in enabled_if #8023

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/changes/8023.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

- `enabled_if` now supports `arch_sixtyfour` variable (#8023, fixes #7997,
@Alizter)
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"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how versioning is supposed to work here. For example, (rule) uses ~allowed_vars:Any so this means that it will accept arch_sixtyfour even with lang dune 1.4 (this affects context_name too). @rgrinberg do you know how this is supposed to work?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe that is intentional to not restrict the user from writing a rule?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's not correct. it means a dune file can be valid or not depending on the version of the dune binary, which we try to avoid.

]
;;

Expand All @@ -27,6 +28,7 @@ let common_vars ~since =
~f:(fun var ->
match var with
| "context_name" -> var, (2, 7)
| "arch_sixtyfour" -> var, (3, 11)
| _ -> 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.11)
> EOF

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

Testing the version guard

$ cat > dune-project << EOF
> (lang dune 3.10)
> 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.11 of the dune
language. Please update your dune-project file to have (lang dune 3.11).
[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]