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

Combine future_syntax with other preprocessors? #1934

Open
rdavison opened this issue Mar 12, 2019 · 7 comments
Open

Combine future_syntax with other preprocessors? #1934

rdavison opened this issue Mar 12, 2019 · 7 comments

Comments

@rdavison
Copy link
Contributor

Is there some way to specify (preprocess future_syntax) in combination with other preprocessors? None of the following seem to work:

(library
  (name foo)
  (libraries core)
  (preprocess future_syntax (pps ppx_jane)))
(library
  (name foo)
  (libraries core)
  (preprocess (pps future_syntax ppx_jane)))
(library
  (name foo)
  (libraries core)
  (preprocess future_syntax)
  (preprocess (pps ppx_jane)))
@ghost
Copy link

ghost commented Mar 12, 2019

No, it is not possible. I suppose the easiest way to make that work would be to add the same hack in ppxlib directly.

@Dean177
Copy link
Contributor

Dean177 commented Jun 10, 2019

@rdavidson see #2262 for a solution

@Alizter
Copy link
Collaborator

Alizter commented Mar 11, 2023

Appears that there is a viable work around.

@Alizter Alizter closed this as completed Mar 11, 2023
@aantron
Copy link
Collaborator

aantron commented May 1, 2023

What is the syntax for the workaround currently? I tried

(preprocess (pps ppxlib.metaquot -- -pp %{bin:ocaml-syntax-shims}))

but the result is that the ASTs in my project appear to be empty.

  1. I am working in Bisect_ppx.
  2. If src/ppx/dune is
(ocamllex exclude_lexer)
(ocamlyacc exclude_parser)

(library
 (name bisect_ppx)
 (public_name bisect_ppx)
 (kind ppx_rewriter)
 (instrumentation.backend (ppx bisect_ppx))
 (synopsis "Code coverage for OCaml")
 (ppx_runtime_libraries bisect_ppx.runtime)
 (preprocess (pps ppxlib.metaquot -- -pp %{bin:ocaml-syntax-shims}))
 (flags (:standard -open Ocaml_shadow))
 (libraries bisect_ppx.common ppxlib str))

Note the -- -pp %{bin:ocaml-syntax-shims}.

I then run

$ ocamlc _build/default/src/ppx/instrument.pp.ml -dparsetree 2>&1 | wc -l

The result is 87, way too few lines for the expected AST from instrument.ml. By comparison, without ocaml-syntax-shims,

$ ocamlc _build/default/src/ppx/instrument.pp.ml -dparsetree 2>&1 | wc -l

shows 19611 lines.

It does not appear that this issue has been fixed, or I am not able to understand how to use the workaround. cc @aalekseyev @Dean117, is this workaround working for you today in some way?

It appears I am able to reopen this issue. Not sure if that's appropriate -- please just close again if not!

@aantron aantron reopened this May 1, 2023
@aantron
Copy link
Collaborator

aantron commented May 1, 2023

This was Dune 3.7.1, OCaml 4.13.1, ocaml-syntax-shims 1.0.0.

@Alizter
Copy link
Collaborator

Alizter commented May 9, 2023

@aantron The issue is that %{bin:...} is not being expanded correctly in the preprocess field. To get around this you can copy the binary and directly mention the copy instead.

#2262 (comment)

It might be worth keeping this open actually as it might be something that @anmonteiro can support with #7373.

@aantron
Copy link
Collaborator

aantron commented May 10, 2023

We couldn't get copy to work either. I don't have the exact error message immediately available right now.

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

No branches or pull requests

4 participants