Prerequisites for building:
both do the same, the source should always embed a self-bootstrapping copy of mek (it's tiny), and the only external dependency is third-party components that are automatically downloaded.
$(mek daemon) ls editor some-file
mek build toto # builds toto or toto.err in case of an error, then builds everything else
# Cached errors are displayed early, but the build is retried in case it was a cosmic ray.
mek clean # only necessary if a hardware or system failure (e.g. out of memory) made a build appear as SUCCESSFUL when it was not
# (e.g. a poorly-written test that expected an error, caught an OOM but the real execution would not have produced an error)
mek watch # rebuilds everything incrementally as soon as sources are modified (threads 1 and 3 or 2 and 3, see below).
mek daemon # same but with '&' after initialization
mek watch toto # rebuilds toto incrementally as soon as one of its transitive dependencies is modified
ls # show progress next to (future) targets and a symlink to the backup of their source
ls _build.err # stderr of the last build (if non-empty)
ls _build/err # stderr of the last build
ls _build/source/ # source of the last build
ls _build/good.source/ # source of the last successful build
ls _build/err.source/ # source of the last failed build
ls toto.err # stderr when building toto (if non-empty)
ls toto.source # source of the last build of toto
ls toto.good.source # source of the last successful build of toto
ls toto.err.source # source of the last failed build of toto
ls toto.log # log of all the builds of toto
mek source # dumps the source of the last build
mek source --good # dumps the source of the last successful build
mek source --err # dumps the source of the last failed build
mek source toto # dumps the source of the last successful build of toto
mek source toto.err # dumps the source of the last failed build of toto
mek log # log of all the builds (from these we can get the source and the built output)
eval $(mek) # builds and adds the output bin directory to $PATH etc.
eval "$(mek)" # same
$(mek) # same
. mekfile.sh # same
mek; copy-paste output # same
$(mek daemon) # same but detaches right away and builds incrementally in the background
eval $(mek build toto) # adds an output bin directory containing only toto (can be a collection of outputs) to $PATH etc.
mek shell toto # subshell in the directory and with the env of the recipe that builds toto
mek shell toto.err # same as above
eval $(mek shell toto) # cd to build directory for toto and add to $PATH etc.
mek archive toto # toto.run now contains the source of toto and of all its dependencies
mek archive --downloaded # downloaded.run now contains the source of all network dependencies
$ $(mek daemon) $ ls (toto 60%) toto.source toto.c toto.h $ ls toto toto.source toto.c toto.h $ echo "bad stuff" >> toto.h $ ls toto (34%) toto.c toto.h $ ls toto toto.source toto.err toto.err.source toto.c toto.h $ meld toto.source/ toto.err.source/ $ echo "fix bug" >> toto.h $ ls toto toto.source toto.c toto.h
mekfiletoto: toto.h # automatic dependency on the gcc executable and on toto.c # "," is the unquote from scheme, it escapes from the implicitly-quoted shell command. # TODO: Maybe gcc (a variable pointing to a third-party tool) should be distinguished from toto.c (a local file) > ,gcc ,toto.c -o ,output
while sleep 1; do date > somesource; done which produces an infinite stream of changes, and one of the versions causes the compiler to deadlock / go in an infinite loop, mek will still eventually produce an infinite stream of output binaries, where the latest produced binary is not based on a "very old" change (i.e. it is not a queue of jobs that grows indefinitely). It tries to build the latest changes, but it is resistant to the compiler hanging forever on some inputs, and it is resistant to a rapid stream of changes that could cause a naive algorithm to always restart without ever finishing any build.