diff --git a/doc/dune-files.rst b/doc/dune-files.rst index 68dc9f79..9fd9a61e 100644 --- a/doc/dune-files.rst +++ b/doc/dune-files.rst @@ -1038,11 +1038,11 @@ the ``-pp`` or ``-ppx`` of the various OCaml tools. Preprocessing with actions ~~~~~~~~~~~~~~~~~~~~~~~~~~ -```` uses the same DSL as described in the `User actions`_ section, and -for the same reason given in that section, it will be executed from the root of -the current build context. It is expected to be an action that reads the file -given as only dependency and outputs the preprocessed file on its standard -output. +```` uses the same DSL as described in the `User actions`_ +section, and for the same reason given in that section, it will be +executed from the root of the current build context. It is expected to +be an action that reads the file given as only dependency named +``input-file`` and outputs the preprocessed file on its standard output. More precisely, ``(preprocess (action ))`` acts as if you had setup a rule for every file of the form: @@ -1055,7 +1055,7 @@ you had setup a rule for every file of the form: (action (with-stdout-to %{@} (chdir %{root} )))) The equivalent of a ``-pp `` option passed to the OCaml compiler is -``(system " %{<}")``. +``(system " %{input-file}")``. Preprocessing with ppx rewriters ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/src/preprocessing.ml b/src/preprocessing.ml index d7584716..1a280a37 100644 --- a/src/preprocessing.ml +++ b/src/preprocessing.ml @@ -456,7 +456,8 @@ let lint_module sctx ~dir ~dep_kind ~lint ~lib_name ~scope ~dir_kind = let src_path = Path.relative dir src.name in add_alias src.name (Build.path src_path - >>^ (fun _ -> Jbuild.Bindings.singleton src_path) + >>^ (fun _ -> + [Jbuild.Bindings.Named ("input-file", [src_path])]) >>> SC.Action.run sctx action ~loc @@ -532,7 +533,7 @@ let make sctx ~dir ~dep_kind ~lint ~preprocess (preprocessor_deps >>> Build.path src - >>^ (fun _ -> Jbuild.Bindings.singleton src) + >>^ (fun _ -> [Jbuild.Bindings.Named ("input-file", [src])]) >>> SC.Action.run sctx (Redirect diff --git a/test/blackbox-tests/test-cases/preprocess-with-action/dune/dune b/test/blackbox-tests/test-cases/preprocess-with-action/dune/dune index e0af31fc..4616e711 100644 --- a/test/blackbox-tests/test-cases/preprocess-with-action/dune/dune +++ b/test/blackbox-tests/test-cases/preprocess-with-action/dune/dune @@ -1,3 +1,3 @@ (test (name test) - (preprocess (action (run pp/pp.exe %{first-dep})))) + (preprocess (action (run pp/pp.exe %{input-file})))) diff --git a/test/blackbox-tests/test-cases/preprocess-with-action/run.t b/test/blackbox-tests/test-cases/preprocess-with-action/run.t index b5f24afd..10bcbf13 100644 --- a/test/blackbox-tests/test-cases/preprocess-with-action/run.t +++ b/test/blackbox-tests/test-cases/preprocess-with-action/run.t @@ -1,4 +1 @@ $ dune runtest - File "dune/dune", line 3, characters 38-48: - Error: unknown variable "first-dep" - [1]