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__
|
(Default { loc = Loc.of_pos __POS__
|
||||||
; targets = [Native]
|
; targets = [Native]
|
||||||
; profile = Config.default_build_profile
|
; profile = Config.default_build_profile
|
||||||
|
; env = None
|
||||||
})
|
})
|
||||||
~env
|
~env
|
||||||
>>= fun ctxs ->
|
>>= fun ctxs ->
|
||||||
|
|
|
@ -26,6 +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 : Shared_stanza.Env.t option
|
||||||
; 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
|
||||||
|
@ -130,7 +131,8 @@ let ocamlpath_sep =
|
||||||
else
|
else
|
||||||
Bin.path_sep
|
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
|
let opam_var_cache = Hashtbl.create 128 in
|
||||||
(match kind with
|
(match kind with
|
||||||
| Opam { root; _ } ->
|
| Opam { root; _ } ->
|
||||||
|
@ -332,6 +334,7 @@ let create ~(kind : Kind.t) ~path ~env ~name ~merlin ~targets ~profile () =
|
||||||
; kind
|
; kind
|
||||||
; profile
|
; profile
|
||||||
; merlin
|
; merlin
|
||||||
|
; env_node
|
||||||
; for_host = host
|
; for_host = host
|
||||||
; build_dir
|
; build_dir
|
||||||
; path
|
; 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 opam_config_var t var = opam_config_var ~env:t.env ~cache:t.opam_var_cache var
|
||||||
|
|
||||||
let default ?(merlin=true) ~env ~targets () =
|
let default ?(merlin=true) ~env_node ~env ~targets () =
|
||||||
create ~kind:Default ~path:Bin.path ~env ~name:"default" ~merlin ~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) () =
|
?(merlin=false) () =
|
||||||
match Bin.opam with
|
match Bin.opam with
|
||||||
| None -> Utils.program_not_found "opam"
|
| 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
|
| 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 ~name
|
create ~kind:(Opam { root; switch }) ~profile ~targets ~path ~env ~env_node
|
||||||
~merlin ()
|
~name ~merlin ()
|
||||||
|
|
||||||
let create ?merlin ~env def =
|
let create ?merlin ~env def =
|
||||||
match (def : Workspace.Context.t) with
|
match (def : Workspace.Context.t) with
|
||||||
| Default { targets; profile; _ } -> default ~env ~profile ~targets ?merlin ()
|
| Default { targets; profile; env = env_node ; loc = _ } ->
|
||||||
| Opam { base = { targets ; profile ; loc = _ }
|
default ~env ~env_node ~profile ~targets ?merlin ()
|
||||||
|
| Opam { base = { targets ; profile ; env = env_node ; loc = _ }
|
||||||
; name; switch; root; merlin = _ } ->
|
; 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
|
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" *)
|
; (** Directory where artifact are stored, for instance "_build/default" *)
|
||||||
build_dir : Path.t
|
build_dir : Path.t
|
||||||
|
|
||||||
|
; (** env node that this context was initialized with *)
|
||||||
|
env_node : Shared_stanza.Env.t option
|
||||||
|
|
||||||
; (** [PATH] *)
|
; (** [PATH] *)
|
||||||
path : Path.t list
|
path : Path.t list
|
||||||
|
|
||||||
|
|
|
@ -366,6 +366,8 @@ module Env : sig
|
||||||
{ loc : Loc.t
|
{ loc : Loc.t
|
||||||
; rules : (pattern * config) list
|
; rules : (pattern * config) list
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val t : t Sexp.Of_sexp.t
|
||||||
end
|
end
|
||||||
|
|
||||||
module Tests : sig
|
module Tests : sig
|
||||||
|
|
|
@ -45,9 +45,11 @@ module Context = struct
|
||||||
{ loc : Loc.t
|
{ loc : Loc.t
|
||||||
; profile : string
|
; profile : string
|
||||||
; targets : Target.t list
|
; targets : Target.t list
|
||||||
|
; env : Jbuild.Env.t option
|
||||||
}
|
}
|
||||||
|
|
||||||
let t ~profile =
|
let t ~profile =
|
||||||
|
field_o "env" Jbuild.Env.t >>= fun env ->
|
||||||
field "targets" (list Target.t) ~default:[Target.Native]
|
field "targets" (list Target.t) ~default:[Target.Native]
|
||||||
>>= fun targets ->
|
>>= fun targets ->
|
||||||
field "profile" string ~default:profile
|
field "profile" string ~default:profile
|
||||||
|
@ -57,6 +59,7 @@ module Context = struct
|
||||||
{ targets
|
{ targets
|
||||||
; profile
|
; profile
|
||||||
; loc
|
; loc
|
||||||
|
; env
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -138,6 +141,7 @@ module Context = struct
|
||||||
; targets = [Option.value x ~default:Target.Native]
|
; targets = [Option.value x ~default:Target.Native]
|
||||||
; profile = Option.value profile
|
; profile = Option.value profile
|
||||||
~default:Config.default_build_profile
|
~default:Config.default_build_profile
|
||||||
|
; env = None
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ module Context : sig
|
||||||
{ loc : Loc.t
|
{ loc : Loc.t
|
||||||
; profile : string
|
; profile : string
|
||||||
; targets : Target.t list
|
; targets : Target.t list
|
||||||
|
; env : Jbuild.Env.t option
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
module Opam : sig
|
module Opam : sig
|
||||||
|
|
Loading…
Reference in New Issue