Plumb through env node
workspace -> context -> super context Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
parent
61d7e49e07
commit
4769f9df9f
|
@ -574,6 +574,7 @@ let installed_libraries =
|
|||
(Default { loc = Loc.of_pos __POS__
|
||||
; targets = [Native]
|
||||
; profile = Config.default_build_profile
|
||||
; env = None
|
||||
})
|
||||
~env
|
||||
>>= fun ctxs ->
|
||||
|
|
|
@ -26,6 +26,7 @@ type t =
|
|||
; for_host : t option
|
||||
; implicit : bool
|
||||
; build_dir : Path.t
|
||||
; env_node : Shared_stanza.Env.t option
|
||||
; path : Path.t list
|
||||
; toplevel_path : Path.t option
|
||||
; ocaml_bin : Path.t
|
||||
|
@ -130,7 +131,8 @@ let ocamlpath_sep =
|
|||
else
|
||||
Bin.path_sep
|
||||
|
||||
let create ~(kind : Kind.t) ~path ~env ~name ~merlin ~targets ~profile () =
|
||||
let create ~(kind : Kind.t) ~path ~env ~env_node ~name ~merlin ~targets
|
||||
~profile () =
|
||||
let opam_var_cache = Hashtbl.create 128 in
|
||||
(match kind with
|
||||
| Opam { root; _ } ->
|
||||
|
@ -332,6 +334,7 @@ let create ~(kind : Kind.t) ~path ~env ~name ~merlin ~targets ~profile () =
|
|||
; kind
|
||||
; profile
|
||||
; merlin
|
||||
; env_node
|
||||
; for_host = host
|
||||
; build_dir
|
||||
; path
|
||||
|
@ -407,10 +410,11 @@ let create ~(kind : Kind.t) ~path ~env ~name ~merlin ~targets ~profile () =
|
|||
|
||||
let opam_config_var t var = opam_config_var ~env:t.env ~cache:t.opam_var_cache var
|
||||
|
||||
let default ?(merlin=true) ~env ~targets () =
|
||||
create ~kind:Default ~path:Bin.path ~env ~name:"default" ~merlin ~targets ()
|
||||
let default ?(merlin=true) ~env_node ~env ~targets () =
|
||||
create ~kind:Default ~path:Bin.path ~env ~env_node ~name:"default"
|
||||
~merlin ~targets ()
|
||||
|
||||
let create_for_opam ?root ~env ~targets ~profile ~switch ~name
|
||||
let create_for_opam ?root ~env ~env_node ~targets ~profile ~switch ~name
|
||||
?(merlin=false) () =
|
||||
match Bin.opam with
|
||||
| None -> Utils.program_not_found "opam"
|
||||
|
@ -448,15 +452,16 @@ let create_for_opam ?root ~env ~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 ~name
|
||||
~merlin ()
|
||||
create ~kind:(Opam { root; switch }) ~profile ~targets ~path ~env ~env_node
|
||||
~name ~merlin ()
|
||||
|
||||
let create ?merlin ~env def =
|
||||
match (def : Workspace.Context.t) with
|
||||
| Default { targets; profile; _ } -> default ~env ~profile ~targets ?merlin ()
|
||||
| Opam { base = { targets ; profile ; loc = _ }
|
||||
| Default { targets; profile; env = env_node ; loc = _ } ->
|
||||
default ~env ~env_node ~profile ~targets ?merlin ()
|
||||
| Opam { base = { targets ; profile ; env = env_node ; loc = _ }
|
||||
; name; switch; root; merlin = _ } ->
|
||||
create_for_opam ?root ~env ~profile ~switch ~name ?merlin ~targets ()
|
||||
create_for_opam ?root ~env_node ~env ~profile ~switch ~name ?merlin ~targets ()
|
||||
|
||||
let which t s = which ~cache:t.which_cache ~path:t.path s
|
||||
|
||||
|
|
|
@ -50,6 +50,9 @@ type t =
|
|||
; (** Directory where artifact are stored, for instance "_build/default" *)
|
||||
build_dir : Path.t
|
||||
|
||||
; (** env node that this context was initialized with *)
|
||||
env_node : Shared_stanza.Env.t option
|
||||
|
||||
; (** [PATH] *)
|
||||
path : Path.t list
|
||||
|
||||
|
|
|
@ -366,6 +366,8 @@ module Env : sig
|
|||
{ loc : Loc.t
|
||||
; rules : (pattern * config) list
|
||||
}
|
||||
|
||||
val t : t Sexp.Of_sexp.t
|
||||
end
|
||||
|
||||
module Tests : sig
|
||||
|
|
|
@ -45,9 +45,11 @@ module Context = struct
|
|||
{ loc : Loc.t
|
||||
; profile : string
|
||||
; targets : Target.t list
|
||||
; env : Jbuild.Env.t option
|
||||
}
|
||||
|
||||
let t ~profile =
|
||||
field_o "env" Jbuild.Env.t >>= fun env ->
|
||||
field "targets" (list Target.t) ~default:[Target.Native]
|
||||
>>= fun targets ->
|
||||
field "profile" string ~default:profile
|
||||
|
@ -57,6 +59,7 @@ module Context = struct
|
|||
{ targets
|
||||
; profile
|
||||
; loc
|
||||
; env
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -138,6 +141,7 @@ module Context = struct
|
|||
; targets = [Option.value x ~default:Target.Native]
|
||||
; profile = Option.value profile
|
||||
~default:Config.default_build_profile
|
||||
; env = None
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ module Context : sig
|
|||
{ loc : Loc.t
|
||||
; profile : string
|
||||
; targets : Target.t list
|
||||
; env : Jbuild.Env.t option
|
||||
}
|
||||
end
|
||||
module Opam : sig
|
||||
|
|
Loading…
Reference in New Issue