Merge pull request #3 from Kreyren/patch-3
README: Declare formatting for scheme codeblocks
This commit is contained in:
commit
bea938f6dc
30
README.md
30
README.md
@ -9,21 +9,26 @@ build script in Guile Scheme.
|
|||||||
|
|
||||||
Add this at the top of your build script.
|
Add this at the top of your build script.
|
||||||
|
|
||||||
|
```scheme
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
exec guile -s "$0" "$@"
|
exec guile -s "$0" "$@"
|
||||||
!#
|
!#
|
||||||
|
|
||||||
(use-modules (potato make))
|
(use-modules (potato make))
|
||||||
(initialize)
|
(initialize)
|
||||||
|
```
|
||||||
|
|
||||||
Add this at the bottom of your build script
|
Add this at the bottom of your build script
|
||||||
|
|
||||||
|
```scheme
|
||||||
(execute)
|
(execute)
|
||||||
|
```
|
||||||
|
|
||||||
The rules go in between `initialize` and `build`.
|
The rules go in between `initialize` and `build`.
|
||||||
|
|
||||||
## A Simple Example
|
## A Simple Example
|
||||||
|
|
||||||
|
```scheme
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
exec guile -s "$0" "$@"
|
exec guile -s "$0" "$@"
|
||||||
!#
|
!#
|
||||||
@ -39,6 +44,7 @@ The rules go in between `initialize` and `build`.
|
|||||||
(-> ".c" ".o"
|
(-> ".c" ".o"
|
||||||
(~ ($ CC) "-c" $<))
|
(~ ($ CC) "-c" $<))
|
||||||
(execute)
|
(execute)
|
||||||
|
```
|
||||||
|
|
||||||
## Command-Line Arguments
|
## Command-Line Arguments
|
||||||
|
|
||||||
@ -108,70 +114,90 @@ You define makevars in the script, in the environment, or on the command line.
|
|||||||
The *target rule* is for when the target, and the prerequisites, if any,
|
The *target rule* is for when the target, and the prerequisites, if any,
|
||||||
have filenames or phony names.
|
have filenames or phony names.
|
||||||
|
|
||||||
|
```scheme
|
||||||
(: target-name '(prereq-name-1 prereq-name-2 ...)
|
(: target-name '(prereq-name-1 prereq-name-2 ...)
|
||||||
recipe-1
|
recipe-1
|
||||||
recipe-2
|
recipe-2
|
||||||
...)
|
...)
|
||||||
|
```
|
||||||
|
|
||||||
`target-name` is a string which is either a filename to be
|
`target-name` is a string which is either a filename to be
|
||||||
created or an phony name like "all" or "clean".
|
created or an phony name like "all" or "clean".
|
||||||
|
|
||||||
Recipe as a string to be evaluated by the system
|
Recipe as a string to be evaluated by the system
|
||||||
|
|
||||||
|
```scheme
|
||||||
(: "foo.o" '("foo.c")
|
(: "foo.o" '("foo.c")
|
||||||
"cc -c foo.o")
|
"cc -c foo.o")
|
||||||
|
```
|
||||||
|
|
||||||
Recipe as a procedure
|
Recipe as a procedure
|
||||||
|
|
||||||
|
```scheme
|
||||||
(: "clean-foo" '()
|
(: "clean-foo" '()
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(delete-file "foo.o")))
|
(delete-file "foo.o")))
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
Recipe as a procedure that returns #f to indicate failure
|
Recipe as a procedure that returns #f to indicate failure
|
||||||
|
|
||||||
|
```scheme
|
||||||
(: "recent" '()
|
(: "recent" '()
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(if condition
|
(if condition
|
||||||
#t
|
#t
|
||||||
#f))))
|
#f))))
|
||||||
|
```
|
||||||
|
|
||||||
Recipe as a procedure returning a string to be evaluated by the
|
Recipe as a procedure returning a string to be evaluated by the
|
||||||
system
|
system
|
||||||
|
|
||||||
|
```scheme
|
||||||
(: "foo.o" '("foo.c")
|
(: "foo.o" '("foo.c")
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(format #f "cc ~A -c foo.c" some-flags))
|
(format #f "cc ~A -c foo.c" some-flags))
|
||||||
|
```
|
||||||
|
|
||||||
Recipe using recipe helper procedures, which create a string to
|
Recipe using recipe helper procedures, which create a string to
|
||||||
be evaluated by the system
|
be evaluated by the system
|
||||||
|
|
||||||
|
```scheme
|
||||||
(: "foo.c" '("foo.c")
|
(: "foo.c" '("foo.c")
|
||||||
(~ ($ CC) ($ CFLAGS) "-c" $<))
|
(~ ($ CC) ($ CFLAGS) "-c" $<))
|
||||||
|
```
|
||||||
|
|
||||||
Recipe as a boolean to indicate pass or failure without doing any
|
Recipe as a boolean to indicate pass or failure without doing any
|
||||||
processing. For example, the rule below tells Potato Make that
|
processing. For example, the rule below tells Potato Make that
|
||||||
the file "foo.c" exists without actually testing for it.
|
the file "foo.c" exists without actually testing for it.
|
||||||
|
|
||||||
|
```scheme
|
||||||
(: "foo.c" '() #t)
|
(: "foo.c" '() #t)
|
||||||
|
```
|
||||||
|
|
||||||
If there is no recipe at all, it is shorthand for the recipe #t,
|
If there is no recipe at all, it is shorthand for the recipe #t,
|
||||||
indicating a recipe that always passes. This is used
|
indicating a recipe that always passes. This is used
|
||||||
in prerequisite-only target rules, such as below, which passes
|
in prerequisite-only target rules, such as below, which passes
|
||||||
so long as the prerequisites
|
so long as the prerequisites pass. These two rules are the same.
|
||||||
pass. These two rules are the same.
|
|
||||||
|
|
||||||
|
```scheme
|
||||||
(: "all" '("foo.exe"))
|
(: "all" '("foo.exe"))
|
||||||
(: "all" '("foo.exe") #t)
|
(: "all" '("foo.exe") #t)
|
||||||
|
```
|
||||||
|
|
||||||
Lastly, if the recipe is #f, this target will always fail.
|
Lastly, if the recipe is #f, this target will always fail.
|
||||||
|
|
||||||
|
```scheme
|
||||||
(: "fail" '() #f)
|
(: "fail" '() #f)
|
||||||
|
```
|
||||||
|
|
||||||
The *suffix rule* is a generic rule to convert one source file to a
|
The *suffix rule* is a generic rule to convert one source file to a
|
||||||
target file, based on the filename extensions.
|
target file, based on the filename extensions.
|
||||||
|
|
||||||
|
```scheme
|
||||||
(-> ".c" ".o"
|
(-> ".c" ".o"
|
||||||
(~ ($ CC) ($ CFLAGS) "-c" $< "-o" $@))
|
(~ ($ CC) ($ CFLAGS) "-c" $< "-o" $@))
|
||||||
|
```
|
||||||
|
|
||||||
## Recipe Helpers
|
## Recipe Helpers
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user