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

Add %{toolchain} variable #4899

Merged
merged 1 commit into from
Sep 7, 2021
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
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Unreleased
----------

- Add a `%{toolchain}` expansion variable (#4899, fixes #3949, @rgrinberg)

- Include dependencies of executables when creating toplevels (either `dune
top` or `dune utop`) (#4882, fixes #4872, @Gopiancode)

Expand Down
4 changes: 4 additions & 0 deletions src/dune_engine/pform.ml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module Var = struct
| Test
| Corrected_suffix
| Inline_tests
| Toolchain

let compare : t -> t -> Ordering.t = Poly.compare

Expand Down Expand Up @@ -94,6 +95,7 @@ module Var = struct
| Test -> "Test"
| Corrected_suffix -> "Corrected_suffix"
| Inline_tests -> "Inline_tests"
| Toolchain -> "Toolchain"
in
Dyn.Variant (cstr, [])
end
Expand Down Expand Up @@ -285,6 +287,7 @@ let encode_to_latest_dune_lang_version t =
| Test -> Some "test"
| Corrected_suffix -> Some "corrected-suffix"
| Inline_tests -> Some "inline_tests"
| Toolchain -> Some "toolchain"
with
| None -> Pform_was_deleted
| Some name -> Success { name; payload = None })
Expand Down Expand Up @@ -469,6 +472,7 @@ module Env = struct
; ("input-file", since ~version:(1, 0) Var.Input_file)
; ("corrected-suffix", No_info Corrected_suffix)
; ("inline_tests", No_info Inline_tests)
; ("toolchains", since ~version:(3, 0) Var.Toolchain)
]
in
String.Map.of_list_exn (List.concat [ lowercased; uppercased; other ])
Expand Down
1 change: 1 addition & 0 deletions src/dune_engine/pform.mli
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module Var : sig
| Test
| Corrected_suffix
| Inline_tests
| Toolchain

val compare : t -> t -> Ordering.t

Expand Down
11 changes: 10 additions & 1 deletion src/dune_rules/expander.ml
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,16 @@ let expand_pform_gen ~(context : Context.t) ~bindings ~dir ~source
| Ccomp_type ->
static
(string
(Ocaml_config.Ccomp_type.to_string context.lib_config.ccomp_type)))
(Ocaml_config.Ccomp_type.to_string context.lib_config.ccomp_type))
| Toolchain ->
static
(string
(match context.findlib_toolchain with
| Some toolchain -> Context_name.to_string toolchain
| None ->
let loc = Dune_lang.Template.Pform.loc source in
User_error.raise ~loc
[ Pp.text "No toolchain defined for this context" ])))
| Macro (macro, s) -> (
match macro with
| Ocaml_config ->
Expand Down