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 -> List.iter stanzas ~f:(fun stanza ->
match (stanza : Stanza.t) with match (stanza : Stanza.t) with
| Menhir.T m -> | Menhir.T m ->
let cctx = begin match
match
List.find_map (Menhir_rules.module_names m) List.find_map (Menhir_rules.module_names m)
~f:(Modules_partitioner.find modules_partitioner) ~f:(Modules_partitioner.find modules_partitioner)
with with
| None -> | None ->
Loc.fail m.loc (* This happens often when passing a [-p ...] option that
"I can't determine what library/executable the files produced \ hides a library *)
by this stanza are part of." let targets =
| Some cctx -> cctx List.map (Menhir_rules.targets m) ~f:(Path.relative ctx_dir)
in 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 Menhir_rules.gen_rules cctx m
end
| _ -> ()); | _ -> ());
Modules_partitioner.emit_errors modules_partitioner Modules_partitioner.emit_errors modules_partitioner