Skip to content

Add Make/Dune target for debug printers #1289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ocaml/Makefile.common-jst
Original file line number Diff line number Diff line change
Expand Up @@ -357,3 +357,10 @@ hacking-emacs-poller: _build/_bootinstall
hacking-emacs-builder: _build/_bootinstall
$(dune) rpc build $(ws_boot) -w $(boot_targets)
$(dune) diagnostics

.PHONY: debug-printers
debug-printers: runtime-stdlib # required for $(ws_main) to work
$(dune) build $(ws_main) $(ocamldir)/tools/debug_printers
@echo
@echo To load into ocamldebug, use:
@echo source \"$$(realpath _build/main/$(ocamldir)/tools/debug_printers)\"
17 changes: 17 additions & 0 deletions ocaml/tools/dune
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,22 @@
(section lib)
(package ocaml))

(library
(name debug_printers)
(modes byte)
(libraries ocamlcommon)
(modules debug_printers))

(rule
(target debug_printers)
(deps debug_printers.ml %{cmo:debug_printers})
(action
(with-stdout-to %{target}
(progn
; Resorting to Bash instead of the built-in [echo] action because I
; couldn't find a better way to get an absolute path out of Dune
(bash "echo load_printer \\\"$(realpath %{cmo:debug_printers})\\\"")
(with-stdin-from debug_printers.ml
(run awk "{ print \"install_printer Debug_printers.\" $2 }"))))))

; ocamlcp, ocamloptp and ocamlprof are not currently supported.