Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ocamlbuild support for ocamlfind's -ppopt option #6103

Closed
vicuna opened this issue Jul 29, 2013 · 1 comment
Closed

Add ocamlbuild support for ocamlfind's -ppopt option #6103

vicuna opened this issue Jul 29, 2013 · 1 comment

Comments

@vicuna
Copy link

vicuna commented Jul 29, 2013

Original bug ID: 6103
Reporter: @gasche
Status: resolved (set by @damiendoligez on 2017-03-01T15:23:06Z)
Resolution: suspended
Priority: normal
Severity: feature
Category: -for ocamlbuild use https://github.com/ocaml/ocamlbuild/issues
Tags: junior_job

Bug description

The 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.)

@vicuna
Copy link
Author

vicuna commented Mar 1, 2017

Comment author: @damiendoligez

ocamlbuild is now a separate project that lives on GitHub.
PR transferred to ocaml/ocamlbuild#190

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant