-TACTIC PROBLEM:
+PREDICATE PROBLEM:
-Only one tactic for solving dependencies.
+Only one predicate for solving dependencies.
"If the target file doesn't exist, or if it's older than
one of the dependencies, then run this recipe."
If you think for a little while you'll see that other
-tactics are possible:
+predicates are possible:
eg: URL, newer than any file (not all files),
Koji build, comparing checksums, test with skip
-Tactics are special rules that we can use to change how we
+Predicates are special rules that we can use to change how we
determine if a goal needs to be rebuilt. When you see a
-filename string, there's an implicit tactic called *file, so
+filename string, there's an implicit predicate called is-file, so
these are equivalent, because when goals sees a bare string
-but it wants a tactic it implicitly uses *file.
+but it wants a predicate it implicitly uses is-file.
"target" : "foo.o", "bar.o" { ... }
- *file("target") : *file("foo.o"), *file("bar.o") { ... }
+ is-file("target") : is-file("foo.o"), is-file("bar.o") { ... }
-Apart from *file being the default tactic, it's not built
-into goals. In fact *file is defined in the goals standard
+Apart from is-file being the default predicate, it's not built
+into goals. In fact is-file is defined in the goals standard
library. The special @{...} code section means the code
doesn't print verbosely when its running. And "exit 99"
-is used by the tactic to indicate that the target needs
+is used by the predicate to indicate that the target needs
to be rebuilt, but other than that it's all written in
ordinary shell script:
- tactic *file (filename) = @{
+ predicate is-file (filename) = @{
test -f %filename || exit 99
for f in %<; do
test %filename -ot "$f" && exit 99 ||:
-And you can of course write other tactics in shell script.
-Here's a tactic for running test suites. This tactic lets
+And you can of course write other predicates in shell script.
+Here's a predicate for running test suites. This predicate lets
you skip a test by setting an environment variable.
- tactic *test (script) = @{
+ predicate is-test (script) = @{
# Check if SKIP variable is set.
skip_var=$(
echo -n SKIP_%script |
if test %goals_final_check; then exit 0; else exit 99; fi
}
-You can use the tactic like this. There's quite a lot to unpack
+You can use the predicate like this. There's quite a lot to unpack
in this example, but I'll just say that the wildcard function
expands to a list of files, and the wrap function changes them
-from a list of strings into a list of *test tactics.
+from a list of strings into a list of is-test predicates.
- let tests = wrap ("*test", wildcard ("test-*.sh"))
+ let tests = wrap ("is-test", wildcard ("test-*.sh"))
goal check () = : tests
- goal run (script) = *test(script) : { ./%script }
+ goal run (script) = is-test(script) : { ./%script }
-Another tactic we use is called *koji-built, which I
+Another predicate we use is called is-koji-built, which I
use for mass rebuilding Fedora packages in dependency order.
-I won't go into the full definition of *koji-built since
+I won't go into the full definition of is-koji-built since
interfacing with Koji is quite complicated, but you can
write a mass rebuild tool in goals fairly easily:
goal link = "program" : "foo.o" { %CC %CFLAGS %< -o %@ }
- - Tactics are constructors
+ - Predicates are constructors
- Targets are patterns
- *file ("%name.o") : ... match name with
+ is-file ("%name.o") : ... match name with
| File (name + ".o") -> compile name
| ...
----
to do:
- - Explain tactics better, Kashyap found it confusing.
-
- - Should "tactic" be "predicate"?
- Tactics might use βis-β instead of β*β, eg. is-file, is-koji-built
+ - Explain predicates better, Kashyap found it confusing.
- Cover some of the other tools that are better makes.
(Note I'm not covering all DAG solvers like Ninja unless they
bring something new to the table)
- * Plan 9 mk - has alternate build tactics
+ * Plan 9 mk - has alternate build predicates
* https://github.com/casey/just - has functions and multi-parameter rules