Skip to content

Commit

Permalink
fix: dune describe pp no longer dumps into source root
Browse files Browse the repository at this point in the history
We also fix this by running ocamlc in the _build directory and cleaning
up the dump file afterwards.

- fix ocaml#7430
- [x] changelog

Signed-off-by: Ali Caglayan <alizter@gmail.com>
  • Loading branch information
Alizter committed Aug 10, 2023
1 parent 758e370 commit 1400ca3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
10 changes: 8 additions & 2 deletions bin/describe/describe_pp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,21 @@ let pp_with_ocamlc sctx project pp_file =
let+ () =
Process.run
~display:!Clflags.display
~dir:(Path.build (Super_context.context sctx).build_dir)
~env:(Super_context.context_env sctx)
Strict
(Super_context.context sctx).ocaml.ocamlc
[ "-stop-after"; "parsing"; "-dsource"; Path.to_string pp_file; "-dump-into-file" ]
[ "-stop-after"
; "parsing"
; "-dsource"
; Path.to_string (Path.drop_optional_build_context_maybe_sandboxed pp_file)
; "-dump-into-file"
]
in
match Path.stat dump_file with
| Ok { st_kind = S_REG; _ } ->
Io.cat dump_file;
Path.unlink_no_err dump_file
Path.unlink dump_file
| _ ->
User_error.raise [ Pp.textf "cannot find a dump file: %s" (Path.to_string dump_file) ]
;;
Expand Down
2 changes: 2 additions & 0 deletions doc/changes/8340.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fix `dune describe pp` from leaving behind a dump file. (#8222, fixes #7430,
@Alizter)
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ We can also show the original source if it is not preprocessed
We also make sure that the dump file is not present

$ dune_cmd exists profile.dump
true
false

0 comments on commit 1400ca3

Please sign in to comment.