Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006103OCaml-for ocamlbuild use 19:082017-03-01 16:23
Assigned To 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0006103: Add ocamlbuild support for ocamlfind's -ppopt option
DescriptionThe current ocamlbuild support for -pp flags is not satisfying for preprocessing commands that need user-passed arguments. It is possible to pass "-pp foo" and "-ppflag foo" to the command-line invocation of ocamlbuild, but they will replace the preprocessor invocation command instead of being appended to it.

Consider the following file
    print_endline "foo"
    print_endline "bar"

The following will work:
  ocamlbuild -tag "pp(camlp4of -DFOO)" test.byte
the following will also work:
  ocamlbuild -ppflag camlp4of -ppflag -DFOO test.byte
they both generate the command
  .../ocamlc.opt -c -pp 'camlp4of -DFOO' -o test.cmo # cached

but the following will fail:
  ocamlbuild -use-ocamlfind -tag "syntax(camlp4o)" -package camlp4.macro -ppflag -DFOO test.byte

  + /usr/bin/ocamlfind ocamldep -package camlp4.macro -syntax camlp4o -pp -DFOO -modules >
  Warning: -pp overrides the effect of -syntax partly
  sh: 0: Illegal option -D
  Preprocessing error on file

It would be useful to directly support ocamlfind's -ppopt option
(when -use-ocamlfind is used), that doesn't replace the preprocessor
command entirely but only appends to it. One would then be able to do
(I'm using below the new "-syntax" command-line option corresponding
to the flag):
  ocamlbuild -use-ocamlfind -syntax camlp4o -package camlp4.macro -ppopt -DFOO test.byte

Of course, it is important to also have a "ppopt(-DFOO)" parametrized
flag to be able to use it locally.

Note that, as a workaround, it is currently possible to pass -ppopt as
a -cflags parameter:
  ocamlbuild -use-ocamlfind -syntax camlp4o -package camlp4.macro -cflags -ppopt,-DFOO test.byte

The problem is that only works during "compile" steps, and will not
work, for example, when building a target.

(In the long-term it is unclear to me whether having both -ppflag and -ppopt is useful, and we should not use the appending semantics of -ppopt for -ppflag as well. This would have backward-compatibility implications though, so it's better left for later.)
Attached Files

- Relationships

-  Notes
doligez (administrator)
2017-03-01 16:22

ocamlbuild is now a separate project that lives on GitHub.
PR transferred to [^]

- Issue History
Date Modified Username Field Change
2013-07-29 19:08 gasche New Issue
2013-07-29 19:08 gasche Tag Attached: junior_job
2013-07-29 20:18 gasche Description Updated View Revisions
2013-08-28 11:17 doligez Status new => acknowledged
2014-05-25 20:24 doligez Target Version 4.01.1+dev => 4.02.0+dev
2014-08-21 11:43 doligez Target Version 4.02.0+dev =>
2017-02-23 16:34 doligez Category OCamlbuild (the tool) => for ocamlbuild use [^]
2017-02-23 16:44 doligez Category for ocamlbuild use [^] => -for ocamlbuild use [^]
2017-03-01 16:22 doligez Note Added: 0017520
2017-03-01 16:23 doligez Status acknowledged => resolved
2017-03-01 16:23 doligez Resolution open => suspended

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker