diff --git a/src/context.ml b/src/context.ml index 2a91fb4d..d005a9a6 100644 --- a/src/context.ml +++ b/src/context.ml @@ -26,7 +26,7 @@ type t = ; for_host : t option ; implicit : bool ; build_dir : Path.t - ; env_node : Shared_stanza.Env.t option + ; env_node : Dune_env.Stanza.t option ; path : Path.t list ; toplevel_path : Path.t option ; ocaml_bin : Path.t diff --git a/src/context.mli b/src/context.mli index af23a195..7cf4fe37 100644 --- a/src/context.mli +++ b/src/context.mli @@ -51,7 +51,7 @@ type t = build_dir : Path.t ; (** env node that this context was initialized with *) - env_node : Shared_stanza.Env.t option + env_node : Dune_env.Stanza.t option ; (** [PATH] *) path : Path.t list diff --git a/src/shared_stanza.ml b/src/dune_env.ml similarity index 82% rename from src/shared_stanza.ml rename to src/dune_env.ml index dc8b772a..1227d7d7 100644 --- a/src/shared_stanza.ml +++ b/src/dune_env.ml @@ -1,9 +1,11 @@ -open Import -open Stanza.Of_sexp +type stanza = Stanza.t = .. -let field_oslu name = Ordered_set_lang.Unexpanded.field name +module Stanza = struct + open Import + open Stanza.Of_sexp + + let field_oslu name = Ordered_set_lang.Unexpanded.field name -module Env = struct type config = { flags : Ordered_set_lang.Unexpanded.t ; ocamlc_flags : Ordered_set_lang.Unexpanded.t @@ -40,7 +42,8 @@ module Env = struct loc >>= fun loc -> repeat rule >>| fun rules -> { loc; rules } + end -type Stanza.t += - | Env of Env.t +type stanza += + | T of Stanza.t diff --git a/src/shared_stanza.mli b/src/dune_env.mli similarity index 81% rename from src/shared_stanza.mli rename to src/dune_env.mli index 1f6f2a3a..afe45c3a 100644 --- a/src/shared_stanza.mli +++ b/src/dune_env.mli @@ -1,6 +1,8 @@ open Import -module Env : sig +type stanza = Stanza.t = .. + +module Stanza : sig type config = { flags : Ordered_set_lang.Unexpanded.t ; ocamlc_flags : Ordered_set_lang.Unexpanded.t @@ -19,5 +21,5 @@ module Env : sig val t : t Sexp.Of_sexp.t end -type Stanza.t += - | Env of Env.t +type stanza += + | T of Stanza.t diff --git a/src/jbuild.ml b/src/jbuild.ml index dd7af3d0..be30a42a 100644 --- a/src/jbuild.ml +++ b/src/jbuild.ml @@ -1592,6 +1592,7 @@ module Stanzas = struct (let%map () = Syntax.since Stanza.syntax (1, 0) and t = Tests.single in [Tests t]) + ; "env", Dune_env.Stanza.t >>| fun x -> [Dune_env.T x] ] let jbuild_parser = @@ -1663,7 +1664,7 @@ module Stanzas = struct in match List.filter_map stanzas - ~f:(function Shared_stanza.Env e -> Some e | _ -> None) + ~f:(function Dune_env.T e -> Some e | _ -> None) with | _ :: e :: _ -> Loc.fail e.loc "The 'env' stanza cannot appear more than once" diff --git a/src/super_context.ml b/src/super_context.ml index 816ccd74..f0992784 100644 --- a/src/super_context.ml +++ b/src/super_context.ml @@ -1,5 +1,5 @@ open Import -open Shared_stanza +(* open Dune_env.Stanza *) open Jbuild module A = Action @@ -29,7 +29,7 @@ module Env_node = struct { dir : Path.t ; inherit_from : t Lazy.t option ; scope : Scope.t - ; config : Env.t + ; config : Dune_env.Stanza.t ; mutable ocaml_flags : Ocaml_flags.t option } end @@ -449,7 +449,7 @@ end = struct in let flags = match List.find_map node.config.rules ~f:(fun (pat, cfg) -> - match (pat : Env.pattern), profile t with + match (pat : Dune_env.Stanza.pattern), profile t with | Any, _ -> Some cfg | Profile a, b -> Option.some_if (a = b) cfg) with @@ -629,7 +629,7 @@ let create List.iter stanzas ~f:(fun { Dir_with_jbuild. ctx_dir; scope; stanzas; _ } -> List.iter stanzas ~f:(function - | Env config -> + | Dune_env.T config -> let inherit_from = if ctx_dir = Scope.root scope then context_env_node diff --git a/src/workspace.ml b/src/workspace.ml index 11e03412..f331d5fa 100644 --- a/src/workspace.ml +++ b/src/workspace.ml @@ -45,11 +45,11 @@ module Context = struct { loc : Loc.t ; profile : string ; targets : Target.t list - ; env : Shared_stanza.Env.t option + ; env : Dune_env.Stanza.t option } let t ~profile = - field_o "env" Shared_stanza.Env.t >>= fun env -> + field_o "env" Dune_env.Stanza.t >>= fun env -> field "targets" (list Target.t) ~default:[Target.Native] >>= fun targets -> field "profile" string ~default:profile diff --git a/src/workspace.mli b/src/workspace.mli index fb891d7a..f3d73ebe 100644 --- a/src/workspace.mli +++ b/src/workspace.mli @@ -13,7 +13,7 @@ module Context : sig { loc : Loc.t ; profile : string ; targets : Target.t list - ; env : Shared_stanza.Env.t option + ; env : Dune_env.Stanza.t option } end module Opam : sig