Added makefile.rkt
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
racket/file
|
||||
(only-in racket-makefile
|
||||
target deps phony default-target make
|
||||
run rm-f rm-rf cleanup
|
||||
run raco rm-f rm-rf cleanup
|
||||
list-dir/files list-files list-dirs
|
||||
$target $deps $<)))
|
||||
|
||||
@@ -14,8 +14,7 @@
|
||||
@defmodulelang[racket-makefile]
|
||||
|
||||
@tt{racket-makefile} is a small make-style language built on Racket. It adds
|
||||
targets, dependencies, timestamp based rebuilding, phony targets, command
|
||||
execution, and a few cleanup helpers. The rest of the language is ordinary
|
||||
targets, dependencies, timestamp based rebuilding, phony targets, command execution, Racket tool execution, and a few cleanup helpers. The rest of the language is ordinary
|
||||
Racket.
|
||||
|
||||
A makefile only defines targets. Loading or running the module does not execute
|
||||
@@ -32,7 +31,7 @@ raco pkg install
|
||||
For a versioned archive, specify the package name explicitly:
|
||||
|
||||
@verbatim{
|
||||
raco pkg install --name racket-makefile racket-makefile-0.1.4.zip
|
||||
raco pkg install --name racket-makefile racket-makefile-0.1.5.zip
|
||||
}
|
||||
|
||||
After installation a makefile can start with:
|
||||
@@ -195,6 +194,36 @@ Ordinary Racket values can be inserted with quasiquote:
|
||||
(run `(,CC ,@CFLAGS -o $target $<)))
|
||||
]
|
||||
|
||||
@section{Running Racket tools}
|
||||
|
||||
@defproc[(raco [command list?]) void?]{
|
||||
Runs a @tt{raco} command using the @tt{raco} executable that belongs to the
|
||||
Racket installation currently running the makefile. The helper first checks
|
||||
the console binary directory reported by the current Racket installation, then
|
||||
the directory containing the current @tt{racket} executable, and only then
|
||||
falls back to @tt{PATH}. This makes the helper useful on Windows installations
|
||||
where @tt{raco.exe} is installed next to @tt{racket.exe} but is not on
|
||||
@tt{%PATH%}.
|
||||
|
||||
The command syntax is the same as for @racket[run], except that the executable
|
||||
is supplied automatically. Symbols, strings, paths and numbers are converted
|
||||
to command-line arguments, nested lists are flattened, and the recipe values
|
||||
@racket['$target], @racket['$deps], and @racket['$<] are supported. A non-zero
|
||||
result raises an error.
|
||||
}
|
||||
|
||||
For example:
|
||||
|
||||
@racketblock[
|
||||
(phony setup test)
|
||||
|
||||
(target setup
|
||||
(raco '(setup racket-makefile)))
|
||||
|
||||
(target test
|
||||
(raco '(test -p racket-makefile)))
|
||||
]
|
||||
|
||||
@section{Cleanup helpers}
|
||||
|
||||
@defproc[(rm-f [path path-string?] ...) void?]{
|
||||
@@ -271,7 +300,7 @@ These helpers make regexp-based cleanup concise. For example:
|
||||
(apply rm-rf
|
||||
(list-dirs "." #px"compiled$" #:recursive #t))
|
||||
(apply rm-f
|
||||
(list-files "." #px"(?i:(?:[.]bak|~)$)" #:recursive #t))
|
||||
(list-files "." #px"(?i:([.]bak|~)$)" #:recursive #t))
|
||||
(displayln "done."))
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user