# Takes iditacards output json and produces the dynamic ninja build def expandout: to_entries[] | .value + { name: .key }; def everything: ( (.assets | map_values(. + { pseudo: false })), (.pseudoassets | map_values(. + { pseudo: true })) ) | expandout; def cuesources: $ARGS.positional | join(" "); "# Generated from configure.jq, do not edit this file!", "", "root = .", "", "rule configure", " description = recreate build.ninja using configure.jq via configure.sh", " command = bash configure.sh > build.ninja", " generator = 1", " restat = 1", "", "build build.ninja: configure | configure.jq configure.sh \(cuesources)", "include rules.ninja", "", "build output/everything.json: cuegen \(cuesources)", " filter = .", "", ( everything | ( select(.kind == "template") | .w = (.size | split("x")[0]) | .h = (.size | split("x")[1]) | .rawsuffix = (if .print then "raw." else "" end) | "build output/.\(.name).json.stamp | output/\(.name).json: extract output/everything.json", " filter = --arg asset '\(.name)' '.assets[$$asset].data'", " target = output/\(.name).json", "build output/\(.name).tex: template2tex output/\(.name).json | templates/\(.template)", " template = templates/\(.template)", "build output/\(.name).pdf: tex2pdf output/\(.name).tex || output/.\(.name).pdf.dd", " dyndep = output/.\(.name).pdf.dd", "build output/.\(.name).pdf.dd: scantex output/\(.name).tex", " target = output/\(.name).pdf", "build output/\(.name).\(.rawsuffix)png: pdf2png output/\(.name).pdf", " w = \(.w)", " h = \(.h)", (select(.print) | "build output/\(.name).png: convert output/\(.name).raw.png"), (select(.print) | " args = \(.print)") ),( select(.kind == "image") | .rawsuffix = (if .print then "raw." else "" end) | "build output/\(.name).\(.rawsuffix)png: copy \(.source)", (select(.print) | "build output/\(.name).png: convert output/\(.name).raw.png"), (select(.print) | " args = \(.print)") ),( select(.kind == "tex") | .w = (.size | split("x")[0]) | .h = (.size | split("x")[1]) | .rawsuffix = (if .print then "raw." else "" end) | "build output/\(.name).pdf: tex2pdf \(.source) || output/.\(.name).pdf.dd", " dyndep = output/.\(.name).pdf.dd", "build output/.\(.name).pdf.dd: scantex \(.source)", " target = output/\(.name).pdf", "build output/\(.name).\(.rawsuffix)png: pdf2png output/\(.name).pdf", " w = \(.w)", " h = \(.h)", (select(.print) | "build output/\(.name).png: convert output/\(.name).raw.png"), (select(.print) | " args = \(.print)") ),( select(.kind == "texdoc") | "build output/\(.name).pdf: tex2pdf2x \(.source) || output/.\(.name).pdf.dd", " dyndep = output/.\(.name).pdf.dd", "build output/.\(.name).pdf.dd: scantex \(.source)", " target = output/\(.name).pdf" ),( select(.kind == "cat") | .ins = (.contents | map("output/\(.).pdf") | join(" ")) | "build output/\(.name).pdf: pdfunite \(.ins)" ) )