How can I declare a (module) dependency manually without require
ing it?
I have found the function register-external-module, but it only adds an additional dependency after the code has been compiled. In other words, the new dependencies work only after re-compilation.
Here is an example code that demonstrates the problem:
;; main.rkt
#lang racket/base
(require (for-syntax racket/base compiler/cm-accomplice))
(define-syntax (ghost-require stx)
(syntax-case stx ()
[(_ relative-path)
(register-external-module (path->complete-path (syntax-e #'relative-path)))
#'(begin)]))
(ghost-require "ext.rkt")
I hope that compiling main.rkt
using raco make
would trigger the compilation of ext.rkt
, while instantiating main.rkt
itself would not load or instantiate ext.rkt
. Is this possible? With ghost-require
, I need to compile make.rkt
twice to actually compile ext.rkt
.
$ raco make -v main.rkt
"main.rkt":
making #<path:...cm/main.rkt>
[output to "compiled/main_rkt.zo"]
$ ls compiled
main_rkt.dep main_rkt.zo
$ raco make -v main.rkt
"main.rkt":
making #<path:...cm/ext.rkt>
making #<path:...cm/main.rkt>
[output to "compiled/main_rkt.zo"]
$ ls compiled
ext_rkt.dep ext_rkt.zo main_rkt.dep main_rkt.zo
$