bake - a make-like utility

by Christian Kjær Larsen on June 27, 2017

For the course Programming Language Design I implemented a simple make-like domain specific language.

Introducing bake

You can define constants to be used later. All definitions are written using an arrow (<-)

@cc <- gcc
@cflags <- -std=c99 -pedantic -Wall -O2

You can define rules to be used when you have repeating patterns in your scripts

@compileLib(in, out)
  @cc -c -o @out @in @cflags

bake is indentation sensitive just like Python or Haskell. Finally you can define build rules for particular files

libs: math.o list.o <- math.c list.c
  @compileLib(math.c, math.o)
  @compileLib(list.c, list.o)
  zip @input

@input is bound to the input files and @output is bound to the output files. To reduce repetition there is also the fish operator (<-<). This repeats the rule for every file in the argument list. The previous rule can then be written as

libs: math.o list.o <-< math.c list.c
  @compileLib(@input, @output)

bake does automatic dependency resolution and makes sure that all necessary files are present before executing any commands.


bake is implemented in Haskell using megaparsec and the very nice graph library by King and Launchbury.

It uses simple graph algorithms to do dependency resolution and execute the rules in the correct order.