caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] A way to have certain file suffixes treated as .ml/.mli with ocamlbuild.
@ 2015-08-02 19:45 Jordan W
  2015-08-02 20:31 ` Gabriel Scherer
  0 siblings, 1 reply; 2+ messages in thread
From: Jordan W @ 2015-08-02 19:45 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 872 bytes --]

Hello,

Is there a way to have certain files, with particular suffixes, treated as
.ml/.mli respectively with ocamlbuild? I understand that ocaml compiler
itself supports -intf/-impl/-intf-suffix, but it's not clear that
ocamlbuild will allow use of these.

Specifically, here is how all of the ocamlc/ocamldep/* suite of commands
should be effected by the file extension:

*/*.xyz

ocamlc/ocamldep  -pp convertXyzProgram -impl theFile.xyz -intf-suffix xyzi

*/*.xyzi

ocamlc/ocamldep -pp convertXyzProgram -intf theFile.xyzi


Is there a way to do this with _tags or possibly resorting to a
myocamlbuild.ml? I would be satisfied with a myocamlbuild rule that *moves*
the .xyz to a .ml, but in that case errors are reported in terms of the
generated .ml and not the original .xyz, which is unfortunate. I know the
ocaml compler supports this, but does ocamlbuild?

Jordan

[-- Attachment #2: Type: text/html, Size: 1133 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] A way to have certain file suffixes treated as .ml/.mli with ocamlbuild.
  2015-08-02 19:45 [Caml-list] A way to have certain file suffixes treated as .ml/.mli with ocamlbuild Jordan W
@ 2015-08-02 20:31 ` Gabriel Scherer
  0 siblings, 0 replies; 2+ messages in thread
From: Gabriel Scherer @ 2015-08-02 20:31 UTC (permalink / raw)
  To: Jordan W; +Cc: caml-list

I think it should not be terribly hard to implement -intf-suffix and
-impl-suffix in ocamlbuild (you should open a feature wish on the
bugtracker http://caml.inria.fr/mantis/ to keep track of this need).

In the meantime, you can work around the compiler error messages by
using a .xyz -> .ml rule that prepends a lexer directive. At the
beginning of each "foo.ml", have
  # 1 "foo.xyz"
to inform the compiler that the "real filename" is foo.xyz

(This affect compiler-generated errors. OCamlbuild errors (during the
build itself) will still mention the foo.ml file, as the dependency of
foo.xyz that failed to build.)

On Sun, Aug 2, 2015 at 9:45 PM, Jordan W <jordojw@gmail.com> wrote:
> Hello,
>
> Is there a way to have certain files, with particular suffixes, treated as
> .ml/.mli respectively with ocamlbuild? I understand that ocaml compiler
> itself supports -intf/-impl/-intf-suffix, but it's not clear that ocamlbuild
> will allow use of these.
>
> Specifically, here is how all of the ocamlc/ocamldep/* suite of commands
> should be effected by the file extension:
>
> */*.xyz
>
> ocamlc/ocamldep  -pp convertXyzProgram -impl theFile.xyz -intf-suffix xyzi
>
> */*.xyzi
>
> ocamlc/ocamldep -pp convertXyzProgram -intf theFile.xyzi
>
>
> Is there a way to do this with _tags or possibly resorting to a
> myocamlbuild.ml? I would be satisfied with a myocamlbuild rule that *moves*
> the .xyz to a .ml, but in that case errors are reported in terms of the
> generated .ml and not the original .xyz, which is unfortunate. I know the
> ocaml compler supports this, but does ocamlbuild?
>
> Jordan

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-08-02 20:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-02 19:45 [Caml-list] A way to have certain file suffixes treated as .ml/.mli with ocamlbuild Jordan W
2015-08-02 20:31 ` Gabriel Scherer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).