Skip to content

Commit 1deb5af

Browse files
authored
flambda-backend: Add Make/Dune target for debug printers (#1289)
1 parent 324f32e commit 1deb5af

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

Makefile.common-jst

+7
Original file line numberDiff line numberDiff line change
@@ -357,3 +357,10 @@ hacking-emacs-poller: _build/_bootinstall
357357
hacking-emacs-builder: _build/_bootinstall
358358
$(dune) rpc build $(ws_boot) -w $(boot_targets)
359359
$(dune) diagnostics
360+
361+
.PHONY: debug-printers
362+
debug-printers: runtime-stdlib # required for $(ws_main) to work
363+
$(dune) build $(ws_main) $(ocamldir)/tools/debug_printers
364+
@echo
365+
@echo To load into ocamldebug, use:
366+
@echo source \"$$(realpath _build/main/$(ocamldir)/tools/debug_printers)\"

tools/dune

+17
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,22 @@
8585
(section lib)
8686
(package ocaml))
8787

88+
(library
89+
(name debug_printers)
90+
(modes byte)
91+
(libraries ocamlcommon)
92+
(modules debug_printers))
93+
94+
(rule
95+
(target debug_printers)
96+
(deps debug_printers.ml %{cmo:debug_printers})
97+
(action
98+
(with-stdout-to %{target}
99+
(progn
100+
; Resorting to Bash instead of the built-in [echo] action because I
101+
; couldn't find a better way to get an absolute path out of Dune
102+
(bash "echo load_printer \\\"$(realpath %{cmo:debug_printers})\\\"")
103+
(with-stdin-from debug_printers.ml
104+
(run awk "{ print \"install_printer Debug_printers.\" $2 }"))))))
88105

89106
; ocamlcp, ocamloptp and ocamlprof are not currently supported.

0 commit comments

Comments
 (0)