Make sure not to fail eagerly when we can't setup menhir rules

Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
This commit is contained in:
Jeremie Dimino 2018-07-10 13:56:17 +01:00 committed by Jérémie Dimino
parent 3d389846a8
commit 0272733d2a
1 changed files with 20 additions and 12 deletions

View File

@ -1062,18 +1062,26 @@ module Gen(P : Install_rules.Params) = struct
List.iter stanzas ~f:(fun stanza ->
match (stanza : Stanza.t) with
| Menhir.T m ->
let cctx =
match
List.find_map (Menhir_rules.module_names m)
~f:(Modules_partitioner.find modules_partitioner)
with
| None ->
Loc.fail m.loc
"I can't determine what library/executable the files produced \
by this stanza are part of."
| Some cctx -> cctx
in
Menhir_rules.gen_rules cctx m
begin match
List.find_map (Menhir_rules.module_names m)
~f:(Modules_partitioner.find modules_partitioner)
with
| None ->
(* This happens often when passing a [-p ...] option that
hides a library *)
let targets =
List.map (Menhir_rules.targets m) ~f:(Path.relative ctx_dir)
in
SC.add_rule sctx
(Build.fail ~targets
{ fail = fun () ->
Loc.fail m.loc
"I can't determine what library/executable the files \
produced by this stanza are part of."
})
| Some cctx ->
Menhir_rules.gen_rules cctx m
end
| _ -> ());
Modules_partitioner.emit_errors modules_partitioner