Add toplevel env stanza to workspace files
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
parent
5e7841abf2
commit
200f9d0a52
|
@ -148,22 +148,25 @@ end
|
||||||
type t =
|
type t =
|
||||||
{ merlin_context : string option
|
{ merlin_context : string option
|
||||||
; contexts : Context.t list
|
; contexts : Context.t list
|
||||||
|
; env : Dune_env.Stanza.t option
|
||||||
}
|
}
|
||||||
|
|
||||||
include Versioned_file.Make(struct type t = unit end)
|
include Versioned_file.Make(struct type t = unit end)
|
||||||
let () = Lang.register syntax ()
|
let () = Lang.register syntax ()
|
||||||
|
|
||||||
let t ?x ?profile:cmdline_profile () =
|
let t ?x ?profile:cmdline_profile () =
|
||||||
|
field_o "env" Dune_env.Stanza.t >>= fun env ->
|
||||||
field "profile" string ~default:Config.default_build_profile
|
field "profile" string ~default:Config.default_build_profile
|
||||||
>>= fun profile ->
|
>>= fun profile ->
|
||||||
let profile = Option.value cmdline_profile ~default:profile in
|
let profile = Option.value cmdline_profile ~default:profile in
|
||||||
multi_field "context" (Context.t ~profile ~x)
|
multi_field "context" (Context.t ~profile ~x)
|
||||||
>>= fun contexts ->
|
>>= fun contexts ->
|
||||||
let defined_names = ref String.Set.empty in
|
let defined_names = ref String.Set.empty in
|
||||||
let { merlin_context; contexts } =
|
let { merlin_context; contexts; env } =
|
||||||
let init =
|
let init =
|
||||||
{ merlin_context = None
|
{ merlin_context = None
|
||||||
; contexts = []
|
; contexts = []
|
||||||
|
; env
|
||||||
}
|
}
|
||||||
in
|
in
|
||||||
List.fold_left contexts ~init ~f:(fun t ctx ->
|
List.fold_left contexts ~init ~f:(fun t ctx ->
|
||||||
|
@ -178,7 +181,7 @@ let t ?x ?profile:cmdline_profile () =
|
||||||
Loc.fail (Context.loc ctx)
|
Loc.fail (Context.loc ctx)
|
||||||
"you can only have one context for merlin"
|
"you can only have one context for merlin"
|
||||||
| Opam { merlin = true; _ }, None ->
|
| Opam { merlin = true; _ }, None ->
|
||||||
{ merlin_context = Some name; contexts = ctx :: t.contexts }
|
{ merlin_context = Some name; contexts = ctx :: t.contexts; env = None }
|
||||||
| _ ->
|
| _ ->
|
||||||
{ t with contexts = ctx :: t.contexts })
|
{ t with contexts = ctx :: t.contexts })
|
||||||
in
|
in
|
||||||
|
@ -200,6 +203,7 @@ let t ?x ?profile:cmdline_profile () =
|
||||||
return
|
return
|
||||||
{ merlin_context
|
{ merlin_context
|
||||||
; contexts = List.rev contexts
|
; contexts = List.rev contexts
|
||||||
|
; env
|
||||||
}
|
}
|
||||||
|
|
||||||
let t ?x ?profile () = fields (t ?x ?profile ())
|
let t ?x ?profile () = fields (t ?x ?profile ())
|
||||||
|
@ -207,6 +211,7 @@ let t ?x ?profile () = fields (t ?x ?profile ())
|
||||||
let default ?x ?profile () =
|
let default ?x ?profile () =
|
||||||
{ merlin_context = Some "default"
|
{ merlin_context = Some "default"
|
||||||
; contexts = [Context.default ?x ?profile ()]
|
; contexts = [Context.default ?x ?profile ()]
|
||||||
|
; env = None
|
||||||
}
|
}
|
||||||
|
|
||||||
let load ?x ?profile p =
|
let load ?x ?profile p =
|
||||||
|
|
|
@ -38,6 +38,7 @@ end
|
||||||
type t =
|
type t =
|
||||||
{ merlin_context : string option
|
{ merlin_context : string option
|
||||||
; contexts : Context.t list
|
; contexts : Context.t list
|
||||||
|
; env : Dune_env.Stanza.t option
|
||||||
}
|
}
|
||||||
|
|
||||||
val load : ?x:string -> ?profile:string -> Path.t -> t
|
val load : ?x:string -> ?profile:string -> Path.t -> t
|
||||||
|
|
Loading…
Reference in New Issue