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
|
; for_host : t option
|
||||||
; implicit : bool
|
; implicit : bool
|
||||||
; build_dir : Path.t
|
; build_dir : Path.t
|
||||||
; env_node : Dune_env.Stanza.t option
|
; env_nodes : Dune_env.Stanza.t list
|
||||||
; path : Path.t list
|
; path : Path.t list
|
||||||
; toplevel_path : Path.t option
|
; toplevel_path : Path.t option
|
||||||
; ocaml_bin : Path.t
|
; ocaml_bin : Path.t
|
||||||
|
@ -131,7 +131,7 @@ let ocamlpath_sep =
|
||||||
else
|
else
|
||||||
Bin.path_sep
|
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 () =
|
~profile () =
|
||||||
let opam_var_cache = Hashtbl.create 128 in
|
let opam_var_cache = Hashtbl.create 128 in
|
||||||
(match kind with
|
(match kind with
|
||||||
|
@ -334,7 +334,7 @@ let create ~(kind : Kind.t) ~path ~env ~env_node ~name ~merlin ~targets
|
||||||
; kind
|
; kind
|
||||||
; profile
|
; profile
|
||||||
; merlin
|
; merlin
|
||||||
; env_node
|
; env_nodes
|
||||||
; for_host = host
|
; for_host = host
|
||||||
; build_dir
|
; build_dir
|
||||||
; path
|
; 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 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 () =
|
let default ?(merlin=true) ~env_nodes ~env ~targets () =
|
||||||
create ~kind:Default ~path:Bin.path ~env ~env_node ~name:"default"
|
create ~kind:Default ~path:Bin.path ~env ~env_nodes ~name:"default"
|
||||||
~merlin ~targets ()
|
~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) () =
|
?(merlin=false) () =
|
||||||
match Bin.opam with
|
match Bin.opam with
|
||||||
| None -> Utils.program_not_found "opam"
|
| 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
|
| Some s -> Bin.parse_path s
|
||||||
in
|
in
|
||||||
let env = Env.extend env ~vars 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 ()
|
~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
|
match (def : Workspace.Context.t) with
|
||||||
| Default { targets; profile; env = env_node ; loc = _ } ->
|
| 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 = _ }
|
| Opam { base = { targets ; profile ; env = env_node ; loc = _ }
|
||||||
; name; switch; root; merlin = _ } ->
|
; 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
|
let which t s = which ~cache:t.which_cache ~path:t.path s
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ type t =
|
||||||
build_dir : Path.t
|
build_dir : Path.t
|
||||||
|
|
||||||
; (** env node that this context was initialized with *)
|
; (** 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 : Path.t list
|
path : Path.t list
|
||||||
|
@ -125,6 +125,7 @@ val compare : t -> t -> Ordering.t
|
||||||
|
|
||||||
val create
|
val create
|
||||||
: ?merlin:bool
|
: ?merlin:bool
|
||||||
|
-> ?workspace_env:Dune_env.Stanza.t
|
||||||
-> env:Env.t
|
-> env:Env.t
|
||||||
-> Workspace.Context.t
|
-> Workspace.Context.t
|
||||||
-> t list Fiber.t
|
-> t list Fiber.t
|
||||||
|
|
|
@ -612,18 +612,24 @@ let create
|
||||||
}
|
}
|
||||||
in
|
in
|
||||||
let context_env_node = lazy (
|
let context_env_node = lazy (
|
||||||
let config =
|
let make ~inherit_from ~config =
|
||||||
match context.env_node with
|
{ Env_node.
|
||||||
| Some s -> s
|
dir = context.build_dir
|
||||||
| None -> { loc = Loc.none; rules = [] }
|
; scope = Scope.DB.find_by_dir scopes context.build_dir
|
||||||
|
; ocaml_flags = None
|
||||||
|
; inherit_from
|
||||||
|
; config
|
||||||
|
}
|
||||||
in
|
in
|
||||||
{ Env_node.
|
match context.env_nodes with
|
||||||
dir = context.build_dir
|
| [] ->
|
||||||
; inherit_from = None
|
make ~config:{ loc = Loc.none; rules = [] } ~inherit_from:None
|
||||||
; scope = Scope.DB.find_by_dir scopes context.build_dir
|
| [config] ->
|
||||||
; config
|
make ~config ~inherit_from:None
|
||||||
; ocaml_flags = None
|
| [context; workspace] ->
|
||||||
}
|
make ~config:context
|
||||||
|
~inherit_from:(Some (lazy (make ~inherit_from:None ~config:workspace)))
|
||||||
|
| _::_::_::_ -> assert false
|
||||||
) in
|
) in
|
||||||
List.iter stanzas
|
List.iter stanzas
|
||||||
~f:(fun { Dir_with_jbuild. ctx_dir; scope; stanzas; _ } ->
|
~f:(fun { Dir_with_jbuild. ctx_dir; scope; stanzas; _ } ->
|
||||||
|
|
Loading…
Reference in New Issue