2 \include "common/common.ily"
4 #(use-modules (ice-9 optargs))
6 #(define-markup-command (column layout props args) (markup-list?)
7 #:properties ((baseline-skip))
8 (let ((arg-stencils (interpret-markup-list layout props args)))
10 (space-lines baseline-skip
11 (remove ly:stencil-empty? arg-stencils)))))
13 #(define (print-score key name title . rest)
14 (markup #:hspace 5 "⁃" title))
16 #(define* (print-opus title #:key description key opus url main parts)
17 (let ((title-markup (make-fontsize-markup
21 (list (markup #:fontsize -2 #:concat ("[" opus "]")
24 (list (markup #:italic title))))))
25 (descr-markup (make-column-markup (if description (list description) (list))))
26 (books-markup (make-column-markup
28 (map (lambda (book-spec)
29 (markup #:hspace 3 (cadr book-spec)))
32 (parts-markup (make-column-markup
34 (cons (markup #:hspace 3 "Parties séparées :")
35 (map (lambda (part-spec)
36 (apply print-score key part-spec))
39 (url-markup (make-column-markup
41 (list (markup #:fontsize -2 #:with-url url #:typewriter url))
43 (markup #:force-line-width-ratio 0.45
44 #:column (#:fontsize 1 title-markup
51 #(define-markup-command (composer-section layout props composer-works) (list?)
52 #:properties ((column-number 2)
53 (inter-column-padding 6))
54 (let* ((title-item (car composer-works))
55 (items (cadr composer-works))
58 (interpret-markup layout props
59 (apply print-opus item)))
62 (if (null? title-item)
66 (markup #:column (#:fill-line (#:fontsize 3 #:italic title-item) #:vspace 0.5)))))
67 (total-height (reduce + 0 (map (lambda (stencil)
68 (interval-length (ly:stencil-extent stencil Y)))
70 (average-height (/ total-height column-number)))
71 (let fill-columns ((lines item-stencils)
72 (current-column-index 1)
73 (current-column-height 0)
74 (current-column-lines '())
75 (previous-columns '()))
77 ;; the end result: the section title and the items on several columns
83 (reverse! (if current-column-lines
86 (reverse! current-column-lines))
89 ;; go on collecting the item stencils into columns
90 (let* ((line (car lines))
91 (height (interval-length (ly:stencil-extent line Y))))
92 (if (and (< current-column-index column-number)
93 (>= (+ current-column-height height) average-height))
94 ;; this line ends filling this column
95 ;; => start a new column after it
96 (fill-columns (cdr lines)
97 (1+ current-column-index)
100 (cons (ly:make-stencil
101 "" (cons 0 inter-column-padding) '(0 . 0))
104 (reverse! (cons line current-column-lines)))
106 ;; there is still room in this column
107 ;; => go on filling it
108 (fill-columns (cdr lines)
110 (+ current-column-height height)
111 (cons line current-column-lines)
112 previous-columns)))))))
114 #(define-markup-list-command (catalog layout props catalog) (list?)
115 (interpret-markup-list
117 (make-column-lines-markup-list
118 (map (lambda (composer-works)
119 (markup #:composer-section composer-works))
123 %%% Makefile generation
126 #(define* (print-makefile-score is-part key name title #:key score-file options part)
127 (let ((target (format #f "~a~a"
129 (if name (format #f "-~a" name) "")))
130 (output (format #f "$(OUTPUT_DIR)/~a~a"
132 (if name (format #f "-~a" name) "")))
133 (all-options (cond (is-part
134 (format #f "-dpart=~a ~a"
135 (or part name) (or options "")))
138 (ly-file (format #f "~a/~a"
141 (if is-part "part.ly" "main.ly")))))
148 (or title name) target output all-options ly-file target)
149 (cons target (format #f "~a.pdf" output))))
151 #(define* (print-makefile-opus title #:key description key opus url main parts)
152 (let* ((split-path (string-split key #\/))
153 (delivery-dir (format #f "$(DELIVERY_DIR)/~a/~a"
155 (car (reverse split-path)))))
156 (format #t "### ~a~%" title)
160 (for-each (lambda (book-spec)
161 (let ((target+pdf (apply print-makefile-score #f key book-spec)))
162 (set! pdfs (cons (cdr target+pdf) pdfs))
163 (set! score-targets (cons (car target+pdf) score-targets))))
166 (for-each (lambda (part-spec)
167 (let ((target+pdf (apply print-makefile-score #t key part-spec)))
168 (set! pdfs (cons (cdr target+pdf) pdfs))
169 (set! score-targets (cons (car target+pdf) score-targets))))
171 (set! pdfs (reverse! pdfs))
172 (set! score-targets (reverse! score-targets))
173 ;; -delivery rule: PDF, MIDI archive, source archive
174 (format #t "~%~a-delivery:
176 @if [ -e $(OUTPUT_DIR)/~a-1.midi ]; then tar zcf ~a/~a-midi.tar.gz $(OUTPUT_DIR)/~a.midi $(OUTPUT_DIR)/~a-[0-9]*.midi; elif [ -e $(OUTPUT_DIR)/~a.midi ]; then cp $(OUTPUT_DIR)/~a.midi ~a/ ; fi
177 git archive --prefix=~a/ HEAD ~a common out templates Makefile README | gzip > ~a/~a.tar.gz~%"
181 (format #f " @if [ -e ~a ]; then mv -fv ~a ~a; fi" pdf pdf delivery-dir))
183 (basename key) delivery-dir (basename key) (basename key) (basename key)
184 (basename key) (basename key) delivery-dir
185 (basename key) key delivery-dir (basename key))
187 (format #t "~%~a-clean:
188 @rm -f $(OUTPUT_DIR)/~a-* $(OUTPUT_DIR)/~a.*~%"
189 key (basename key) (basename key))
191 (format #t "~%~a-all:~{ \\~% ~a~}\\
195 .PHONY: ~a-delivery ~a-clean ~a-all~2%"
196 key score-targets key key key key key))))
198 #(define (print-makefile-composer-work composer-work)
199 (format #t "###~%### ~a~%###~%" (car composer-work))
200 (for-each (lambda (opus-spec)
201 (apply print-makefile-opus opus-spec))
202 (cadr composer-work)))
205 #(define-public (export-makefile filename catalog)
206 (format #t "~%Exporting ~a..." filename)
207 (with-output-to-file filename
209 (format #t "### File generated by LilyPond
210 ### run: lilypond catalogue.ly
213 DELIVERY_DIR=delivery
214 LILYPOND_CMD=lilypond --loglevel=WARN -ddelete-intermediate-files -dno-protected-scheme-parsing~2%")
215 (for-each print-makefile-composer-work catalog))))
218 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%