#!/bin/bash # Incremental build script. # Main inputs are from the *.cue and *.yaml files in the top-level directory # Assets are taken from raw/ tex/ mako/ etc and put into the output/ directory # The output/ directory is populated with a ninja build script to do the # actual build, along with source files that are updated for a build. # Thus to build a full output in dir you would run: build.sh dir/ && cd dir/ && ninja build # Once built once, a simple `ninja` in the output directory should suffice # echo "new" | update file # updates file with new content only if the content differs update() { fname="$1" data="$(cat)" new="$(echo "$data" | sha256sum | cut -d " " -f 1)" old="$(sha256sum "$fname" | cut -d " " -f 1)" if [ "$new" != "$old" ]; then echo "Updating $fname" echo "$data" > "$fname" fi } outdir="${1:-output}/" mkdir -p "$outdir" json="$(cue export *.cue *.yaml)" { echo "# Generated by build.sh on $(date)" echo "include ../rules.ninja" EOF } | update "$outdir/build.ninja" # TODO: get json via `cue export *.cue *.yaml`