#!/bin/bash

in=__default__.yaml
out=layouts.c

echo "making default layout..."

function build {
	echo "" > $out
	echo "// This file is generated from __default__.yaml" >> $out
	echo "" >> $out
	echo -en "const char* default_layout = \"" >> $out
	cpp -P $in | sed -e "s/$/\\\n\\\/" | sed -e "s/\"/\\\\\"/g" >> $out
	echo "\";" >> $out
}

if [[ -s $out ]]; then
	#output file already exists, check age
	if [[ ! $in -nt $out ]] && [[ ! make_layouts -nt $out ]]; then
		exit
	fi
fi

build

