fix: manual latex build with proper build dir

This commit is contained in:
relikd
2023-03-03 23:13:05 +01:00
parent 938b5bdc13
commit 2911bfe705
2 changed files with 17 additions and 5 deletions

View File

@@ -1,6 +1,10 @@
PROJDIR := src PROJDIR := src
LEKTOR := lektor --project $(PROJDIR) LEKTOR := lektor --project $(PROJDIR)
BUILD_DIR := $$($(LEKTOR) project-info --output-path) BUILD_DIR := $$($(LEKTOR) project-info --output-path)
RESOLVED_BUILD_DIR := $$( \
if [ $$(readlink 'src/content/recipes') == "../../data/distribution/" ]; \
then echo "$(PWD)/bin"; \
else echo "$(BUILD_DIR)"; fi)
.PHONY: help .PHONY: help
help: help:
@@ -73,8 +77,10 @@ deploy:
# technically this isnt needed anymore but it simplyfies latex development # technically this isnt needed anymore but it simplyfies latex development
.PHONY: pdf .PHONY: pdf
pdf: pdf:
@echo
@echo 'Generating PDF from tex source ...'
@SECONDS=0; \ @SECONDS=0; \
"$(PROJDIR)/_tex-to-pdf/build_manually.sh" \ "$(PROJDIR)/_tex-to-pdf/build_manually.sh" "$(RESOLVED_BUILD_DIR)" \
&& echo "done. finished after $${SECONDS}s." && echo "done. finished after $${SECONDS}s."
# Helper methods on all recipes # Helper methods on all recipes

View File

@@ -1,15 +1,21 @@
#!/bin/sh #!/bin/sh
BUILD_DIR=$1
if [ $# != 1 ] || [ ! -d "$BUILD_DIR" ]; then
echo "Usage: ${0##*/} path/to/build-dir/"
exit 1
fi
cd "${0%/*}" || exit 1 cd "${0%/*}" || exit 1
rm -rf out rm -rf out
mkdir -p out mkdir -p out
build_dir=$(lektor project-info --output-path) echo "\\\\def\\\\buildDir{$BUILD_DIR}" > out/builddir.tex
echo "\\\\def\\\\buildDir{$build_dir}" > out/builddir.tex
find "$build_dir" -name "*.tex" | while read -r x; do find "$BUILD_DIR" -name "*.tex" | while read -r x; do
bname=$(basename "${x%.tex}") # remove extension and parent dir bname=$(basename "${x%.tex}") # remove extension and parent dir
shortname=${x#"$build_dir"} shortname=${x#"$BUILD_DIR"}
for i in 1 2; do for i in 1 2; do
echo lualatex "$shortname [$i/2]" echo lualatex "$shortname [$i/2]"
lualatex --halt-on-error --output-directory out "$x" > /dev/null || exit 13 lualatex --halt-on-error --output-directory out "$x" > /dev/null || exit 13