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
ocamlbuild's ocamlfind integration doesn't support syntax extensions #5548
Comments
Comment author: @gasche I discussed this with xclerc and therefore mark this as "acknowledged". If someone in the respected audience has a patch, please submit it! (Sane) contributions to fix ocamlbuild deficiencies are always welcome. |
Comment author: meyer So ocamlbuild just does not use ocamlfind in this case. This definetely needs fixing. |
Comment author: @gasche This PR has in fact seen invisible progress: in the SVN commit 13262, Wojciech implemented a "-syntax " command-line option for ocamlbuild, meant to be used exactly as for ocamlfind. It is equivalent to passing the tag "syntax(foo)". You can therefore use
to compile test.ml into test.byte. For example for test.ml as such: You can use the two equivalent commands: ocamlbuild -use-ocamlfind -tag "syntax(camlp4o -DBLAH)" -package camlp4.macro test.byte However, the target .pp.ml still does not work as expected. I know of no easy way to call ocamlfind for only the preprocessing phase, and get source code as a result (in particular there is no "ocamlfind camlp4* -package ..." invocation possible. Options for implementing this would be to: (1) re-implement the build-camlp4-invocation-command logic in ocamlbuild (reusing the ocamlfind-like logic that was present before -use-ocamlfind was implemented), by calling "ocamlfind query" to get the right option to pass to the preprocessor; painful and probably not the best solution (2) work-around the issue the issue by internally calling "ocamlfind ocamlc -syntax camlp4o ... -dsource" to convince ocamlfind that he's invoking a compiler, but actually get the postprocessed source code from ocaml. Not satisfying right now as there is no "-stop-after-parsing" flag to feed to the compiler, and it would still e.g. fail on ill-typed files. It's still a credible option, and in particular could be the best one if we want pp.ml to also perform -ppx rewritings. (3) implement the "ocamlfind camlp4*" command. I have not contacted Gerd to know whether that would be possible, but I would suspect that if this (rather natural) feature is not present, he possibly has already considered that and has good reason not to do it. In any case, none of those options are realistic during a feature freeze, so I'm moving the .pp.ml part of this bug (the rest I consider solved) to 4.02+dev. |
Comment author: @damiendoligez ocamlbuild is now a separate project that lives on GitHub. |
Original bug ID: 5548
Reporter: @gasche
Assigned to: @gasche
Status: resolved (set by @damiendoligez on 2017-03-03T14:26:46Z)
Resolution: suspended
Priority: normal
Severity: feature
Category: -for ocamlbuild use https://github.com/ocaml/ocamlbuild/issues
Related to: #6102
Monitored by: @gasche mehdi @diml @hcarty @avsm
Bug description
OCamlbuild's ocamlfind integration includes -I-options and stuff from ocamlfind in the "compile" and "link" ocamlbuild steps but, to my knowledge, does not include them during preprocessing ("pp"). This means that while ocamlfind libraries can be used, I don't know how to use their attached syntax extensions (ocamlfind's predicate "syntax"). It would be nice if that was fixed.
Steps to reproduce
With some ocamlfind package "foo.syntax" that enables syntax extensions, and some file "test.ml" using the extension,
ocamlfind ocamlc -syntax camlp4o -package foo.syntax test.ml
does not raise a syntax error, while for instance
ocamlbuild -use-ocamlfind -tag "package(foo.syntax)" test.pp.ml
does (because neither ocamlfind's -I-option nor the camlp4 extension archive name are included in the camlp4o invocation).
Additional information
I have discussed this with Anil Madhavapeddy which mentioned a related need on the mailing list:
https://groups.google.com/forum/#!topic/fa.caml/y6VsobyJV0s/discussion
The text was updated successfully, but these errors were encountered: