Change menhir flags to use ordered set language
Consistent with how flags are handled elsewhere in jbuilder
This commit is contained in:
parent
f06519e231
commit
6d5c2de689
|
@ -942,7 +942,7 @@ end
|
|||
module Menhir = struct
|
||||
type t =
|
||||
{ merge_into : string option
|
||||
; flags : String_with_vars.t list
|
||||
; flags : Ordered_set_lang.Unexpanded.t
|
||||
; modules : string list
|
||||
; mode : Rule.Mode.t
|
||||
; loc : Loc.t
|
||||
|
@ -951,7 +951,7 @@ module Menhir = struct
|
|||
let v1 =
|
||||
record
|
||||
(field_o "merge_into" string >>= fun merge_into ->
|
||||
field "flags" (list String_with_vars.t) ~default:[] >>= fun flags ->
|
||||
field_oslu "flags" >>= fun flags ->
|
||||
field "modules" (list string) >>= fun modules ->
|
||||
Rule.Mode.field >>= fun mode ->
|
||||
return
|
||||
|
|
|
@ -287,7 +287,7 @@ end
|
|||
module Menhir : sig
|
||||
type t =
|
||||
{ merge_into : string option
|
||||
; flags : String_with_vars.t list
|
||||
; flags : Ordered_set_lang.Unexpanded.t
|
||||
; modules : string list
|
||||
; mode : Rule.Mode.t
|
||||
; loc : Loc.t
|
||||
|
|
|
@ -1,17 +1,22 @@
|
|||
open Import
|
||||
open Build.O
|
||||
open! No_io
|
||||
|
||||
let gen_rules sctx ~dir ~scope (t : Jbuild.Menhir.t) =
|
||||
let targets n = List.map ~f:(Path.relative dir) [n ^ ".ml"; n ^ ".mli"] in
|
||||
let flags =
|
||||
List.map ~f:(Super_context.expand_vars sctx ~scope ~dir) t.flags in
|
||||
Super_context.expand_and_eval_set sctx ~scope ~dir t.flags
|
||||
~standard:[] in
|
||||
let menhir =
|
||||
let menhir =
|
||||
Super_context.resolve_program sctx ~hint:"opam install menhir" "menhir" in
|
||||
fun ~extra_targets ->
|
||||
Build.run ~extra_targets
|
||||
menhir
|
||||
~dir
|
||||
~context:(Super_context.context sctx) in
|
||||
fun ~extra_targets args->
|
||||
flags
|
||||
>>> (Build.run ~extra_targets
|
||||
menhir
|
||||
~dir
|
||||
~context:(Super_context.context sctx)
|
||||
args) in
|
||||
let add_rule_get_targets =
|
||||
Super_context.add_rule_get_targets sctx ~mode:t.mode ~loc:t.loc in
|
||||
let mly name = Path.relative dir (name ^ ".mly") in
|
||||
|
@ -21,7 +26,7 @@ let gen_rules sctx ~dir ~scope (t : Jbuild.Menhir.t) =
|
|||
add_rule_get_targets (
|
||||
menhir
|
||||
~extra_targets:(targets name)
|
||||
[ As flags
|
||||
[ Dyn (fun x -> As x)
|
||||
; Dep (mly name)]
|
||||
)) t.modules
|
||||
| Some merge_into ->
|
||||
|
@ -29,7 +34,7 @@ let gen_rules sctx ~dir ~scope (t : Jbuild.Menhir.t) =
|
|||
menhir
|
||||
~extra_targets:(targets merge_into)
|
||||
[ A "--base" ; A merge_into
|
||||
; As flags
|
||||
; Dyn (fun x -> As x)
|
||||
; Deps (List.map ~f:mly t.modules)
|
||||
]
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue