caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Edgar Friendly <thelema314@gmail.com>
To: caml-list@yquem.inria.fr
Subject: Conditional compilation
Date: Mon, 17 Aug 2009 22:00:28 -0400	[thread overview]
Message-ID: <4A8A0B3C.10504@gmail.com> (raw)

I'm working on a project that has significant build infrastructure using
autoconf, make and ocamlbuild.  I want to have a reasonably simple
trigger, such as a command-line argument to autoconf.  The result of
activating this trigger would be to drastically reduce what gets
compiled -- many files wouldn't need to be compiled, and many sections
of files should be commented out.

The project already uses optcomp for some conditional compilation based
on ocaml version.  I've learned that optcomp creates a new camlp4
command-line flag, [-let], which accepts a "var=value" pair and sets
that for use in [#if var = value] triggers.  I've also dug into
ocamlbuild and found a way to set this flag within the [-pp] argument to
ocamlc.  I've hit some hurdles, and wonder how to overcome them:

1) optcomp is sometimes used as a standalone camlp4 executable (-pp
'build/optcomp/optcomp_o.byte') - in this mode, it seems to accept only
the name of a file as input, and doesn't take the [-let] argument.  What
is the difference between this and "-pp 'camlp4oof
build/optcomp/pa_optcomp.cmo'"?

2) I'm using the identifier "AAA" for my trigger, and I can use
ocamlbuild's tags system to set "-let AAA=true" when the tag "AAA" is
set - is there any way to do "-let AAA=false" when tag "AAA" is unset?
Optcomp gives a compilation error on bound identifiers, so I have to set
it in both cases.

Is there a better way to do this?  The path I'm following is looking
very byzantine compared to C's [-DFOO] + [#ifdef FOO].

E


             reply	other threads:[~2009-08-18  2:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-18  2:00 Edgar Friendly [this message]
2009-08-18  2:26 ` [Caml-list] " Andre Nathan
2009-08-18  2:37   ` Edgar Friendly
2009-08-18  7:00     ` Olivier Andrieu
2009-08-21  9:39   ` Pietro Abate
2009-08-18 10:20 ` Richard Jones

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=4A8A0B3C.10504@gmail.com \
    --to=thelema314@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    /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).