1
1
mirror of https://github.com/wader/fq.git synced 2024-11-05 02:34:02 +03:00

make: Move doc generate to helper script

This commit is contained in:
Mattias Wadman 2021-09-18 18:24:12 +02:00
parent e4e269b162
commit 75b59dbeff
2 changed files with 16 additions and 12 deletions

View File

@ -35,18 +35,7 @@ testcli:
.PHONY: doc
doc: doc/file.mp3 doc/file.mp4
$(eval REPODIR=$(shell pwd))
$(eval TEMPDIR=$(shell mktemp -d))
@cp -a doc/* "${TEMPDIR}"
@go build -o "${TEMPDIR}/fq" main.go
@for f in *.md doc/*.md ; do \
cd "${TEMPDIR}" ; \
echo $$f ; \
mkdir -p $$(dirname "${TEMPDIR}/$$f") ; \
cat "${REPODIR}/$$f" | PATH="${TEMPDIR}:${PATH}" go run "${REPODIR}/doc/mdsh.go" > "${TEMPDIR}/$$f" ; \
mv "${TEMPDIR}/$$f" "${REPODIR}/$$f" ; \
done
@rm -rf "${TEMPDIR}"
@doc/mdsh.sh *.md doc/*.md
doc/file.mp3: Makefile
ffmpeg -y -f lavfi -i sine -f lavfi -i testsrc -map 0:0 -map 1:0 -t 20ms "$@"

15
doc/mdsh.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/sh
set -eu
REPODIR=$(pwd)
TEMPDIR=$(mktemp -d)
cp -a doc/* "${TEMPDIR}"
go build -o "${TEMPDIR}/fq" main.go
for f in "$@"; do
cd "${TEMPDIR}"
echo "Generate $f"
mkdir -p "$(dirname "${TEMPDIR}/$f")"
PATH="${TEMPDIR}:${PATH}" go run "${REPODIR}/doc/mdsh.go" >"${TEMPDIR}/$f" <"${REPODIR}/$f"
mv "${TEMPDIR}/$f" "${REPODIR}/$f"
done
rm -rf "${TEMPDIR}"