Name the intput file for action preprocessors
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
This commit is contained in:
parent
fa0ab5b4a4
commit
38c0d56ba8
|
@ -1038,11 +1038,11 @@ the ``-pp`` or ``-ppx`` of the various OCaml tools.
|
|||
Preprocessing with actions
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
``<action>`` 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.
|
||||
``<action>`` 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 <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} <action>))))
|
||||
|
||||
The equivalent of a ``-pp <command>`` option passed to the OCaml compiler is
|
||||
``(system "<command> %{<}")``.
|
||||
``(system "<command> %{input-file}")``.
|
||||
|
||||
Preprocessing with ppx rewriters
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
(test
|
||||
(name test)
|
||||
(preprocess (action (run pp/pp.exe %{first-dep}))))
|
||||
(preprocess (action (run pp/pp.exe %{input-file}))))
|
||||
|
|
|
@ -1,4 +1 @@
|
|||
$ dune runtest
|
||||
File "dune/dune", line 3, characters 38-48:
|
||||
Error: unknown variable "first-dep"
|
||||
[1]
|
||||
|
|
Loading…
Reference in New Issue