* ocamlbuild, menhir and include directories
@ 2007-05-14 16:56 Stéphane Gimenez
2007-05-15 7:02 ` [Caml-list] " Nicolas Pouillard
0 siblings, 1 reply; 3+ messages in thread
From: Stéphane Gimenez @ 2007-05-14 16:56 UTC (permalink / raw)
To: caml-list
[-- Attachment #1: Type: text/plain, Size: 668 bytes --]
Hi Caml list,
I got stuck with calls from ocamlbuild to
menhir --infer ...
failing because include dirs (-I dir) were not given as parameters.
The fact is that menhir currently does not accept such parameters.
I found a dirty workaround using
menhir --ocamlc "ocamlc -I dir" ...
but this could override an other --ocamlc parameter.
Looking at menhir and ocamlbuild code, I thought a tiny patch to both
was the best choice:
- a patch to learn menhir about -I options
- a patch to ocamlbuild to feed menhir --infer calls with -I options
(using the same argument generation code as for other commands)
Those patches are attached.
Regards,
Stéphane.
[-- Attachment #2: menhir-20070322.incl_dirs.patch --]
[-- Type: text/plain, Size: 2152 bytes --]
diff -ru menhir-20070322/infer.ml menhir-20070322.patched/infer.ml
--- menhir-20070322/infer.ml 2007-03-22 21:12:49.000000000 +0100
+++ menhir-20070322.patched/infer.ml 2007-05-14 18:07:02.000000000 +0200
@@ -332,9 +332,12 @@
(* Invoke ocamlc to do type inference for us. *)
let output =
+ let incl_dirs =
+ String.concat " " (List.map (fun s -> "-I " ^ s) Settings.incl_dirs)
+ in
IO.winvoke
[ write grammar ]
- (Printf.sprintf "%s -c -i %s" Settings.ocamlc (Filename.quote mlname))
+ (Printf.sprintf "%s %s -c -i %s" Settings.ocamlc incl_dirs (Filename.quote mlname))
[ remove mlname ]
in
diff -ru menhir-20070322/settings.ml menhir-20070322.patched/settings.ml
--- menhir-20070322/settings.ml 2007-03-22 21:12:49.000000000 +0100
+++ menhir-20070322.patched/settings.ml 2007-05-14 18:50:58.000000000 +0200
@@ -93,6 +93,9 @@
let ocamldep =
ref "ocamldep"
+let incl_dirs =
+ ref []
+
let logG, logA, logC =
ref 0, ref 0, ref 0
@@ -131,6 +134,7 @@
"--no-stdlib", Arg.Set no_stdlib, " Do not load the standard library";
"--ocamlc", Arg.Set_string ocamlc, "<command> Specifies how ocamlc should be invoked";
"--ocamldep", Arg.Set_string ocamldep, "<command> Specifies how ocamldep should be invoked";
+ "-I", Arg.String (fun s -> incl_dirs := s :: !incl_dirs), "<dir> Add <dir> to the list of include directories";
"--only-preprocess", Arg.Set preprocess_only, " Print a simplified grammar and exit";
"--only-tokens", Arg.Unit tokentypeonly, " Generate token type definition only, no code";
"--raw-depend", Arg.Unit (fun () -> depend := OMRaw), " Invoke ocamldep and echo its raw output";
@@ -237,6 +241,9 @@
let ocamldep =
!ocamldep
+let incl_dirs =
+ !incl_dirs
+
let logG, logA, logC =
!logG, !logA, !logC
diff -ru menhir-20070322/settings.mli menhir-20070322.patched/settings.mli
--- menhir-20070322/settings.mli 2007-03-22 21:12:50.000000000 +0100
+++ menhir-20070322.patched/settings.mli 2007-05-14 18:05:47.000000000 +0200
@@ -97,6 +97,7 @@
val ocamlc: string
val ocamldep: string
+val incl_dirs: string list
(* How verbose we should be. *)
[-- Attachment #3: ocaml-menhir-incl_dirs.patch --]
[-- Type: text/plain, Size: 683 bytes --]
Index: ocaml_tools.ml
===================================================================
RCS file: /caml/ocaml/ocamlbuild/ocaml_tools.ml,v
retrieving revision 1.2
diff -u -r1.2 ocaml_tools.ml
--- ocaml_tools.ml 8 Feb 2007 16:53:39 -0000 1.2
+++ ocaml_tools.ml 14 May 2007 16:18:24 -0000
@@ -37,7 +37,8 @@
let menhir mly env build =
let mly = env mly in
Ocaml_compiler.prepare_compile build mly;
- Cmd(S[!Options.ocamlyacc; T(tags_of_pathname mly++"ocaml"++"parser"++"menhir");
+ Cmd(S[!Options.ocamlyacc; ocaml_include_flags mly;
+ T(tags_of_pathname mly++"ocaml"++"parser"++"menhir");
A"--infer"; flags_of_pathname mly; Px mly])
let ocamldoc_c tags arg odoc =
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] ocamlbuild, menhir and include directories
2007-05-14 16:56 ocamlbuild, menhir and include directories Stéphane Gimenez
@ 2007-05-15 7:02 ` Nicolas Pouillard
2007-05-15 12:50 ` Stéphane Gimenez
0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Pouillard @ 2007-05-15 7:02 UTC (permalink / raw)
To: Stéphane Gimenez, caml-list
On 5/14/07, Stéphane Gimenez <gimenez@pps.jussieu.fr> wrote:
> Hi Caml list,
>
> I got stuck with calls from ocamlbuild to
> menhir --infer ...
> failing because include dirs (-I dir) were not given as parameters.
>
I already fixed this bug on the ocamlbuild side by giving -I
directories trough --ocamlc. It's in the CVS, release3100 tag
--
Nicolas Pouillard
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] ocamlbuild, menhir and include directories
2007-05-15 7:02 ` [Caml-list] " Nicolas Pouillard
@ 2007-05-15 12:50 ` Stéphane Gimenez
0 siblings, 0 replies; 3+ messages in thread
From: Stéphane Gimenez @ 2007-05-15 12:50 UTC (permalink / raw)
To: Nicolas Pouillard; +Cc: caml-list
> >I got stuck with calls from ocamlbuild to
> > menhir --infer ...
> >failing because include dirs (-I dir) were not given as parameters.
> >
>
> I already fixed this bug on the ocamlbuild side by giving -I
> directories trough --ocamlc. It's in the CVS, release3100 tag
Ok! thanks and sorry for the noise. I follow MAIN branch, and
I was thinking such fixes would have been applied here.
(Btw, just in case, my menhir patch was lacking filename quotation,
don't use it whithout modification. Silly shell calls...)
Stéphane.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-05-15 12:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-14 16:56 ocamlbuild, menhir and include directories Stéphane Gimenez
2007-05-15 7:02 ` [Caml-list] " Nicolas Pouillard
2007-05-15 12:50 ` Stéphane Gimenez
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox