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 -> (* This happens often when passing a [-p ...] option that
Loc.fail m.loc hides a library *)
"I can't determine what library/executable the files produced \ let targets =
by this stanza are part of." List.map (Menhir_rules.targets m) ~f:(Path.relative ctx_dir)
| Some cctx -> cctx in
in SC.add_rule sctx
Menhir_rules.gen_rules cctx m (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 Modules_partitioner.emit_errors modules_partitioner