Some extra helper functions
This commit is contained in:
@@ -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.2.zip
|
||||
raco pkg install --name racket-makefile racket-makefile-0.1.4.zip
|
||||
```
|
||||
|
||||
## Running targets
|
||||
@@ -78,6 +78,36 @@ 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`.
|
||||
|
||||
## Regexp-based cleanup
|
||||
|
||||
For cleanup rules that need more control than globs, `racket-makefile` also
|
||||
provides small directory/regexp helpers. The results are ordinary path lists,
|
||||
so they can be passed directly to `rm-f` and `rm-rf` with `apply`:
|
||||
|
||||
```racket
|
||||
#lang racket-makefile
|
||||
|
||||
(default-target all)
|
||||
(phony all clean)
|
||||
|
||||
(target all
|
||||
(displayln "use (make clean)"))
|
||||
|
||||
(target clean
|
||||
(display "cleaning up...")
|
||||
(apply rm-rf
|
||||
(list-dirs "." #px"compiled$" #:recursive #t))
|
||||
(apply rm-f
|
||||
(list-files "." #px"(?i:(?:[.]bak|~)$)" #:recursive #t))
|
||||
(displayln "done."))
|
||||
```
|
||||
|
||||
`list-dir/files` returns matching files and directories. `list-files` and
|
||||
`list-dirs` restrict the result to files or directories. All three scan one
|
||||
directory level by default; use `#:recursive #t` to walk the complete tree.
|
||||
Non-recursive results are returned as complete paths, so the lists can be fed
|
||||
directly to `rm-f` or `rm-rf` with `apply`.
|
||||
|
||||
## Generated targets
|
||||
|
||||
Because the rest of the language is ordinary Racket, targets can be generated
|
||||
@@ -101,7 +131,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`, `$target`, `$deps` and `$<`. Everything else is
|
||||
ordinary Racket.
|
||||
`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