* ocamlbuild .inferred.mli problem
@ 2007-09-16 2:36 Hezekiah M. Carty
2007-09-17 14:25 ` [Caml-list] " Nicolas Pouillard
0 siblings, 1 reply; 4+ messages in thread
From: Hezekiah M. Carty @ 2007-09-16 2:36 UTC (permalink / raw)
To: caml-list
I have been unable to get ocamlbuild to preprocess a single .ml file
when creating an inferred interface file. Here is some simple code
to illustrate the problem:
test.ml:
value f x = x + 2;
_tags:
<test.ml>: pp(camlp4r)
To build it:
$ ocamlbuild test.cma
^^^ This works without issue
$ ocamlbuild test.inferred.mli
^^^ This produces the following output/error:
---BEGIN PASTE---
+ /home/hcarty/Applications/godi/bin/ocamlc.opt -i test.ml >
test.inferred.mli
File "test.ml", line 1, characters 0-5:
Unbound value value
Command exited with code 2.
Compilation unsuccessful after building 2 targets (1 cached) in
00:00:00.
---END PASTE---
I have tried various changes with the _tags line, such as:
<test.{ml,mli,inferred.mli}>
and others, but have had no success.
I have also tried creating a myocamlbuild.ml to get around this, but
using something like this in myocamlbuild.ml:
flag ["use_openin"]
(S [A "-I"; A "+camlp4"; A "-pp"; A "camlp4o pa_openin.cmo"]);;
along with a matching flag in _tags causes havoc, with each of the
items on the list being repeated twice and quoted, leading to shell
errors.
I'm using revised syntax here as a simple example. I originally ran
in to this issue while trying to build a library which uses the
pa_openin camlp4 extension.
Any suggestions or pointers on how to proceed with this?
Thanks,
Hez
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] ocamlbuild .inferred.mli problem
2007-09-16 2:36 ocamlbuild .inferred.mli problem Hezekiah M. Carty
@ 2007-09-17 14:25 ` Nicolas Pouillard
2007-09-17 18:08 ` Hezekiah M. Carty
0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Pouillard @ 2007-09-17 14:25 UTC (permalink / raw)
To: Hezekiah M. Carty; +Cc: Inria Ocaml Mailing List
Excerpts from Hezekiah M. Carty's message of Sun Sep 16 04:36:23 +0200 2007:
> I have been unable to get ocamlbuild to preprocess a single .ml file
> when creating an inferred interface file. Here is some simple code
> to illustrate the problem:
>
> test.ml:
> value f x = x + 2;
>
> _tags:
> <test.ml>: pp(camlp4r)
Using pp(...), is not the best way to use preprocessors.
Try the camlp4r tag:
"test.ml": camlp4r
[...]
> I have also tried creating a myocamlbuild.ml to get around this, but
> using something like this in myocamlbuild.ml:
>
> flag ["use_openin"]
> (S [A "-I"; A "+camlp4"; A "-pp"; A "camlp4o pa_openin.cmo"]);;
You certainly don't want to add these flags to any commands that treat a file
that is tagged use_openin. You certainly want to add them only for ocaml
preprocessing.
flag ["ocaml"; "pp"; "use_openin"]
(A"pa_openin.cmo");;
> along with a matching flag in _tags causes havoc, with each of the
> items on the list being repeated twice and quoted, leading to shell
> errors.
>
> I'm using revised syntax here as a simple example. I originally ran
> in to this issue while trying to build a library which uses the
> pa_openin camlp4 extension.
>
> Any suggestions or pointers on how to proceed with this?
HTH,
--
Nicolas Pouillard aka Ertai
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] ocamlbuild .inferred.mli problem
2007-09-17 14:25 ` [Caml-list] " Nicolas Pouillard
@ 2007-09-17 18:08 ` Hezekiah M. Carty
2007-09-18 14:49 ` Nicolas Pouillard
0 siblings, 1 reply; 4+ messages in thread
From: Hezekiah M. Carty @ 2007-09-17 18:08 UTC (permalink / raw)
To: Nicolas Pouillard; +Cc: Inria Ocaml Mailing List
On Mon, 17 Sep 2007, Nicolas Pouillard wrote:
> > I have also tried creating a myocamlbuild.ml to get around this, but
> > using something like this in myocamlbuild.ml:
> >
> > flag ["use_openin"]
> > (S [A "-I"; A "+camlp4"; A "-pp"; A "camlp4o pa_openin.cmo"]);;
>
> You certainly don't want to add these flags to any commands that treat a file
> that is tagged use_openin. You certainly want to add them only for ocaml
> preprocessing.
>
> flag ["ocaml"; "pp"; "use_openin"]
> (A"pa_openin.cmo");;
>
This gets me a little bit closer I think, but I'm still not able to
make ocamlbuild do what I want.
Here's the current code -
test.ml:
let sum l = open List in fold_left (+) 0 l
_tags:
"test.ml": use_openin
myocamlbuild.ml:
open Ocamlbuild_plugin;;
open Command;;
flag ["ocaml"; "pp"; "use_openin"] (A "pa_openin.cmo");;
Using the above "flag ..." line adds "-pp pa_openin.cmo" to the
compilation command line using the following line in _tags:
"test.ml": use_openin
If I change the _tags line to:
"test.ml": camlp4o, use_openin
the output from ocamlbuild test.cma is:
+ /home/hcarty/Applications/godi/bin/ocamldep.opt -pp 'pa_openin.cmo
camlp4o' -modules test.ml > test.ml.depends
sh: pa_openin.cmo: command not found
Preprocessing error on file test.ml
How do I fix this to properly use a syntax extension such as
pa_openin.cmo and be able to specify the location of the .cmo, but
only for the files which need that specific extension? ie. add "-I
+camlp4" to the ocaml* command line, and have the -pp value in the
correct order.
I apologize for asking such a basic question, but I haven't been
able to figure out the answer from the user's guide or other
examples I've found. Once this is all worked out I would be happy
to add this to a wiki somewhere.
Thanks,
Hez
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] ocamlbuild .inferred.mli problem
2007-09-17 18:08 ` Hezekiah M. Carty
@ 2007-09-18 14:49 ` Nicolas Pouillard
0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Pouillard @ 2007-09-18 14:49 UTC (permalink / raw)
To: Hezekiah M. Carty; +Cc: Inria Ocaml Mailing List
Excerpts from Hezekiah M. Carty's message of Mon Sep 17 20:08:49 +0200 2007:
> On Mon, 17 Sep 2007, Nicolas Pouillard wrote:
>
> > > I have also tried creating a myocamlbuild.ml to get around this, but
> > > using something like this in myocamlbuild.ml:
> > >
> > > flag ["use_openin"]
> > > (S [A "-I"; A "+camlp4"; A "-pp"; A "camlp4o pa_openin.cmo"]);;
> >
> > You certainly don't want to add these flags to any commands that treat a file
> > that is tagged use_openin. You certainly want to add them only for ocaml
> > preprocessing.
> >
> > flag ["ocaml"; "pp"; "use_openin"]
> > (A"pa_openin.cmo");;
> >
>
> This gets me a little bit closer I think, but I'm still not able to
> make ocamlbuild do what I want.
>
> Here's the current code -
> test.ml:
> let sum l = open List in fold_left (+) 0 l
Ok
> _tags:
> "test.ml": use_openin
Your second attempt is good you need the camlp4o tag.
> myocamlbuild.ml:
> open Ocamlbuild_plugin;;
> open Command;;
> flag ["ocaml"; "pp"; "use_openin"] (A "pa_openin.cmo");;
You absolutely need to wrap this flag declaration to avoid order of initialization problems (see below).
> Using the above "flag ..." line adds "-pp pa_openin.cmo" to the
> compilation command line using the following line in _tags:
> "test.ml": use_openin
>
> If I change the _tags line to:
> "test.ml": camlp4o, use_openin
Ok
> the output from ocamlbuild test.cma is:
> + /home/hcarty/Applications/godi/bin/ocamldep.opt -pp 'pa_openin.cmo
> camlp4o' -modules test.ml > test.ml.depends
> sh: pa_openin.cmo: command not found
> Preprocessing error on file test.ml
That's due to the order of initialization.
> How do I fix this to properly use a syntax extension such as
> pa_openin.cmo and be able to specify the location of the .cmo, but
> only for the files which need that specific extension? ie. add "-I
> +camlp4" to the ocaml* command line, and have the -pp value in the
> correct order.
$ cat myocamlbuild.ml
open Ocamlbuild_plugin;;
open Command;;
dispatch begin function
| After_rules ->
flag ["ocaml"; "pp"; "use_openin"] (A"pa_openin.cmo");
dep ["ocaml"; "ocamldep"; "use_openin"] ["pa_openin.cmo"];
| _ -> ()
end;;
> I apologize for asking such a basic question, but I haven't been
> able to figure out the answer from the user's guide or other
> examples I've found. Once this is all worked out I would be happy
> to add this to a wiki somewhere.
Yes you're right!
I've quickly added a page on that:
http://brion.inria.fr/gallium/index.php/Ocamlbuild
--
Nicolas Pouillard aka Ertai
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-09-18 14:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-16 2:36 ocamlbuild .inferred.mli problem Hezekiah M. Carty
2007-09-17 14:25 ` [Caml-list] " Nicolas Pouillard
2007-09-17 18:08 ` Hezekiah M. Carty
2007-09-18 14:49 ` Nicolas Pouillard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox