Initialize env_node from Super_context.create
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
parent
a82e783f15
commit
78786e09d4
|
@ -612,33 +612,40 @@ let create
|
|||
; env = Hashtbl.create 128
|
||||
}
|
||||
in
|
||||
let context_env_node = lazy (
|
||||
let config =
|
||||
match context.env_node with
|
||||
| Some s -> s
|
||||
| None -> { loc = Loc.none; rules = [] }
|
||||
in
|
||||
{ Env_node.
|
||||
dir = context.build_dir
|
||||
; inherit_from = None
|
||||
; scope = Scope.DB.find_by_dir scopes context.build_dir
|
||||
; config
|
||||
; ocaml_flags = None
|
||||
}
|
||||
) in
|
||||
List.iter stanzas
|
||||
~f:(fun { Dir_with_jbuild. ctx_dir; scope; stanzas; _ } ->
|
||||
List.iter stanzas ~f:(function
|
||||
| Env config ->
|
||||
let inherit_from =
|
||||
if ctx_dir = Scope.root scope then
|
||||
None
|
||||
context_env_node
|
||||
else
|
||||
Some (lazy (Env.get t ~dir:(Path.parent_exn ctx_dir)))
|
||||
lazy (Env.get t ~dir:(Path.parent_exn ctx_dir))
|
||||
in
|
||||
Hashtbl.add t.env ctx_dir
|
||||
{ dir = ctx_dir
|
||||
; inherit_from
|
||||
; inherit_from = Some inherit_from
|
||||
; scope = scope
|
||||
; config = config
|
||||
; ocaml_flags = None
|
||||
}
|
||||
| _ -> ()));
|
||||
if not (Hashtbl.mem t.env context.build_dir) then
|
||||
Hashtbl.add t.env context.build_dir
|
||||
{ Env_node.
|
||||
dir = context.build_dir
|
||||
; inherit_from = None
|
||||
; scope = Scope.DB.find_by_dir scopes context.build_dir
|
||||
; config = { loc = Loc.none; rules = [] }
|
||||
; ocaml_flags = None
|
||||
};
|
||||
Hashtbl.add t.env context.build_dir (Lazy.force context_env_node);
|
||||
t
|
||||
module Libs = struct
|
||||
open Build.O
|
||||
|
|
|
@ -47,3 +47,7 @@ see how we can set a "native" target. Which is the default.
|
|||
Entering directory 'targets-native'
|
||||
Entering directory 'targets-native'
|
||||
message from targets-native test
|
||||
|
||||
Workspaces also allow you to set the env for a context:
|
||||
|
||||
$ dune printenv --root workspace-env --profile default
|
|
@ -0,0 +1 @@
|
|||
(lang dune 1.0)
|
|
@ -0,0 +1,7 @@
|
|||
(lang dune 1.0)
|
||||
|
||||
(context
|
||||
(default
|
||||
(env
|
||||
(default
|
||||
(flags (:standard -machin))))))
|
Loading…
Reference in New Issue