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
|
; env = Hashtbl.create 128
|
||||||
}
|
}
|
||||||
in
|
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
|
List.iter stanzas
|
||||||
~f:(fun { Dir_with_jbuild. ctx_dir; scope; stanzas; _ } ->
|
~f:(fun { Dir_with_jbuild. ctx_dir; scope; stanzas; _ } ->
|
||||||
List.iter stanzas ~f:(function
|
List.iter stanzas ~f:(function
|
||||||
| Env config ->
|
| Env config ->
|
||||||
let inherit_from =
|
let inherit_from =
|
||||||
if ctx_dir = Scope.root scope then
|
if ctx_dir = Scope.root scope then
|
||||||
None
|
context_env_node
|
||||||
else
|
else
|
||||||
Some (lazy (Env.get t ~dir:(Path.parent_exn ctx_dir)))
|
lazy (Env.get t ~dir:(Path.parent_exn ctx_dir))
|
||||||
in
|
in
|
||||||
Hashtbl.add t.env ctx_dir
|
Hashtbl.add t.env ctx_dir
|
||||||
{ dir = ctx_dir
|
{ dir = ctx_dir
|
||||||
; inherit_from
|
; inherit_from = Some inherit_from
|
||||||
; scope = scope
|
; scope = scope
|
||||||
; config = config
|
; config = config
|
||||||
; ocaml_flags = None
|
; ocaml_flags = None
|
||||||
}
|
}
|
||||||
| _ -> ()));
|
| _ -> ()));
|
||||||
if not (Hashtbl.mem t.env context.build_dir) then
|
if not (Hashtbl.mem t.env context.build_dir) then
|
||||||
Hashtbl.add t.env context.build_dir
|
Hashtbl.add t.env context.build_dir (Lazy.force context_env_node);
|
||||||
{ 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
|
|
||||||
};
|
|
||||||
t
|
t
|
||||||
module Libs = struct
|
module Libs = struct
|
||||||
open Build.O
|
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'
|
||||||
Entering directory 'targets-native'
|
Entering directory 'targets-native'
|
||||||
message from targets-native test
|
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