Skip to content

Commit

Permalink
fix: Revert "fix: Invoke preprocessor commands from local dir" (#7169)
Browse files Browse the repository at this point in the history
Running the preprocessor from cwd breaks the error messages outputted by
the preprocessor.

Signed-off-by: Rudi Grinberg <[email protected]>
  • Loading branch information
rgrinberg authored Feb 24, 2023
1 parent 927b672 commit 6fa1a17
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
3 changes: 0 additions & 3 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ Unreleased
- Non-user proccesses such as version control or config checking are now run
silently. (#6994, fixes #4066, @Alizter)

- Invoke preprocessor commands from directory of dune file containing the
commands rather than from the workspace root (#7057, fixes #7043, @gridbugs)

- Add the `--display-separate-messages` flag to separate the error messages
produced by commands with a blank line. (#6823, fixes #6158, @esope)

Expand Down
5 changes: 1 addition & 4 deletions src/dune_rules/preprocessing.ml
Original file line number Diff line number Diff line change
Expand Up @@ -705,11 +705,8 @@ let pp_one_module sctx ~lib_name ~scope ~preprocessor_deps
(let open Action_builder.O in
preprocessor_deps
>>> let* exe, flags, args = driver_and_flags in
let project = Scope.project scope in
let dune_version = Dune_project.dune_version project in
let dir =
if dune_version >= (3, 8) then Path.build dir
else Path.build (Super_context.context sctx).build_dir
Path.build (Super_context.context sctx).build_dir
in
Command.run' ~dir
(Ok (Path.build exe))
Expand Down
14 changes: 3 additions & 11 deletions test/blackbox-tests/test-cases/preprocessor-directory.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,13 @@ the preprocessor command. There are two rewrite.sh scripts in this test: one in
the root directory which rewrites the source to print "foo ..." and one in the
src directory which writes the source to print "bar ...".

Initially the project uses dune lang 3.7 so the preprocessor command is invoked
from the project root:
The preprocessor command is invoked from the workspace root:
$ cat dune-project
(lang dune 3.7)
(package (name foo))
$ dune exec ./src/foo.exe
foo (from the rewrite.sh script in the project root directory)

Change the versiono of the dune language to 3.8:
$ sed -i.bak 's/(lang dune 3.7)/(lang dune 3.8)/' $(readlink dune-project)

Now the preprocessor should be invoked from the src directory because the dune
file which specifies the preprocessor is located there:
$ cat dune-project
(lang dune 3.8)
(package (name foo))
This is unintended. We should be printing bar:
$ dune exec ./src/foo.exe
bar (from the rewrite.sh script in the src directory)
foo (from the rewrite.sh script in the project root directory)

0 comments on commit 6fa1a17

Please sign in to comment.