Added makefile.rkt
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
`racket-makefile` is a small `#lang` for make-style builds. It keeps ordinary
|
||||
Racket available and only adds targets, dependencies, timestamp based rebuilds,
|
||||
phony targets, external command execution and a few cleanup helpers.
|
||||
phony targets, external command execution, Racket tool execution and a few cleanup helpers.
|
||||
|
||||
A makefile only defines its targets. Loading or running the file does not build
|
||||
anything by itself. Builds are started explicitly with `make`.
|
||||
@@ -40,7 +40,7 @@ raco pkg install
|
||||
For a versioned archive, give the package name explicitly:
|
||||
|
||||
```text
|
||||
raco pkg install --name racket-makefile racket-makefile-0.1.4.zip
|
||||
raco pkg install --name racket-makefile racket-makefile-0.1.5.zip
|
||||
```
|
||||
|
||||
## Running targets
|
||||
@@ -78,6 +78,31 @@ registers the targets. Then use the Interactions window:
|
||||
Bare identifiers in `make` are target names, so no quote is needed. For
|
||||
example, `(make clean)` selects the target named `clean`.
|
||||
|
||||
## Running Racket tools with `raco`
|
||||
|
||||
Use `raco` to invoke a Racket tool from a target without depending on `%PATH%`
|
||||
or `$PATH`:
|
||||
|
||||
```racket
|
||||
(phony setup test)
|
||||
|
||||
(target setup
|
||||
(raco '(setup racket-makefile)))
|
||||
|
||||
(target test
|
||||
(raco '(test -p racket-makefile)))
|
||||
```
|
||||
|
||||
`racket-makefile` first looks for `raco` in the console binary directory of
|
||||
the Racket installation that is currently running the makefile. It then tries
|
||||
the directory containing the current `racket` executable and uses `PATH` only
|
||||
as a final fallback. On Windows this normally finds `raco.exe` next to
|
||||
`racket.exe` even when the Racket directory is not in `%PATH%`.
|
||||
|
||||
The argument rules are the same as for `run`: symbols, strings, paths and
|
||||
numbers are converted to command-line arguments, nested lists are flattened,
|
||||
and `$target`, `$deps` and `$<` are available inside a recipe.
|
||||
|
||||
## Regexp-based cleanup
|
||||
|
||||
For cleanup rules that need more control than globs, `racket-makefile` also
|
||||
@@ -98,7 +123,7 @@ so they can be passed directly to `rm-f` and `rm-rf` with `apply`:
|
||||
(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."))
|
||||
```
|
||||
|
||||
@@ -131,7 +156,7 @@ with normal definitions and loops:
|
||||
Dependency expressions may produce lists; they are recursively flattened.
|
||||
|
||||
The language adds `target`, `deps`, `phony`, `default-target`, `make`, `run`,
|
||||
`rm-f`, `rm-rf`, `cleanup`, `list-dir/files`, `list-files`, `list-dirs`,
|
||||
`raco`, `rm-f`, `rm-rf`, `cleanup`, `list-dir/files`, `list-files`, `list-dirs`,
|
||||
`$target`, `$deps` and `$<`. Everything else is ordinary Racket.
|
||||
|
||||
See the installed `racket-makefile` Scribble documentation for the full API.
|
||||
|
||||
Reference in New Issue
Block a user