Use toplevel env stanza from workspace file
This should be the top most env stanza when it's available Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
parent
c112516a67
commit
8cda4349fa
|
@ -26,7 +26,7 @@ type t =
|
|||
; for_host : t option
|
||||
; implicit : bool
|
||||
; build_dir : Path.t
|
||||
; env_node : Dune_env.Stanza.t option
|
||||
; env_nodes : Dune_env.Stanza.t list
|
||||
; path : Path.t list
|
||||
; toplevel_path : Path.t option
|
||||
; ocaml_bin : Path.t
|
||||
|
@ -131,7 +131,7 @@ let ocamlpath_sep =
|
|||
else
|
||||
Bin.path_sep
|
||||
|
||||
let create ~(kind : Kind.t) ~path ~env ~env_node ~name ~merlin ~targets
|
||||
let create ~(kind : Kind.t) ~path ~env ~env_nodes ~name ~merlin ~targets
|
||||
~profile () =
|
||||
let opam_var_cache = Hashtbl.create 128 in
|
||||
(match kind with
|
||||
|
@ -334,7 +334,7 @@ let create ~(kind : Kind.t) ~path ~env ~env_node ~name ~merlin ~targets
|
|||
; kind
|
||||
; profile
|
||||
; merlin
|
||||
; env_node
|
||||
; env_nodes
|
||||
; for_host = host
|
||||
; build_dir
|
||||
; path
|
||||
|
@ -410,11 +410,11 @@ let create ~(kind : Kind.t) ~path ~env ~env_node ~name ~merlin ~targets
|
|||
|
||||
let opam_config_var t var = opam_config_var ~env:t.env ~cache:t.opam_var_cache var
|
||||
|
||||
let default ?(merlin=true) ~env_node ~env ~targets () =
|
||||
create ~kind:Default ~path:Bin.path ~env ~env_node ~name:"default"
|
||||
let default ?(merlin=true) ~env_nodes ~env ~targets () =
|
||||
create ~kind:Default ~path:Bin.path ~env ~env_nodes ~name:"default"
|
||||
~merlin ~targets ()
|
||||
|
||||
let create_for_opam ?root ~env ~env_node ~targets ~profile ~switch ~name
|
||||
let create_for_opam ?root ~env ~env_nodes ~targets ~profile ~switch ~name
|
||||
?(merlin=false) () =
|
||||
match Bin.opam with
|
||||
| None -> Utils.program_not_found "opam"
|
||||
|
@ -452,16 +452,26 @@ let create_for_opam ?root ~env ~env_node ~targets ~profile ~switch ~name
|
|||
| Some s -> Bin.parse_path s
|
||||
in
|
||||
let env = Env.extend env ~vars in
|
||||
create ~kind:(Opam { root; switch }) ~profile ~targets ~path ~env ~env_node
|
||||
create ~kind:(Opam { root; switch }) ~profile ~targets ~path ~env ~env_nodes
|
||||
~name ~merlin ()
|
||||
|
||||
let create ?merlin ~env def =
|
||||
let create ?merlin ?workspace_env ~env def =
|
||||
let env_nodes =
|
||||
match workspace_env with
|
||||
| None -> Option.to_list
|
||||
| Some s ->
|
||||
begin function
|
||||
| None -> [s]
|
||||
| Some x -> [x; s]
|
||||
end
|
||||
in
|
||||
match (def : Workspace.Context.t) with
|
||||
| Default { targets; profile; env = env_node ; loc = _ } ->
|
||||
default ~env ~env_node ~profile ~targets ?merlin ()
|
||||
default ~env ~env_nodes:(env_nodes env_node) ~profile ~targets ?merlin ()
|
||||
| Opam { base = { targets ; profile ; env = env_node ; loc = _ }
|
||||
; name; switch; root; merlin = _ } ->
|
||||
create_for_opam ?root ~env_node ~env ~profile ~switch ~name ?merlin ~targets ()
|
||||
create_for_opam ?root ~env_nodes:(env_nodes env_node) ~env ~profile
|
||||
~switch ~name ?merlin ~targets ()
|
||||
|
||||
let which t s = which ~cache:t.which_cache ~path:t.path s
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ type t =
|
|||
build_dir : Path.t
|
||||
|
||||
; (** env node that this context was initialized with *)
|
||||
env_node : Dune_env.Stanza.t option
|
||||
env_nodes : Dune_env.Stanza.t list
|
||||
|
||||
; (** [PATH] *)
|
||||
path : Path.t list
|
||||
|
@ -125,6 +125,7 @@ val compare : t -> t -> Ordering.t
|
|||
|
||||
val create
|
||||
: ?merlin:bool
|
||||
-> ?workspace_env:Dune_env.Stanza.t
|
||||
-> env:Env.t
|
||||
-> Workspace.Context.t
|
||||
-> t list Fiber.t
|
||||
|
|
|
@ -612,18 +612,24 @@ let create
|
|||
}
|
||||
in
|
||||
let context_env_node = lazy (
|
||||
let config =
|
||||
match context.env_node with
|
||||
| Some s -> s
|
||||
| None -> { loc = Loc.none; rules = [] }
|
||||
in
|
||||
let make ~inherit_from ~config =
|
||||
{ Env_node.
|
||||
dir = context.build_dir
|
||||
; inherit_from = None
|
||||
; scope = Scope.DB.find_by_dir scopes context.build_dir
|
||||
; config
|
||||
; ocaml_flags = None
|
||||
; inherit_from
|
||||
; config
|
||||
}
|
||||
in
|
||||
match context.env_nodes with
|
||||
| [] ->
|
||||
make ~config:{ loc = Loc.none; rules = [] } ~inherit_from:None
|
||||
| [config] ->
|
||||
make ~config ~inherit_from:None
|
||||
| [context; workspace] ->
|
||||
make ~config:context
|
||||
~inherit_from:(Some (lazy (make ~inherit_from:None ~config:workspace)))
|
||||
| _::_::_::_ -> assert false
|
||||
) in
|
||||
List.iter stanzas
|
||||
~f:(fun { Dir_with_jbuild. ctx_dir; scope; stanzas; _ } ->
|
||||
|
|
Loading…
Reference in New Issue