logo

blog

My website can't be that messy, right? git clone https://hacktivis.me/git/blog.git
commit: c31091253ce216b00f1e3b679fd589da035b261a
parent a63012ad5f278842886552c5882eac8602059010
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Wed,  8 Mar 2023 23:17:50 +0100

Replace Makefile with ninja-based buildsystem

Bit more verbose due to it being generation-focused but much better at supporting build dependencies.

Diffstat:

DMakefile33---------------------------------
Abuild.ninja30++++++++++++++++++++++++++++++
Aconfig.ninja8++++++++
Aconfigure19+++++++++++++++++++
4 files changed, 57 insertions(+), 33 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,33 +0,0 @@ -TEMPLATES_EN = templates/head.xml templates/en/nav.xsl templates/en/footer.shtml - -.PHONY: all -all: bookmarks.html notes/index.xhtml linux-audio-output images/avatar.png images/avatar_HD.png articles/2022\ Summary.html - -bookmarks.html: bookmarks.xbel bookmarks.xsl $(TEMPLATES_EN) - xsltproc --nonet bookmarks.xsl bookmarks.xbel | xmllint --xinclude --encode utf-8 --nofixup-base-uris --nsclean - | sed '1d' >|$@ - -articles/2022\ Summary.html: articles/2022\ Summary.xml entry.xsl $(TEMPLATES_EN) - xsltproc --nonet --param feedURL "'https://hacktivis.me/feed.atom'" entry.xsl articles/2022\ Summary.xml | xmllint --xinclude --encode utf-8 --nofixup-base-uris --nsclean - | sed '1d' >|"$@" - -.PHONY: linux-audio-output -linux-audio-output: images/linux-audio-output.png images/linux-audio-output.svg images/linux-audio-output-current.png images/linux-audio-output-current.svg - -images/linux-audio-output.png: images/linux-audio-output.dot - dot -Tpng $< >|$@ - -images/linux-audio-output.svg: images/linux-audio-output.dot - dot -Tsvg $< >|$@ - -images/linux-audio-output-current.dot: images/linux-audio-output.dot images/linux-audio-output-obsolete.txt - grep -v -f images/linux-audio-output-obsolete.txt $< > $@ - sed -i 's;Linux Audio Output APIs[^"]*;Linux Audio Output APIs (current-only);' $@ - -images/linux-audio-output-current.png: images/linux-audio-output-current.dot - dot -Tpng $< >|$@ - -images/linux-audio-output-current.svg: images/linux-audio-output-current.dot - dot -Tsvg $< >|$@ - -.PHONY: notes/index.xhtml -notes/index.xhtml: notes_index.pm - ./notes_index.pm >|$@ diff --git a/build.ninja b/build.ninja @@ -0,0 +1,30 @@ +# Written by hand + +rule xslt + command = xsltproc --nonet $in | xmllint --xinclude --encode utf-8 --nofixup-base-uris --nsclean - | sed '1d' >|$out + +rule article + command = xsltproc --nonet --param feedURL "'https://hacktivis.me/feed.atom'" $in | xmllint --xinclude --encode utf-8 --nofixup-base-uris --nsclean - | sed '1d' >|$out + +rule notes_index + command = ./notes_index.pm >|$out +build notes/index.xhtml: notes_index ./notes | ./notes_index.pm + +rule dot + command = dot -T$format -o$out $in + +build images/linux-audio-output.png: dot images/linux-audio-output.dot + format = png +build images/linux-audio-output.svg: dot images/linux-audio-output.dot + format = svg + +rule filter_dot + command = grep -v -f $in | sed 's;Linux Audio Output APIs[^"]*;Linux Audio Output APIs (current-only);' >|$out + +build images/linux-audio-output-current.dot: filter_dot images/linux-audio-output-obsolete.txt images/linux-audio-output.dot +build images/linux-audio-output-current.png: dot images/linux-audio-output-current.dot + format = png +build images/linux-audio-output-current.svg: dot images/linux-audio-output-current.dot + format = svg + +include config.ninja diff --git a/config.ninja b/config.ninja @@ -0,0 +1,8 @@ +# Generated by: ./configure +rule gen_config + command = ./configure "" + generator = 1 + +build config.ninja: gen_config configure | ./articles +build bookmarks.html: xslt bookmarks.xsl bookmarks.xbel | ./templates/head.xml ./templates/en/nav.xsl ./templates/en/footer.shtml +build articles/2022$ Summary.html: article entry.xsl articles/2022$ Summary.xml | ./templates/head.xml ./templates/en/nav.xsl ./templates/en/footer.shtml diff --git a/configure b/configure @@ -0,0 +1,19 @@ +#!/bin/sh +templates_en="./templates/head.xml ./templates/en/nav.xsl ./templates/en/footer.shtml" + +cat >|config.ninja <<-EOF +# Generated by: $0 $@ +rule gen_config + command = $0 "$@" + generator = 1 + +build config.ninja: gen_config configure | ./articles +build bookmarks.html: xslt bookmarks.xsl bookmarks.xbel | ${templates_en} +EOF + +for i in articles/*.xml +do + i="${i//$/\$\$}" # '$' → '$$' + i="${i// /$ }" # ' ' → '$ ' + echo "build ${i//.xml/.html}: article entry.xsl ${i} | ${templates_en}" +done >>config.ninja