caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gabriel Scherer <gabriel.scherer@gmail.com>
To: Jordan W <jordojw@gmail.com>
Cc: "caml-list@inria.fr" <caml-list@inria.fr>
Subject: Re: [Caml-list] A way to have certain file suffixes treated as .ml/.mli with ocamlbuild.
Date: Sun, 2 Aug 2015 22:31:47 +0200	[thread overview]
Message-ID: <CAPFanBFea3+5oLxTRe1NDgV2Ay+h9Ps4SSxJuGLnLaKbN2o2DA@mail.gmail.com> (raw)
In-Reply-To: <CAPOA5_6GUaMeNP0ic5KB0vF9v6hRe-=htppkks_ytyHQBeSOqw@mail.gmail.com>

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

      reply	other threads:[~2015-08-02 20:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-02 19:45 Jordan W
2015-08-02 20:31 ` Gabriel Scherer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPFanBFea3+5oLxTRe1NDgV2Ay+h9Ps4SSxJuGLnLaKbN2o2DA@mail.gmail.com \
    --to=gabriel.scherer@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=jordojw@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).