replace waf with make

This commit is contained in:
Sebastian Hugentobler 2017-11-08 11:07:22 +01:00
parent 6eeb3e8b3c
commit cc46c8779f
No known key found for this signature in database
GPG Key ID: 7BBE74D3F626FC0F
29 changed files with 1100 additions and 427 deletions

8
.gitignore vendored
View File

@ -2,9 +2,7 @@
.DS_Store .DS_Store
*.swp *.swp
*.lock* *.lock*
*.waf* .vscode
out tmp
pdf
midi
music
build build
src/tmp_ly

89
Makefile Normal file
View File

@ -0,0 +1,89 @@
WORKING_DIR:=$(shell pwd)
BOOKNAME=kommersbuch
SRC_DIR=src
BUILD_DIR=build
TMP_DIR=tmp
SONG_DIR=${SRC_DIR}/songs
BUILD_BOOK_DIR=${BUILD_DIR}/books
TMP_BOOK_DIR=${TMP_DIR}/books
BUILD_SONG_DIR=${BUILD_DIR}/songs
TMP_SONG_DIR=${TMP_DIR}/songs
BUILD_MIDI_DIR=${BUILD_DIR}/midi
TMP_MIDI_DIR=${TMP_DIR}/midi
BUILD_OPUS_DIR=${BUILD_DIR}/opus
LY_FILES=$(wildcard ${SONG_DIR}/*.ly)
LY_PDFS=$(patsubst %.ly,${BUILD_SONG_DIR}/%.pdf,$(notdir ${LY_FILES}))
LY_TMP_PDFS=$(patsubst %.ly,${TMP_SONG_DIR}/%.pdf,$(notdir ${LY_FILES}))
LY_MIDIS=$(patsubst %.ly,${BUILD_MIDI_DIR}/%.midi,$(notdir ${LY_FILES}))
LY_TMP_MIDIS=$(patsubst %.ly,${TMP_MIDI_DIR}/%.midi,$(notdir ${LY_FILES}))
LY_OPUS=$(patsubst %.ly,${BUILD_OPUS_DIR}/%.opus,$(notdir ${LY_FILES}))
.PHONY: book songs midi opus clean directories all
.DEFAULT_GOAL := all
directories: ${BUILD_DIR} ${BUILD_BOOK_DIR} ${TMP_BOOK_DIR} ${BUILD_SONG_DIR} ${BUILD_MIDI_DIR} ${TMP_DIR} ${TMP_SONG_DIR} ${TMP_MIDI_DIR} ${BUILD_OPUS_DIR}
${BUILD_DIR}:
mkdir -p ${BUILD_DIR}
${BUILD_BOOK_DIR}:
mkdir -p ${BUILD_BOOK_DIR}
${BUILD_SONG_DIR}:
mkdir -p ${BUILD_SONG_DIR}
${BUILD_MIDI_DIR}:
mkdir -p ${BUILD_MIDI_DIR}
${TMP_DIR}:
mkdir -p ${TMP_DIR}
${TMP_BOOK_DIR}:
mkdir -p ${TMP_BOOK_DIR}
${TMP_SONG_DIR}:
mkdir -p ${TMP_SONG_DIR}
${TMP_MIDI_DIR}:
mkdir -p ${TMP_MIDI_DIR}
${BUILD_OPUS_DIR}:
mkdir -p ${BUILD_OPUS_DIR}
${TMP_SONG_DIR}/%.pdf: ${SONG_DIR}/%.ly ${SONG_DIR}/%.tex
cd ${SRC_DIR} && lualatex --jobname='$(notdir $(basename $@))' --output-directory=${WORKING_DIR}/${TMP_SONG_DIR} --shell-escape ${WORKING_DIR}/${SRC_DIR}/song.tex ${WORKING_DIR}/${SONG_DIR}/$(notdir $(basename $@)).ly ${WORKING_DIR}/${SONG_DIR}/$(notdir $(basename $@)).tex
${BUILD_MIDI_DIR}/%.midi: ${TMP_MIDI_DIR}/%-1.midi
cp $< $@
${TMP_MIDI_DIR}/%-1.midi: ${SONG_DIR}/%.ly
lilypond --output=${TMP_MIDI_DIR} $<
${BUILD_OPUS_DIR}/%.opus: ${BUILD_MIDI_DIR}/%.midi
timidity $< -Ow -o - | opusenc - $@
${TMP_BOOK_DIR}/%.pdf: ${SRC_DIR}/%.tex ${SRC_DIR}/images/title.png
latexmk -cd -lualatex -e '$$lualatex=q/lualatex %O -shell-escape %S/' -output-directory=${WORKING_DIR}/${TMP_BOOK_DIR} $<
#short edge binding
${TMP_BOOK_DIR}/%-octavo.pdf: ${TMP_BOOK_DIR}/%.pdf
cd ${TMP_BOOK_DIR} && \
../../bin/makebook -v -t octavo -i $(notdir $<) -o $(notdir $@)
${TMP_BOOK_DIR}/%-folio.pdf: ${TMP_BOOK_DIR}/%.pdf
cd ${TMP_BOOK_DIR} && \
../../bin/makebook -v -t folio -i $(notdir $<) -o $(notdir $@)
${BUILD_DIR}/%.pdf: ${TMP_DIR}/%.pdf
cp $< $@
book: directories ${BUILD_BOOK_DIR}/${BOOKNAME}.pdf ${BUILD_BOOK_DIR}/${BOOKNAME}-folio.pdf ${BUILD_BOOK_DIR}/${BOOKNAME}-octavo.pdf
songs: directories ${LY_PDFS}
midi: directories ${LY_MIDIS}
opus: directories ${LY_OPUS}
all: book songs midi opus
clean:
rm -rf ${BUILD_DIR}
rm -rf ${TMP_DIR}

632
bin/makebook Executable file
View File

@ -0,0 +1,632 @@
#!/bin/sh
# +AMDG This document was begun just before Christmas,
# 2010, and it is humbly dedicated to St. Wulfric, patron of
# bookbinders, and to the Immaculate Heart of Mary for their
# prayers, and to the Sacred Heart of Jesus for His mercy.
#
#**********************************************************#
# makebook #
# written by Donald P. Goodman III #
# Copyright (C) 2011 #
# #
# Impose pdf pages for binding #
#**********************************************************#
#
# This program is free software: you can redistribute it
# and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more
# details.
#
# For a full copy of the GNU General Public License, see
# <http://www.gnu.org/licenses/>.
#
#**********************************************************#
# begin the code #
#**********************************************************#
umask 033
# define our revision number variable for rcs
REVISION="2.0"
# define error codes
E_WRONG_ARGS=64 # too many or few args
E_BAD_SIG_TYPE=65 # invalid type of signature
E_BAD_UNIT=66 # unrecognized dimension unit used
E_BAD_FILENAME=67 # filename contains insecure chars,
# or doesn't exist
E_BAD_OPT=68 # bad command-line flag requested
E_NO_PROG=69 # missing a required program
# define usage variables
VERBOSE=0 # 0 if not verbose, 1 if -v
SIG_TYPE="folio" # type of section desired
PAGES_PER_SIG=4 # number of pages per signature
SECT_TYPE=1 # number of signatures per section
NUP="2x1" # default format of signatures
FRONT_FAVOR=0 # favor front for blanks; off by default
# define various variables to be zero by default
TGT_PAGE_WIDTH=0
TGT_PAGE_HEIGHT=0
HORIZ_DELTA=0
VERT_DELTA=0
HORIZ_OFFSET=0
VERT_OFFSET=0
SCALE=1
# make sure user has the right programs installed, and die
# horribly if not
command -v od >/dev/null 2>&1 ||
{ echo >&2 "makebook: error: requires od, but it's not installed";
exit $E_NO_PROG;
}
command -v pdflatex >/dev/null 2>&1 ||
{ echo >&2 "makebook: error: requires pdflatex, but it's not installed";
exit $E_NO_PROG;
}
command -v pdfinfo >/dev/null 2>&1 ||
{ echo >&2 "makebook: error: requires pdfinfo, but it's not installed";
exit $E_NO_PROG;
}
command -v pdftk >/dev/null 2>&1 ||
{ echo >&2 "makebook: error: requires pdftk, but it's not installed";
exit $E_NO_PROG;
}
# print the version information and exit successfully
versionfunc ()
{
echo "makebook v${REVISION}. Copyright (C) 2011, Donald P."
echo "Goodman III."
echo "This program comes with ABSOLUTELY NO WARRANTY."
echo "This is free software, and you are welcome to "
echo "redistribute it under certain conditions; see "
echo "the GNU GPL v3 for details."
exit 0
}
# print the online help and exit successfully
helpfunc ()
{
cat <<End-of-help
makebook v${REVISION}. Copyright (C) 2011, Donald P. Goodman III.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to
redistribute it under certain conditions; see
the GNU GPL v3 for details.
-V: Prints license and version information, then exits
successfully.
-h: Prints this help information, then exist successfully.
-v: Verbose output
-f: Favor front, rather than back, for blanks.
-t: Signature type
-n: Number of signatures per section.
-H: Height of the target page.
-w: Width of the target page.
-d: Horizontal delta.
-D: Vertical delta.
-m: Horizontal offset.
-M: Vertical offset.
-s: Scaling of source pages to target page.
-i: Input file.
-o: Output file.
Please see the man page for complete documentation.
End-of-help
exit 0;
}
# define a for dealing with units; convert to bp ()
unitarg ()
{
if [ ! `echo "$1" | grep '^[\+\|-]*[0-9\.][0-9\.]*\(in\|cm\|pt\|bp\|pc\|$\)'` ]
then
echo "ERROR: dimension \"$1\" not valid." >&2
exit $E_BAD_UNIT
fi
if [ `expr match "$1" '.*\(in\)'` ]
then
OPTARG=`echo "scale=0; ${1%in} * 72" | bc`
OPTARG=${OPTARG%.*}
elif [ `expr match "$1" '.*\(cm\)'` ]
then
OPTARG=`echo "scale=0; ${1%cm} * 28.3464567" | bc`
OPTARG=${OPTARG%.*}
elif [ `expr match "$1" '.*\(pt\)'` ]
then
OPTARG=`echo "scale=0; ${1%pt} / 1.00375" | bc`
OPTARG=${OPTARG%.*}
elif [ `expr match "$1" '.*\(pc\)'` ]
then
OPTARG=`echo "scale=0; (${1%pc} / 1.00375) * 12" | bc`
OPTARG=${OPTARG%.*}
elif [ `expr match "$1" '.*\(bp\)'` ]
then
OPTARG=${1%bp}
else
OPTARG=${1%.*}
fi
}
# define a for dealing with section types; convert ()
# to words; e.g., "4to" to "quarto"
typearg ()
{
if [ "$1" = "4to" ] || [ "$1" = "quarto" ]
then
PAGES_PER_SIG=8
NUP="2x2"
OPTARG="quarto"
elif [ "$1" = "2o" ] || [ "$1" = "folio" ]
then
PAGES_PER_SIG=4
NUP="2x1"
OPTARG="folio"
elif [ "$1" = "8vo" ] || [ "$1" = "octavo" ]
then
PAGES_PER_SIG=16
NUP="4x2"
OPTARG="octavo"
elif [ "$1" = "6to" ] || [ "$1" = "sexto" ]
then
PAGES_PER_SIG=12
NUP="2x3"
OPTARG="sexto"
elif [ "$1" = "12mo" ] || [ "$1" = "duodecimo" ]
then
PAGES_PER_SIG=24
NUP="4x3"
OPTARG="duodecimo"
else
echo "ERROR: signature type \"$1\" not recognized." >&2
exit $E_BAD_SIG_TYPE
fi
}
# clean up filename argument
filefunc ()
{
err_message="ERROR: bad characters in file name."
if [ `echo "$1" | grep '\?'` ]
then
echo "$err_message" >&2
exit $E_BAD_FILENAME
elif [ `echo "$1" | grep '\*'` ]
then
echo "$err_message" >&2
exit $E_BAD_FILENAME
elif [ `echo "$1" | grep '"'` ]
then
echo "$err_message" >&2
exit $E_BAD_FILENAME
elif [ `echo "$1" | grep ';'` ]
then
echo "$err_message" >&2
exit $E_BAD_FILENAME
elif [ `echo "$1" | grep '[\\]'` ]
then
echo "$err_message" >&2
exit $E_BAD_FILENAME
elif [ `echo "$1" | grep ' '` ]
then
echo "$err_message" >&2
exit $E_BAD_FILENAME
fi
OPTARG=`basename $1`
}
# now identify and parse the options
while getopts "Vhvfn:t:H:w:d:D:m:M:s:i:o:" Option
do
case $Option in
V ) versionfunc;;
h ) helpfunc;;
v ) VERBOSE=1;;
f ) FRONT_FAVOR=1;;
n ) SECT_TYPE=$OPTARG;;
t ) typearg "$OPTARG"; SIG_TYPE=$OPTARG;;
H ) unitarg "$OPTARG"; TGT_PAGE_HEIGHT=$OPTARG;;
w ) unitarg "$OPTARG"; TGT_PAGE_WIDTH=$OPTARG;;
d ) unitarg "$OPTARG"; HORIZ_DELTA=$OPTARG;;
D ) unitarg "$OPTARG"; VERT_DELTA=$OPTARG;;
m ) unitarg "$OPTARG"; HORIZ_OFFSET=$OPTARG;;
M ) unitarg "$OPTARG"; VERT_OFFSET=$OPTARG;;
s ) SCALE=$OPTARG;;
i ) filefunc "$OPTARG"; FILE_NAME=$OPTARG;;
o ) filefunc "$OPTARG"; OUTFILE_NAME=$OPTARG;;
* ) echo "ERROR: unknown flag \
\"$Option\"." >&2; exit $E_BAD_OPT;;
esac
done
# make random file name to use for input
NEW_FILE_NAME="tmp_`od -An -N4 -t uL /dev/urandom | tr -d '\ '`.pdf"
# if input file specified, use file; if not, read stdin
if [ "$FILE_NAME" ]
then
cp "$FILE_NAME" "$NEW_FILE_NAME"
else
FILE_NAME="book.pdf"
cat /dev/stdin > "$NEW_FILE_NAME"
fi
# declare holder variable for pdftk
tmp_name="tmp_`od -An -N4 -t uL /dev/urandom | tr -d '\ '`.pdf"
# if output file specified, use that; if not, name it; if
# "-", use stdout
[ "$OUTFILE_NAME" ] || OUTFILE_NAME="sigs_$FILE_NAME"
if [ "$OUTFILE_NAME" = "stdout" ]
then
VERBOSE=0
fi
# print our introduction message
if [ $VERBOSE -eq 1 ]
then
echo "makebook. Copyright (C) 2011, Donald P. Goodman III."
echo "This program comes with ABSOLUTELY NO WARRANTY."
echo "This is free software, and you are welcome to "
echo "redistribute it under certain conditions; see "
echo "the GNU GPL v3 for details."
echo "IMPOSING pdf pages onto \"$OUTFILE_NAME\"..."
fi
# get some information about our source document
NUM_PAGES=`pdfinfo "$NEW_FILE_NAME" | awk '/Pages:/ {print $2}'`;
SRC_PAGE_WIDTH=`pdfinfo "$NEW_FILE_NAME" | awk '/Page\ size:/ {print $3}'`;
SRC_PAGE_HEIGHT=`pdfinfo "$NEW_FILE_NAME" | awk '/Page\ size:/ {print $5}'`;
# find the number of pages we'll have per signature
PAGES_PER_SIG=$(($PAGES_PER_SIG * $SECT_TYPE))
# determine if extra pages will be necessary
NUM_BLANKS=`expr $NUM_PAGES % $PAGES_PER_SIG`
if [ $NUM_BLANKS -ne 0 ]
then
NUM_BLANKS=`expr $PAGES_PER_SIG - $NUM_BLANKS`
fi
tmp=`expr $NUM_PAGES + $NUM_BLANKS`
NUM_SIGS=`expr $tmp / $PAGES_PER_SIG`
# if extra pages are needed, generate blank page
if [ $NUM_BLANKS -gt 0 ] && [ ! -e "./blank.pdf" ]
then
echo "\documentclass{article}" > blank.tex
echo '\\thispagestyle{empty}' >> blank.tex
echo "\usepackage[paperwidth=${SRC_PAGE_WIDTH}bp,paperheight="${SRC_PAGE_HEIGHT}bp"]{geometry}" >> blank.tex
echo '\\begin{document}' >> blank.tex
echo "\quad \end{document}" >> blank.tex
if [ $VERBOSE -eq 1 ]
then
echo "CREATING blank page to fill sections...";
fi
pdflatex blank.tex > /dev/null 2&>1
rm blank.aux blank.log blank.tex
fi
# now insert blank pages as needed, preferring the back for
# odd numbers by default, front if stated
if [ $NUM_BLANKS -eq 1 ]
then
if [ $VERBOSE -eq 1 ]
then
echo "INSERTING one blank page..."
fi
if [ $FRONT_FAVOR -eq 0 ]
then
pdftk A="$NEW_FILE_NAME" B=blank.pdf cat A1-end \
B1 output "$tmp_name"
else
pdftk A="$NEW_FILE_NAME" B=blank.pdf cat B1 \
A1-end output "$tmp_name"
fi
mv "$tmp_name" "$NEW_FILE_NAME"
else
# tmp=`expr $NUM_BLANKS / 2`
# START_BLANKS=${tmp/.*}
START_BLANKS=`expr $NUM_BLANKS / 2`
END_BLANKS=`expr $NUM_BLANKS - $START_BLANKS`
if [ `expr $START_BLANKS % 2` -ne 0 ]; then : else
START_BLANKS=`expr $START_BLANKS - 1`
END_BLANKS=`expr $END_BLANKS + 1 `
fi
if [ $FRONT_FAVOR -eq 1 ]
then
tmp=$START_BLANKS
START_BLANKS=$END_BLANKS
END_BLANKS=$tmp
if [ `expr $START_BLANKS % 2` -ne 0 ]; then : else
START_BLANKS=`expr $START_BLANKS - 1`
END_BLANKS=`expr $END_BLANKS + 1 `
fi
fi
if [ $VERBOSE -eq 1 ]
then
echo "INSERTING $START_BLANKS blank pages at start..."
echo "INSERTING $END_BLANKS blank pages at end...";
fi
i=0
while [ $i -lt $START_BLANKS ]
do
pdftk A="$NEW_FILE_NAME" B=blank.pdf cat B1 A1-end output "$tmp_name"
mv "$tmp_name" "$NEW_FILE_NAME"
i=`expr $i + 1`
done
i=0
while [ $i -lt $END_BLANKS ]
do
pdftk A="$NEW_FILE_NAME" B=blank.pdf cat A1-end B1 output "$tmp_name"
mv "$tmp_name" "$NEW_FILE_NAME"
i=`expr $i + 1`
done
fi
# begin the imposing, announcing if appropriate
tmp=`expr $NUM_PAGES + $NUM_BLANKS`
if [ $VERBOSE -eq 1 ]
then
echo "IMPOSING $NUM_PAGES pages ($tmp with blanks) on
$(($NUM_SIGS * $SECT_TYPE)) signature(s) gathered in
sections of $SECT_TYPE signature(s) each...";
fi
# arrange the pages for impression on signatures
i=1
j=1
if [ $VERBOSE -eq 1 ]
then
echo "REARRANGING pages...";
fi
while [ $j -le $NUM_SIGS ]
do
if [ "$SIG_TYPE" = "quarto" ]
then
# determine size of target page
if [ $(echo "$TGT_PAGE_HEIGHT == 0" | bc) -eq 1 ]
then
TGT_PAGE_HEIGHT=$(echo "$SRC_PAGE_HEIGHT * 2" | bc)
fi
if [ $(echo "$TGT_PAGE_WIDTH == 0" | bc) -eq 1 ]
then
TGT_PAGE_WIDTH=$(echo "$SRC_PAGE_WIDTH * 2" | bc)
fi
# do the rearranging
k=$i; n=1; total=$(($SECT_TYPE * 8)); m=$total
while [ $n -le $SECT_TYPE ]
do
pdftk "$NEW_FILE_NAME" cat `expr $k + $m - 1` $k \
`expr $k + $m - 4`south `expr $k + 3`south \
`expr $k + 1` `expr $k + $m - 2` `expr $k + 2`south \
`expr $k + $m - 3`south output ${tmp_name%.pdf}_$n;
k=`expr $k + 4`; n=`expr $n + 1`; m=`expr $m - 8`
done
n=1
while [ `expr $n + 0` -le $SECT_TYPE ]
do
if [ ! -e "$tmp_name" ]
then
pdftk A=${tmp_name%.pdf}_$n cat A1-end \
output "$tmp_name"
else
pdftk A=$tmp_name B=${tmp_name%.pdf}_`expr $n` \
cat A1-end B1-end output ${tmp_name}_tmp
mv ${tmp_name}_tmp "$tmp_name"
fi
n=`expr $n + 1`
done
if [ $VERBOSE -eq 1 ]
then
echo "REARRANGING section number $j..."
fi
j=`expr $j + 1`;
i=`expr $i + $total`;
elif [ "$SIG_TYPE" = "folio" ]
then
# determine size of target page
if [ $(echo "$TGT_PAGE_HEIGHT == 0" | bc) -eq 1 ]
then
TGT_PAGE_HEIGHT=$(echo "$SRC_PAGE_HEIGHT * 1" | bc)
fi
if [ $(echo "$TGT_PAGE_WIDTH == 0" | bc) -eq 1 ]
then
TGT_PAGE_WIDTH=$(echo "$SRC_PAGE_WIDTH * 2" | bc)
fi
# do the rearranging
k=$i; n=1; total=$(($SECT_TYPE * 4)); m=$total
while [ $n -le $SECT_TYPE ]
do
pdftk "$NEW_FILE_NAME" cat `expr $k + $m - 1` \
`expr $k` `expr $k + 1` `expr $k + $m - 2` \
output ${tmp_name%.pdf}_$n;
k=`expr $k + 2`; n=`expr $n + 1`; m=`expr $m - 4`
done
n=1
while [ `expr $n + 0` -le $SECT_TYPE ]
do
if [ ! -e "$tmp_name" ]
then
pdftk A=${tmp_name%.pdf}_$n cat A1-end \
output "$tmp_name"
else
pdftk A="$tmp_name" B=${tmp_name%.pdf}_`expr $n` \
cat A1-end B1-end output ${tmp_name}_tmp
mv ${tmp_name}_tmp "$tmp_name"
fi
n=`expr $n + 1`
done
if [ $VERBOSE -eq 1 ]
then
echo "REARRANGING section number $j..."
fi
j=`expr $j + 1`;
i=`expr $i + $total`;
elif [ "$SIG_TYPE" = "octavo" ]
then
# determine target page dimensions
if [ $(echo "$TGT_PAGE_HEIGHT == 0" | bc) -eq 1 ]
then
TGT_PAGE_HEIGHT=$(echo "$SRC_PAGE_HEIGHT * 2" | bc)
fi
if [ $(echo "$TGT_PAGE_WIDTH == 0" | bc) -eq 1 ]
then
TGT_PAGE_WIDTH=$(echo "$SRC_PAGE_WIDTH * 4" | bc)
fi
# do the rearranging
k=$i; n=1; total=$(($SECT_TYPE * 16)); m=$total
while [ $n -le $SECT_TYPE ]
do
pdftk "$NEW_FILE_NAME" cat `expr $k + 3` \
`expr $k + $m - 4` `expr $k + $m - 1` $k \
`expr $k + 4`south `expr $k + $m - 5`south \
`expr $k + $m - 8`south `expr $k + 7`south \
`expr $k + 1` `expr $k + $m - 2` `expr $k + $m - 3` \
`expr $k + 2` `expr $k + 6`south `expr $k + $m - 7`south \
`expr $k + $m - 6`south `expr $k + 5`south \
output ${tmp_name%.pdf}_$n;
k=`expr $k + 8`; n=`expr $n + 1`; m=`expr $m - 16`
done
n=1
while [ `expr $n + 0` -le $SECT_TYPE ]
do
if [ ! -e "$tmp_name" ]
then
pdftk A=${tmp_name%.pdf}_$n cat A1-end \
output "$tmp_name"
else
pdftk A="$tmp_name" B=${tmp_name%.pdf}_`expr $n` \
cat A1-end B1-end output ${tmp_name}_tmp
mv ${tmp_name}_tmp "$tmp_name"
fi
n=`expr $n + 1`
done
if [ $VERBOSE -eq 1 ]
then
echo "REARRANGING section number $j..."
fi
j=`expr $j + 1`;
i=`expr $i + $total`;
elif [ "$SIG_TYPE" = "sexto" ]
then
# determine target page dimensions
if [ $(echo "$TGT_PAGE_HEIGHT == 0" | bc) -eq 1 ]
then
TGT_PAGE_HEIGHT=$(echo "$SRC_PAGE_HEIGHT * 3" | bc)
fi
if [ $(echo "$TGT_PAGE_WIDTH == 0" | bc) -eq 1 ]
then
TGT_PAGE_WIDTH=$(echo "$SRC_PAGE_WIDTH * 2" | bc)
fi
# do the rearranging
k=$i; n=1; total=$(($SECT_TYPE * 12)); m=$total
while [ $n -le $SECT_TYPE ]
do
pdftk "$NEW_FILE_NAME" cat `expr $k + 5` \
`expr $k + 6` `expr $k + $m - 1` $k \
`expr $k + $m - 1 - 3`south `expr $k + 3`south \
`expr $k + 7` `expr $k + 4` \
`expr $k + 1` `expr $k + $m - 1 - 1` \
`expr $k + 2`south `expr $k + $m - 1 - 2`south \
output ${tmp_name%.pdf}_$n;
k=`expr $k + 6`; n=`expr $n + 1`; m=`expr $m - 12`
done
n=1
while [ `expr $n + 0` -le $SECT_TYPE ]
do
if [ ! -e "$tmp_name" ]
then
pdftk A=${tmp_name%.pdf}_$n cat A1-end \
output "$tmp_name"
else
pdftk A=$tmp_name B=${tmp_name%.pdf}_`expr $n` \
cat A1-end B1-end output ${tmp_name}_tmp
mv ${tmp_name}_tmp "$tmp_name"
fi
n=`expr $n + 1`
done
if [ $VERBOSE -eq 1 ]
then
echo "REARRANGING section number $j..."
fi
j=`expr $j + 1`;
i=`expr $i + $total`;
elif [ "$SIG_TYPE" = "duodecimo" ]
then
# determine target page dimensions
if [ $(echo "$TGT_PAGE_HEIGHT == 0" | bc) -eq 1 ]
then
TGT_PAGE_HEIGHT=$(($SRC_PAGE_HEIGHT * 3))
fi
if [ $(echo "$TGT_PAGE_WIDTH == 0" | bc) -eq 1 ]
then
TGT_PAGE_WIDTH=$(($SRC_PAGE_WIDTH * 4))
fi
# do the rearranging
k=$i; n=1; total=$(($SECT_TYPE * 24)); m=$total
while [ $n -le $SECT_TYPE ]
do
pdftk "$NEW_FILE_NAME" cat `expr $k + 8` \
`expr $k + $m - 1 - 8` `expr $k + 12` \
`expr $k + 11` `expr $k + 4` \
`expr $k + $m - 1 - 3` `expr $k + $m - 1` \
$k `expr $k + 4`south `expr $k + $m - 1 - 4`south \
`expr $k + $m - 1 - 7`south `expr $k + 7`south \
`expr $k + 10` `expr $k + 13` `expr $k + 14` \
`expr $k + 9` `expr $k + 1` `expr $k + $m - 1 - 1` \
`expr $k + $m - 1 - 2` `expr $k + 2` \
`expr $k + 6`south `expr $k + $m - 1 - 6`south \
`expr $k + $m - 1 - 5`south `expr $k + 5`south \
output ${tmp_name%.pdf}_$n;
k=`expr $k + 12`; n=`expr $n + 1`; m=`expr $m - 24`
done
n=1
while [ `expr $n + 0` -le $SECT_TYPE ]
do
if [ ! -e "$tmp_name" ]
then
pdftk A=${tmp_name%.pdf}_$n cat A1-end \
output $tmp_name
else
pdftk A="$tmp_name" B=${tmp_name%.pdf}_`expr $n` \
cat A1-end B1-end output ${tmp_name}_tmp
mv ${tmp_name}_tmp "$tmp_name"
fi
n=`expr $n + 1`
done
if [ $VERBOSE -eq 1 ]
then
echo "REARRANGING section number $j..."
fi
j=`expr $j + 1`;
i=`expr $i + $total`;
fi
done
mv "$tmp_name" "$NEW_FILE_NAME"
rm ${tmp_name%.pdf}*
echo "\documentclass{article}
\usepackage{pdfpages}
\usepackage[paperwidth=${TGT_PAGE_WIDTH}bp,paperheight=${TGT_PAGE_HEIGHT}bp]{geometry}
\pagestyle{empty}" > ${OUTFILE_NAME%.pdf}.tex
echo '\\begin{document}' >> ${OUTFILE_NAME%.pdf}.tex
echo "\includepdf[nup=$NUP,pages=-,turn=false,columnstrict,
noautoscale,delta=${HORIZ_DELTA}bp ${VERT_DELTA}bp,
offset=${HORIZ_OFFSET}bp ${VERT_OFFSET}bp,scale=${SCALE}]
{./"$NEW_FILE_NAME"}\end{document}" >> ${OUTFILE_NAME%.pdf}.tex
if [ $VERBOSE -eq 1 ]
then
echo "IMPOSING sections..."
fi
pdflatex ${OUTFILE_NAME%.pdf}.tex #> /dev/null 2>&1
if [ $VERBOSE -eq 1 ]
then
echo "CLEANING up..."
fi
rm ${OUTFILE_NAME%.pdf}.tex ${OUTFILE_NAME%.pdf}.aux \
${OUTFILE_NAME%.pdf}.log "$NEW_FILE_NAME"
if [ $VERBOSE -eq 1 ]
then
echo "`expr $NUM_PAGES + $NUM_BLANKS` pages imposed in
$(($NUM_SIGS * $SECT_TYPE)) $SIG_TYPE signatures gathered
in sections of $SECT_TYPE signature(s) each and output to
${OUTFILE_NAME%.pdf}.pdf."
fi
if [ "$OUTFILE_NAME" = "stdout" ]
then
cat ${OUTFILE_NAME}.pdf
rm ${OUTFILE_NAME}.pdf
fi
exit 0

BIN
src/images/title.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

69
src/kommersbuch.tex Normal file
View File

@ -0,0 +1,69 @@
% !Mode:: "TeX:UTF-8"
\documentclass[9pt, a4paper, openany]{scrbook}
\usepackage{fontspec}
\usepackage{fancyhdr}
\usepackage{geometry}
\usepackage{tgschola}
\usepackage{tocloft}
\usepackage[unicode]{hyperref}
\usepackage{songs}
\usepackage{lyluatex}
\makeatletter
\newcommand{\unchapter}[1]{%
\begingroup
\let\@makechapterhead\@gobble % make \@makechapterhead do nothing
\chapter{#1}
\endgroup
}
\makeatother
\setlength{\headheight}{15pt}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{ \markboth{#1}{} }
\renewcommand{\sectionmark}[1]{ \markright{#1}{} }
\fancyhf{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[RE]{\textit{ \nouppercase{\leftmark}} }
\fancyhead[LO]{\textit{ \nouppercase{\rightmark}} }
\fancypagestyle{plain}{
\fancyhf{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[RE]{\textit{ \nouppercase{Alcolica}} }
\fancyhead[LO]{\textit{ \nouppercase{Alcolica}} }
}
\geometry{a5paper,left=20mm,right=20mm, top=3cm, bottom=3cm}
\renewcommand\addchaptertocentry[2]{\addtocentrydefault{chapter}{}{#2}}
\renewcommand{\contentsname}{Inhalt}
\renewcommand{\cfttoctitlefont}{\huge\textbf\rmfamily}
\renewcommand{\cftchapfont}{\large\rmfamily}
\begin{document}
\begin{titlepage}
\begin{center}
\includegraphics[width=0.50 \textwidth]{images/title.png}\\
\rule{\linewidth}{0.5mm} \\[0.4cm]
{ \huge \bfseries Alcolica}
\rule{\linewidth}{0.5mm} \\[1.5cm]
\end{center}
\end{titlepage}
\pagenumbering{Roman}
\tableofcontents
\newpage
\songs
\end{document}

View File

@ -2,17 +2,18 @@ local err, warn, info, log = luatexbase.provides_module({
name = "lyluatex", name = "lyluatex",
version = '0', version = '0',
greinternalversion = internalversion, greinternalversion = internalversion,
date = "2016/09/08", date = "2017/09/30",
description = "Module lyluatex.", description = "Module lyluatex.",
author = "The Gregorio Project (see CONTRIBUTORS.md)", author = "The Gregorio Project (see CONTRIBUTORS.md)",
copyright = "2008-2016 - The Gregorio Project", copyright = "2008-2017 - The Gregorio Project",
license = "MIT", license = "MIT",
}) })
local md5 = require 'md5' local md5 = require 'md5'
LILYPOND = 'lilypond' LILYPOND = 'lilypond'
TMP = (os.getenv('TMP_LY') and os.getenv('TMP_LY') or 'tmp_ly') TMP = 'tmp_ly'
N = 0 N = 0
@ -42,7 +43,8 @@ end
function direct_ly(ly, largeur, facteur) function direct_ly(ly, largeur, facteur)
N = N + 1 N = N + 1
facteur = calcul_facteur(facteur) facteur = calcul_facteur(facteur)
ly = ly:gsub('\\par ', '\n') ly = ly:gsub('\\par ', '\n'):gsub('\\([^%s]*) %-([^%s])', '\\%1-%2')
print(ly)
local sortie = TMP..'/'..string.gsub(md5.sumhexa(contenuIntegral(ly))..'-'..facteur..'-'..largeur, '%.', '-') local sortie = TMP..'/'..string.gsub(md5.sumhexa(contenuIntegral(ly))..'-'..facteur..'-'..largeur, '%.', '-')
if not lfs.isfile(sortie..'-systems.tex') then if not lfs.isfile(sortie..'-systems.tex') then
compiler_ly(entete_lilypond(facteur, largeur - 10)..'\n'..ly, sortie) compiler_ly(entete_lilypond(facteur, largeur - 10)..'\n'..ly, sortie)
@ -75,7 +77,7 @@ function compiler_ly(ly, sortie, include)
"-dbackend=eps ".. "-dbackend=eps "..
"-djob-count=2 ".. "-djob-count=2 "..
"-ddelete-intermediate-files " "-ddelete-intermediate-files "
if include then commande = commande.."-I "..lfs.currentdir()..'/'..include.." " end if include then commande = commande.."-I '"..lfs.currentdir().."/"..include.."' " end
commande = commande.."-o "..sortie.." -" commande = commande.."-o "..sortie.." -"
local p = io.popen(commande, 'w') local p = io.popen(commande, 'w')
p:write(ly) p:write(ly)
@ -181,4 +183,5 @@ function fontinfo(id)
return font.fonts[id] return font.fonts[id]
end end
mkdirs(TMP) mkdirs(TMP)

View File

@ -61,7 +61,7 @@
\newkeyenvironment{ly}[staffsize=\staffsize][autres]{% \newkeyenvironment{ly}[staffsize=\staffsize][autres]{%
\def\localstaffsize{\commandkey{staffsize}}% \def\localstaffsize{\commandkey{staffsize}}%
\compilerly% \compilerly%
}{ }{%
\endcompilerly% \endcompilerly%
} }

22
src/song.tex Normal file
View File

@ -0,0 +1,22 @@
% !Mode:: "TeX:UTF-8"
\documentclass[fontsize=9pt, a4paper, openany]{article}
\usepackage{fontspec}
\usepackage{lmodern}
\usepackage{tgschola}
\usepackage[unicode]{hyperref}
\usepackage{lyluatex}
\begin{document}
\pagenumbering{gobble}
\directlua{
tex.sprint("\string\\includely[staffsize=14]{" .. arg[5] .. "}")
}
~\\
\directlua{
tex.sprint("\string\\input{" .. arg[6] .. "}")
}
\end{document}

30
src/songs.lua Normal file
View File

@ -0,0 +1,30 @@
require "lfs"
local open = io.open
local function read_file(path)
local file = open(path, "rb") -- r read mode and b binary mode
if not file then return nil end
local content = file:read "*a" -- *a or *all reads the whole file
file:close()
return content
end
function string.ends(String,End)
return End=='' or string.sub(String,-string.len(End))==End
end
function find_songs(dir)
for file in lfs.dir(dir) do
if string.ends(file, ".ly") then
local ly_content = read_file(dir .. '/' .. file)
local ly_title = string.match(ly_content, 'title = "(.-)"')
tex.sprint('\\unchapter{' .. ly_title .. '}')
tex.sprint('\\includely[staffsize=14]{' .. dir .. '/' .. file .. '}')
tex.sprint('~\\\\')
tex.sprint('~\\\\')
tex.sprint('\\input{' .. dir .. '/' .. file:gsub("%.ly", ".tex") .. '}')
end
end
end

19
src/songs.sty Normal file
View File

@ -0,0 +1,19 @@
\ProvidesPackage{songs}
\RequirePackage{luatexbase}
\RequirePackage{luaotfload}
\RequirePackage{kvoptions}
\RequirePackage{keycommand}
\RequirePackage{currfile}
\directlua{dofile(kpse.find_file("songs.lua"))}
\def\songpath{"./songs"}
% Commandes principales
% Inclusion d'un fichier ly
\newkeycommand*\songs[songpath=\songpath]{%
\directlua{%
find_songs(\songpath)%
}%
}

View File

@ -67,17 +67,6 @@ verseOne = \lyricmode {
} }
\book { \book {
\bookOutputName "bierlein_rinn_score"
\score {
<<
\new Voice = "one" {
\musicOne
}
>>
\layout {
}
}
\score { \score {
\unfoldRepeats \articulate \unfoldRepeats \articulate
<< <<

View File

@ -33,7 +33,7 @@ musicOne = \relative f' {
verseOne = \lyricmode { verseOne = \lyricmode {
Hier sind wir ver -- sam -- melt zu | Hier sind wir ver -- sam -- melt zu |
löb -- li -- chem Run, drum, | löb -- li -- chem Tun, drum, |
Brü -- der -- chen, er -- go bi -- | Brü -- der -- chen, er -- go bi -- |
ba -- mus! (Das) | ba -- mus! (Das) |
heisst noch ein altes, ein | heisst noch ein altes, ein |
@ -75,17 +75,6 @@ verseOneRepeat = \lyricmode {
} }
\book { \book {
\bookOutputName "ergo_bibamus_score"
\score {
<<
\new Voice = "one" {
\musicOne
}
>>
\layout {
}
}
\score { \score {
\unfoldRepeats \articulate \unfoldRepeats \articulate
<< <<

View File

@ -57,17 +57,6 @@ verseOne = \lyricmode {
} }
\book { \book {
\bookOutputName "gaudeamus_igitur_score"
\score {
<<
\new Voice = "one" {
\musicOne
}
>>
\layout {
}
}
\score { \score {
\unfoldRepeats \articulate \unfoldRepeats \articulate
<< <<

View File

@ -57,17 +57,6 @@ verseOne = \lyricmode {
} }
\book { \book {
\bookOutputName "in_jedem_vollen_glase_wein_score"
\score {
<<
\new Voice = "one" {
\musicOne
}
>>
\layout {
}
}
\score { \score {
\unfoldRepeats \articulate \unfoldRepeats \articulate
<< <<

View File

@ -63,17 +63,6 @@ verseOne = \lyricmode {
} }
\book { \book {
\bookOutputName "lindenwirtin_score"
\score {
<<
\new Voice = "one" {
\musicOne
}
>>
\layout {
}
}
\score { \score {
\unfoldRepeats \articulate \unfoldRepeats \articulate
<< <<

View File

@ -66,17 +66,6 @@ verseOne = \lyricmode {
} }
\book { \book {
\bookOutputName "viel_volle_becher_score"
\score {
<<
\new Voice = "one" {
\musicOne
}
>>
\layout {
}
}
\score { \score {
\unfoldRepeats \articulate \unfoldRepeats \articulate
<< <<

View File

@ -0,0 +1 @@
\relax

View File

@ -0,0 +1,20 @@
# Fdb version 3
["pdflatex"] 1509718845 "/Users/sebastianhugentobler/Documents/workspace/kommersbuch/src/templates/kommersbuch.j2" "kommersbuch.pdf" "kommersbuch" 1509718845
"/Users/sebastianhugentobler/Documents/workspace/kommersbuch/src/templates/kommersbuch.j2" 1509716660 1691 f5909bb2d078cf0c32c064bc3562d216 ""
"/opt/local/etc/texmf/texmf.cnf" 1498210216 30504 ca4c9cc71f3515cad4981dfa185b811b ""
"/opt/local/share/texmf-texlive/tex/generic/unicode-data/CaseFolding.txt" 1493155083 78161 e3fbf2f626f10070000fe66f3a2ff5ef ""
"/opt/local/share/texmf-texlive/tex/generic/unicode-data/SpecialCasing.txt" 1493155083 16830 fea30f45a2f81ffa474fd984d297e2ea ""
"/opt/local/share/texmf-texlive/tex/generic/unicode-data/UnicodeData.txt" 1493155083 1686443 dde25b1cf9bbb4ba1140ac12e4128b0b ""
"/opt/local/share/texmf-texlive/tex/latex/base/article.cls" 1467165121 19821 310da678527a7dfe2a02c88af38079b7 ""
"/opt/local/share/texmf-texlive/tex/latex/base/size10.clo" 1467165122 8292 e897c12e1e886ce77fe26afc5d470886 ""
"/opt/local/share/texmf-texlive/tex/latex/fontspec/fontspec.sty" 1493155085 1704 f155bd31324526584df93d8880629e82 ""
"/opt/local/share/texmf-texlive/tex/latex/l3kernel/expl3-code.tex" 1496799555 689208 a4a1f960caacd72906628f3f1a2e3b4c ""
"/opt/local/share/texmf-texlive/tex/latex/l3kernel/expl3.sty" 1496799555 9344 31607e39934aa760394a75d15a0594e0 ""
"/opt/local/share/texmf-texlive/tex/latex/l3kernel/l3pdfmode.def" 1496799555 10255 ae20359c06d3acc750024781d0520fe6 ""
"/opt/local/share/texmf-texlive/tex/latex/l3packages/xparse/xparse.sty" 1496799555 76757 9db3143638eba1ea8405900fbbcff235 ""
"/opt/local/var/db/texmf/web2c/pdftex/pdflatex.fmt" 1498210795 3768257 ca4ae9b50676c7797795cbaf354884e6 ""
"kommersbuch.aux" 1509718845 8 a94a2480d3289e625eea47cd1b285758 ""
"kommersbuch.j2" 1509716660 1691 f5909bb2d078cf0c32c064bc3562d216 ""
(generated)
"kommersbuch.log"
"kommersbuch.pdf"

View File

@ -0,0 +1,22 @@
PWD /Users/sebastianhugentobler/Documents/workspace/kommersbuch/src/templates
INPUT /opt/local/etc/texmf/texmf.cnf
INPUT /opt/local/var/db/texmf/web2c/pdftex/pdflatex.fmt
INPUT /Users/sebastianhugentobler/Documents/workspace/kommersbuch/src/templates/kommersbuch.j2
OUTPUT kommersbuch.log
INPUT /opt/local/share/texmf-texlive/tex/latex/base/article.cls
INPUT /opt/local/share/texmf-texlive/tex/latex/base/article.cls
INPUT /opt/local/share/texmf-texlive/tex/latex/base/size10.clo
INPUT /opt/local/share/texmf-texlive/tex/latex/base/size10.clo
INPUT /opt/local/share/texmf-texlive/tex/latex/fontspec/fontspec.sty
INPUT /opt/local/share/texmf-texlive/tex/latex/fontspec/fontspec.sty
INPUT /opt/local/share/texmf-texlive/tex/latex/l3kernel/expl3.sty
INPUT /opt/local/share/texmf-texlive/tex/latex/l3kernel/expl3.sty
INPUT /opt/local/share/texmf-texlive/tex/latex/l3kernel/expl3-code.tex
INPUT /opt/local/share/texmf-texlive/tex/latex/l3kernel/expl3-code.tex
INPUT /opt/local/share/texmf-texlive/tex/generic/unicode-data/UnicodeData.txt
INPUT /opt/local/share/texmf-texlive/tex/generic/unicode-data/CaseFolding.txt
INPUT /opt/local/share/texmf-texlive/tex/generic/unicode-data/SpecialCasing.txt
INPUT /opt/local/share/texmf-texlive/tex/latex/l3kernel/l3pdfmode.def
INPUT /opt/local/share/texmf-texlive/tex/latex/l3kernel/l3pdfmode.def
INPUT /opt/local/share/texmf-texlive/tex/latex/l3packages/xparse/xparse.sty
INPUT /opt/local/share/texmf-texlive/tex/latex/l3packages/xparse/xparse.sty

View File

@ -1,6 +1,6 @@
% !Mode:: "TeX:UTF-8" % !Mode:: "TeX:UTF-8"
\documentclass[9pt, a5paper, openany]{scrbook} \documentclass[9pt, a4paper, openany]{article}
\usepackage{fontspec} \usepackage{fontspec}
\usepackage{lmodern} \usepackage{lmodern}

View File

@ -0,0 +1,182 @@
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017/MacPorts 2017_2) (preloaded format=pdflatex 2017.6.23) 3 NOV 2017 15:20
entering extended mode
restricted \write18 enabled.
file:line:error style messages enabled.
%&-line parsing enabled.
**/Users/sebastianhugentobler/Documents/workspace/kommersbuch/src/templates/kom
mersbuch.j2
(/Users/sebastianhugentobler/Documents/workspace/kommersbuch/src/templates/komm
ersbuch.j2
LaTeX2e <2017-04-15>
Babel <3.10> and hyphenation patterns for 55 language(s) loaded.
(/opt/local/share/texmf-texlive/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/opt/local/share/texmf-texlive/tex/latex/base/size10.clo
File: size10.clo 2014/09/29 v1.4h Standard LaTeX file (size option)
)
\c@part=\count79
\c@section=\count80
\c@subsection=\count81
\c@subsubsection=\count82
\c@paragraph=\count83
\c@subparagraph=\count84
\c@figure=\count85
\c@table=\count86
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
)
(/opt/local/share/texmf-texlive/tex/latex/fontspec/fontspec.sty
(/opt/local/share/texmf-texlive/tex/latex/l3kernel/expl3.sty
Package: expl3 2017/05/13 L3 programming layer (loader)
(/opt/local/share/texmf-texlive/tex/latex/l3kernel/expl3-code.tex
Package: expl3 2017/05/13 L3 programming layer (code)
\c_max_int=\count87
\l_tmpa_int=\count88
\l_tmpb_int=\count89
\g_tmpa_int=\count90
\g_tmpb_int=\count91
\g__prg_map_int=\count92
\c_log_iow=\count93
\l_iow_line_count_int=\count94
\l__iow_line_target_int=\count95
\l__iow_one_indent_int=\count96
\l__iow_indent_int=\count97
\c_zero_dim=\dimen103
\c_max_dim=\dimen104
\l_tmpa_dim=\dimen105
\l_tmpb_dim=\dimen106
\g_tmpa_dim=\dimen107
\g_tmpb_dim=\dimen108
\c_zero_skip=\skip43
\c_max_skip=\skip44
\l_tmpa_skip=\skip45
\l_tmpb_skip=\skip46
\g_tmpa_skip=\skip47
\g_tmpb_skip=\skip48
\c_zero_muskip=\muskip10
\c_max_muskip=\muskip11
\l_tmpa_muskip=\muskip12
\l_tmpb_muskip=\muskip13
\g_tmpa_muskip=\muskip14
\g_tmpb_muskip=\muskip15
\l_keys_choice_int=\count98
\c__fp_leading_shift_int=\count99
\c__fp_middle_shift_int=\count100
\c__fp_trailing_shift_int=\count101
\c__fp_big_leading_shift_int=\count102
\c__fp_big_middle_shift_int=\count103
\c__fp_big_trailing_shift_int=\count104
\c__fp_Bigg_leading_shift_int=\count105
\c__fp_Bigg_middle_shift_int=\count106
\c__fp_Bigg_trailing_shift_int=\count107
\c__fp_rand_size_int=\count108
\c__fp_rand_four_int=\count109
\c__fp_rand_eight_int=\count110
\l__sort_length_int=\count111
\l__sort_min_int=\count112
\l__sort_top_int=\count113
\l__sort_max_int=\count114
\l__sort_true_max_int=\count115
\l__sort_block_int=\count116
\l__sort_begin_int=\count117
\l__sort_end_int=\count118
\l__sort_A_int=\count119
\l__sort_B_int=\count120
\l__sort_C_int=\count121
\c_empty_box=\box26
\l_tmpa_box=\box27
\l_tmpb_box=\box28
\g_tmpa_box=\box29
\g_tmpb_box=\box30
\l__box_top_dim=\dimen109
\l__box_bottom_dim=\dimen110
\l__box_left_dim=\dimen111
\l__box_right_dim=\dimen112
\l__box_top_new_dim=\dimen113
\l__box_bottom_new_dim=\dimen114
\l__box_left_new_dim=\dimen115
\l__box_right_new_dim=\dimen116
\l__box_internal_box=\box31
\l__coffin_internal_box=\box32
\l__coffin_internal_dim=\dimen117
\l__coffin_offset_x_dim=\dimen118
\l__coffin_offset_y_dim=\dimen119
\l__coffin_x_dim=\dimen120
\l__coffin_y_dim=\dimen121
\l__coffin_x_prime_dim=\dimen122
\l__coffin_y_prime_dim=\dimen123
\c_empty_coffin=\box33
\l__coffin_aligned_coffin=\box34
\l__coffin_aligned_internal_coffin=\box35
\l_tmpa_coffin=\box36
\l_tmpb_coffin=\box37
\l__coffin_display_coffin=\box38
\l__coffin_display_coord_coffin=\box39
\l__coffin_display_pole_coffin=\box40
\l__coffin_display_offset_dim=\dimen124
\l__coffin_display_x_dim=\dimen125
\l__coffin_display_y_dim=\dimen126
\l__coffin_bounding_shift_dim=\dimen127
\l__coffin_left_corner_dim=\dimen128
\l__coffin_right_corner_dim=\dimen129
\l__coffin_bottom_corner_dim=\dimen130
\l__coffin_top_corner_dim=\dimen131
\l__coffin_scaled_total_height_dim=\dimen132
\l__coffin_scaled_width_dim=\dimen133
)
(/opt/local/share/texmf-texlive/tex/latex/l3kernel/l3pdfmode.def
File: l3pdfmode.def 2017/03/18 v L3 Experimental driver: PDF mode
\l__driver_color_stack_int=\count122
\l__driver_tmp_box=\box41
))
(/opt/local/share/texmf-texlive/tex/latex/l3packages/xparse/xparse.sty
Package: xparse 2017/05/13 L3 Experimental document command parser
\l__xparse_current_arg_int=\count123
\g__xparse_grabber_int=\count124
\l__xparse_m_args_int=\count125
\l__xparse_mandatory_args_int=\count126
\l__xparse_v_nesting_int=\count127
)
Package: fontspec 2017/03/31 v2.6a Font selection for XeLaTeX and LuaLaTeX
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
/opt/local/share/texmf-texlive/tex/latex/fontspec/fontspec.sty:28: Fatal fontsp
ec error: "cannot-use-pdftex"
!
! The fontspec package requires either XeTeX or LuaTeX.
!
! You must change your typesetting engine to, e.g., "xelatex" or
! "lualatex"instead of plain "latex" or "pdflatex".
!
! See the fontspec documentation for further information.
!
! For immediate help type H <return>.
!...............................................
l.28 \msg_fatal:nn {fontspec} {cannot-use-pdftex}
|'''''''''''''''''''''''''''''''''''''''''''''''
| This is a fatal error: LaTeX will abort.
|...............................................
) )
Here is how much of TeX's memory you used:
7521 strings out of 493588
152856 string characters out of 6147356
171207 words of memory out of 5000000
10980 multiletter control sequences out of 15000+600000
3640 words of font info for 14 fonts, out of 8000000 for 9000
846 hyphenation exceptions out of 8191
33i,1n,32p,10444b,275s stack positions out of 5000i,500n,10000p,200000b,80000s
No pages of output.
PDF statistics:
0 PDF objects out of 1000 (max. 8388607)
0 named destinations out of 1000 (max. 500000)
1 words of extra memory for PDF output out of 10000 (max. 10000000)

170
waf vendored

File diff suppressed because one or more lines are too long

178
wscript
View File

@ -1,178 +0,0 @@
#! /usr/bin/env python
# encoding: utf-8
import os
import re
from functools import reduce
from waflib import TaskGen
APPNAME = 'kommersbuch'
VERSION = '1.0'
top = '.'
out = 'build'
src = 'src'
lib = 'lib'
src_scores = os.path.join(src, 'scores')
src_lyrics = os.path.join(src, 'lyrics')
built_lyrics_path = os.path.abspath(os.path.join(out, src, 'lyrics'))
built_scores_path = os.path.abspath(os.path.join(out, src, 'scores'))
templater_path = os.path.abspath(os.path.join(src, 'tools/templater.py'))
score_lyrics_template_path = os.path.abspath(
os.path.join(src, 'templates', 'score_lyrics.j2'))
book_template_path = os.path.abspath(
os.path.join(src, 'templates', 'book.j2'))
def dist(ctx):
ctx.excl = '**/.waf* **/*~ **/*.pyc **/*.swp **/.lock* out pdf midi music .git .DS_Store'
def configure(ctx):
ctx.find_program('lualatex', var='LUALATEX')
ctx.find_program('lilypond', var='LILYPOND')
ctx.find_program('timidity', var='TIMIDITY')
ctx.find_program('opusenc', var='OPUSENC')
def pre(ctx):
os.system('mkdir -p {1} && cp -r {0}/* {1}'.format(lib, built_lyrics_path))
TaskGen.declare_chain(
name='opus',
rule='${TIMIDITY} ${SRC} -Ow -o - | ${OPUSENC} - ${TGT}',
ext_in='.midi',
ext_out='.opus',
shell=True)
def build(ctx):
ctx.add_pre_fun(pre)
ctx.add_group('lilypond')
ctx.add_group('opus')
ctx.add_group('book')
lilypond_rule = '${LILYPOND} -o ${TGT[0].abspath().replace(".pdf", "")} ${SRC}'
lyrics_template_rule = templater_path + ' ' + \
score_lyrics_template_path + ' "{0}" > ${{TGT}}'
book_template_rule = templater_path + ' ' + \
book_template_path + ' "{0}" > ${{TGT}}'
lyrics_combined_rule = 'cd ' + built_lyrics_path + \
' && ${LUALATEX} --shell-escape '
scoredata = []
scores = ctx.path.ant_glob(src_scores + '/*.ly')
for score in scores:
filename = os.path.basename(score.abspath())
lyricsfile = os.path.join(src_lyrics, filename.replace('.ly', '.tex'))
lilyfile = filename.replace('.ly', '.pdf')
lily_score_file = '{0}_score.pdf'.format(
lilyfile.replace('.pdf', ''))
lily_midi_file = lilyfile.replace('.pdf', '_score.midi')
target_files = '{0} {1} {2}'.format(
os.path.join(src_scores, lilyfile),
os.path.join(src_scores, lily_score_file),
os.path.join(src_scores, lily_midi_file))
score_content = ''
with open(score.abspath(), 'r') as f:
score_content = f.read()
matches = re.findall('title = "(.*)"', score_content)
score_title = matches[0]
scoredata.append(
{'title': score_title,
'score': score.abspath(),
'lyrics': os.path.abspath(lyricsfile)})
ctx.set_group('lilypond')
# score without lyrics & midi
ctx(
rule=lilypond_rule,
source=score,
target=target_files,
shell=True
)
# score with lyrics
template_data = {
'score_file': score.abspath(),
'lyrics_file': os.path.abspath(lyricsfile)
}
lyrics_rule = lyrics_template_rule.format(str(template_data))
built_lyricsfile = os.path.join(
src_lyrics,
filename.replace('.ly', '_built.tex'))
ctx(
rule=lyrics_rule,
source=lyricsfile,
target=built_lyricsfile,
shell=True
)
final_lyrics_path = os.path.join(
built_scores_path, filename.replace('.ly', '_lyrics.pdf'))
lyrics_combined_rule_final = lyrics_combined_rule + \
filename.replace('.ly', '_built.tex') + \
' && cp ' + filename.replace('.ly', '_built.pdf') + \
' ' + final_lyrics_path
ctx(
rule=lyrics_combined_rule_final,
source=score.relpath() + ' ' + built_lyricsfile,
target=os.path.join(
src_scores, filename.replace('.ly', '_lyrics.pdf')),
shell=True
)
# opus
ctx.set_group('opus')
ctx(source=os.path.join(src_scores, lily_midi_file))
# booklet
template_data = {
'scores': scoredata,
}
book_rule = book_template_rule.format(str(template_data))
built_bookfile = os.path.join(src_lyrics, 'book.tex')
ctx.set_group('book')
ctx(
rule=book_rule,
source=os.path.relpath(book_template_path),
target=built_bookfile,
shell=True
)
final_book_path = os.path.join(built_scores_path, 'book.pdf')
book_combined_rule_final = lyrics_combined_rule + \
'book.tex' + \
' && cp book.pdf' + \
' ' + final_book_path
book_sources = os.path.relpath(book_template_path)
for score in scoredata:
book_sources = '{0} {1} {2}'.format(
book_sources,
os.path.relpath(score['score']),
os.path.relpath(score['lyrics']))
ctx(
rule='{0} && {0}'.format(book_combined_rule_final),
source=book_sources,
target=os.path.join(src_scores, 'book.pdf'),
shell=True
)