Move Env stanza to Shared_stanza module
To break dependency cycles. This shared_stanza module doesn't have any dependencies on actions. Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
parent
4769f9df9f
commit
b12517debb
|
@ -1517,39 +1517,6 @@ module Documentation = struct
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
module Env = struct
|
|
||||||
type config =
|
|
||||||
{ flags : Ordered_set_lang.Unexpanded.t
|
|
||||||
; ocamlc_flags : Ordered_set_lang.Unexpanded.t
|
|
||||||
; ocamlopt_flags : Ordered_set_lang.Unexpanded.t
|
|
||||||
}
|
|
||||||
|
|
||||||
type pattern =
|
|
||||||
| Profile of string
|
|
||||||
| Any
|
|
||||||
|
|
||||||
type t =
|
|
||||||
{ loc : Loc.t
|
|
||||||
; rules : (pattern * config) list
|
|
||||||
}
|
|
||||||
|
|
||||||
let config =
|
|
||||||
let%map flags = field_oslu "flags"
|
|
||||||
and ocamlc_flags = field_oslu "ocamlc_flags"
|
|
||||||
and ocamlopt_flags = field_oslu "ocamlopt_flags"
|
|
||||||
in
|
|
||||||
{ flags; ocamlc_flags; ocamlopt_flags }
|
|
||||||
|
|
||||||
let rule =
|
|
||||||
enter
|
|
||||||
(let%map pat =
|
|
||||||
match_keyword [("_", return Any)]
|
|
||||||
~fallback:(string >>| fun s -> Profile s)
|
|
||||||
and configs = fields config
|
|
||||||
in
|
|
||||||
(pat, configs))
|
|
||||||
end
|
|
||||||
|
|
||||||
type Stanza.t +=
|
type Stanza.t +=
|
||||||
| Library of Library.t
|
| Library of Library.t
|
||||||
| Executables of Executables.t
|
| Executables of Executables.t
|
||||||
|
@ -1558,7 +1525,6 @@ type Stanza.t +=
|
||||||
| Alias of Alias_conf.t
|
| Alias of Alias_conf.t
|
||||||
| Copy_files of Copy_files.t
|
| Copy_files of Copy_files.t
|
||||||
| Documentation of Documentation.t
|
| Documentation of Documentation.t
|
||||||
| Env of Env.t
|
|
||||||
| Tests of Tests.t
|
| Tests of Tests.t
|
||||||
|
|
||||||
module Stanzas = struct
|
module Stanzas = struct
|
||||||
|
@ -1695,7 +1661,10 @@ module Stanzas = struct
|
||||||
"\n--> included from %s"
|
"\n--> included from %s"
|
||||||
(line_loc x))))
|
(line_loc x))))
|
||||||
in
|
in
|
||||||
match List.filter_map stanzas ~f:(function Env e -> Some e | _ -> None) with
|
match
|
||||||
|
List.filter_map stanzas
|
||||||
|
~f:(function Shared_stanza.Env e -> Some e | _ -> None)
|
||||||
|
with
|
||||||
| _ :: e :: _ ->
|
| _ :: e :: _ ->
|
||||||
Loc.fail e.loc "The 'env' stanza cannot appear more than once"
|
Loc.fail e.loc "The 'env' stanza cannot appear more than once"
|
||||||
| _ -> stanzas
|
| _ -> stanzas
|
||||||
|
|
|
@ -351,25 +351,6 @@ module Documentation : sig
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
module Env : sig
|
|
||||||
type config =
|
|
||||||
{ flags : Ordered_set_lang.Unexpanded.t
|
|
||||||
; ocamlc_flags : Ordered_set_lang.Unexpanded.t
|
|
||||||
; ocamlopt_flags : Ordered_set_lang.Unexpanded.t
|
|
||||||
}
|
|
||||||
|
|
||||||
type pattern =
|
|
||||||
| Profile of string
|
|
||||||
| Any
|
|
||||||
|
|
||||||
type t =
|
|
||||||
{ loc : Loc.t
|
|
||||||
; rules : (pattern * config) list
|
|
||||||
}
|
|
||||||
|
|
||||||
val t : t Sexp.Of_sexp.t
|
|
||||||
end
|
|
||||||
|
|
||||||
module Tests : sig
|
module Tests : sig
|
||||||
type t =
|
type t =
|
||||||
{ exes : Executables.t
|
{ exes : Executables.t
|
||||||
|
@ -387,7 +368,6 @@ type Stanza.t +=
|
||||||
| Alias of Alias_conf.t
|
| Alias of Alias_conf.t
|
||||||
| Copy_files of Copy_files.t
|
| Copy_files of Copy_files.t
|
||||||
| Documentation of Documentation.t
|
| Documentation of Documentation.t
|
||||||
| Env of Env.t
|
|
||||||
| Tests of Tests.t
|
| Tests of Tests.t
|
||||||
|
|
||||||
module Stanzas : sig
|
module Stanzas : sig
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
open Import
|
||||||
|
open Stanza.Of_sexp
|
||||||
|
|
||||||
|
let field_oslu name = Ordered_set_lang.Unexpanded.field name
|
||||||
|
|
||||||
|
module Env = struct
|
||||||
|
type config =
|
||||||
|
{ flags : Ordered_set_lang.Unexpanded.t
|
||||||
|
; ocamlc_flags : Ordered_set_lang.Unexpanded.t
|
||||||
|
; ocamlopt_flags : Ordered_set_lang.Unexpanded.t
|
||||||
|
}
|
||||||
|
|
||||||
|
type pattern =
|
||||||
|
| Profile of string
|
||||||
|
| Any
|
||||||
|
|
||||||
|
type t =
|
||||||
|
{ loc : Loc.t
|
||||||
|
; rules : (pattern * config) list
|
||||||
|
}
|
||||||
|
|
||||||
|
let config =
|
||||||
|
let%map flags = field_oslu "flags"
|
||||||
|
and ocamlc_flags = field_oslu "ocamlc_flags"
|
||||||
|
and ocamlopt_flags = field_oslu "ocamlopt_flags"
|
||||||
|
in
|
||||||
|
{ flags; ocamlc_flags; ocamlopt_flags }
|
||||||
|
|
||||||
|
let rule =
|
||||||
|
enter
|
||||||
|
(let%map pat =
|
||||||
|
match_keyword [("_", return Any)]
|
||||||
|
~fallback:(string >>| fun s -> Profile s)
|
||||||
|
and configs = fields config
|
||||||
|
in
|
||||||
|
(pat, configs))
|
||||||
|
|
||||||
|
let t =
|
||||||
|
Syntax.since Stanza.syntax (1, 0) >>= fun () ->
|
||||||
|
loc >>= fun loc ->
|
||||||
|
repeat rule >>| fun rules ->
|
||||||
|
{ loc; rules }
|
||||||
|
end
|
||||||
|
|
||||||
|
type Stanza.t +=
|
||||||
|
| Env of Env.t
|
|
@ -0,0 +1,23 @@
|
||||||
|
open Import
|
||||||
|
|
||||||
|
module Env : sig
|
||||||
|
type config =
|
||||||
|
{ flags : Ordered_set_lang.Unexpanded.t
|
||||||
|
; ocamlc_flags : Ordered_set_lang.Unexpanded.t
|
||||||
|
; ocamlopt_flags : Ordered_set_lang.Unexpanded.t
|
||||||
|
}
|
||||||
|
|
||||||
|
type pattern =
|
||||||
|
| Profile of string
|
||||||
|
| Any
|
||||||
|
|
||||||
|
type t =
|
||||||
|
{ loc : Loc.t
|
||||||
|
; rules : (pattern * config) list
|
||||||
|
}
|
||||||
|
|
||||||
|
val t : t Sexp.Of_sexp.t
|
||||||
|
end
|
||||||
|
|
||||||
|
type Stanza.t +=
|
||||||
|
| Env of Env.t
|
|
@ -1,4 +1,5 @@
|
||||||
open Import
|
open Import
|
||||||
|
open Shared_stanza
|
||||||
open Jbuild
|
open Jbuild
|
||||||
|
|
||||||
module A = Action
|
module A = Action
|
||||||
|
|
|
@ -45,11 +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
|
; env : Shared_stanza.Env.t option
|
||||||
}
|
}
|
||||||
|
|
||||||
let t ~profile =
|
let t ~profile =
|
||||||
field_o "env" Jbuild.Env.t >>= fun env ->
|
field_o "env" Shared_stanza.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
|
||||||
|
|
|
@ -13,7 +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
|
; env : Shared_stanza.Env.t option
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
module Opam : sig
|
module Opam : sig
|
||||||
|
|
Loading…
Reference in New Issue