Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006103OCamlOCamlbuild (the tool)public2013-07-29 19:082014-08-21 11:43
Reportergasche 
Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
StatusacknowledgedResolutionopen 
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 test.ml:
  IFDEF FOO THEN
    print_endline "foo"
  ELSE
    print_endline "bar"
  ENDIF

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 test.ml # 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 test.ml > test.ml.depends
  Warning: -pp overrides the effect of -syntax partly
  sh: 0: Illegal option -D
  Preprocessing error on file test.ml

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 .pp.ml 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.)
Tagsjunior_job
Attached Files

- Relationships

-  Notes
There are no notes attached to this issue.

- 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 =>


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker