Skip to content

Allow make debug with dune-based build #1480

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 3 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,6 @@ _coverage/
# Jane Street Merlin support
/.local-merlin-binaries
/.local-ocaml-lib

# Debugger support
ocamlc
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,17 @@ coverage: boot-runtest
--source-path=. \
--source-path=_build/default
@echo Coverage report generated in _coverage/index.html

.PHONY: debug
.NOTPARALLEL: debug
debug: install ocaml/tools/debug_printers ocamlc

ocamlc:
ln -s $(prefix)/bin/ocamlc.byte ocamlc

ocaml/tools/debug_printers: ocaml/tools/debug_printers.ml ocaml/tools/debug_printers.cmo
echo 'load_printer "ocaml/tools/debug_printers.cmo"' > $@
awk '{ print "install_printer Debug_printers." $$2 }' < $< >> $@

ocaml/tools/debug_printers.cmo: ocaml/tools/debug_printers.ml _build/install/main/bin/ocamlc.byte
_build/install/main/bin/ocamlc.byte -c -I _build/main/ocaml/.ocamlcommon.objs/byte ocaml/tools/debug_printers.ml
12 changes: 0 additions & 12 deletions ocaml/tools/dune
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,4 @@
(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.