1 ;;;; This file is part of LilyPond, the GNU music typesetter.
3 ;;;; Copyright (C) 1998--2011 Jan Nieuwenhuizen <janneke@gnu.org>
4 ;;;; Han-Wen Nienhuys <hanwen@xs4all.nl>
6 ;;;; LilyPond is free software: you can redistribute it and/or modify
7 ;;;; it under the terms of the GNU General Public License as published by
8 ;;;; the Free Software Foundation, either version 3 of the License, or
9 ;;;; (at your option) any later version.
11 ;;;; LilyPond is distributed in the hope that it will be useful,
12 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;;; GNU General Public License for more details.
16 ;;;; You should have received a copy of the GNU General Public License
17 ;;;; along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
19 ;; Internationalisation: (_i "to be translated") gets an entry in the
20 ;; POT file; (gettext ...) must be invoked explicitly to do the actual
23 ;; (define-macro (_i x) x)
24 ;; (define-macro-public _i (x) x)
25 ;; (define-public-macro _i (x) x)
28 (defmacro-public _i (x) x)
30 ;;; Boolean thunk - are we integrating Guile V2.0 or higher with LilyPond?
31 (define-public (guile-v2)
32 (string>? (version) "1.9.10"))
34 (read-enable 'positions)
38 (debug-enable 'backtrace)
39 (debug-enable 'show-file-name)))
41 (define-public PLATFORM
44 (car (string-tokenize (utsname:sysname (uname)))))))
46 (define scheme-options-definitions
50 ;; - [subject-]object-object-verb +"ing"
51 ;; - [subject-]-verb-object-object
53 ;; Avoid overlong lines in `lilypond -dhelp'! Strings should not
54 ;; be longer than 48 characters per line.
57 "Render at higher resolution (using given factor)
58 and scale down result to prevent jaggies in
61 "Create .tex, .texi, .count files in the
64 "Select backend. Possible values: 'eps, 'null,
65 'ps, 'scm, 'socket, 'svg.")
66 (check-internal-types #f
67 "Check every property assignment for types.")
69 "Generate cut-out snippets of a score.")
71 "LilyPond prefix for data files (read-only).")
73 "Dump memory debugging statistics.")
74 (debug-gc-assert-parsed-dead #f
75 "For memory debugging: Ensure that all
76 references to parsed objects are dead. This is
77 an internal option, and is switched on
78 automatically for `-ddebug-gc'.")
80 "Debug the flex lexer.")
81 (debug-page-breaking-scoring #f
82 "Dump scores for many different page breaking
85 "Debug the bison parser.")
86 (debug-property-callbacks #f
87 "Debug cyclic callback chains.")
90 (delete-intermediate-files #t
91 "Delete unusable, intermediate PostScript files.")
93 "Dump memory and time information for each file.")
95 "Dump timing information (system-dependent).")
97 "Dump output signatures of each system. Used for
100 "Pad left edge of the output EPS bounding box by
101 given amount (in mm).")
103 "Load fonts via Ghostscript.")
104 (gs-load-lily-fonts #f
105 "Load only LilyPond fonts via Ghostscript.")
107 "Run LilyPond from a GUI and redirect stderr to
111 (include-book-title-preview #t
112 "Include book titles in preview images.")
113 (include-eps-fonts #t
114 "Include fonts in separate-system EPS files.")
116 "Include file for global settings, included before the score is processed.")
118 "Process in parallel, using the given number of
121 "If string FOO is given as argument, redirect
122 output to log file `FOO.log'.")
123 (midi-extension ,(if (eq? PLATFORM 'windows)
126 "Set the default file extension for MIDI output
127 file to given string.")
128 (music-strings-to-paths #f
129 "Convert text strings to paths when glyphs belong
132 "Make \\relative mode for simultaneous music work
133 similar to chord syntax.")
135 "Add point & click links to PDF output.")
137 "Set default paper size.")
138 (pixmap-format "png16m"
139 "Set GhostScript's output format for pixel images.")
141 "Create preview images also.")
143 "Print pages in the normal way.")
144 (protected-scheme-parsing #t
145 "Continue when errors in inline scheme are caught
146 in the parser. If #f, halt on errors and print
148 (profile-property-accesses #f
149 "Keep statistics of get_property() calls.")
151 "Set resolution for generating PNG pixmaps to
152 given value (in dpi).")
154 "Specify name of a file which contains a list of
155 input files to be processed.")
156 (relative-includes #f
157 "When processing an \\include command, look for
158 the included file relative to the current file
159 (instead of the root file)")
161 "Run in safer mode.")
162 (separate-log-files #f
163 "For input files `FILE1.ly', `FILE2.ly', ...
164 output log data to files `FILE1.log',
166 (show-available-fonts #f
167 "List available font names.")
168 (strict-infinity-checking #f
169 "Force a crash on encountering Inf and NaN
170 floating point exceptions.")
172 "Don't use directories from input files while
173 constructing output file names.")
175 "Use woff font files in SVG backend.")
176 (trace-memory-frequency #f
177 "Record Scheme cell usage this many times per
178 second. Dump results to `FILE.stacks' and
180 (trace-scheme-coverage #f
181 "Record coverage of Scheme files in `FILE.cov'.")
182 (verbose ,(ly:verbose-output?)
183 "Verbose output, i.e. loglevel at least DEBUG (read-only).")
185 "Change all warning and programming_error
186 messages into errors.")
189 ;; Need to do this in the beginning. Other parts of the Scheme
190 ;; initialization depend on these options.
192 (for-each (lambda (x)
193 (ly:add-option (car x) (cadr x) (caddr x)))
194 scheme-options-definitions)
196 (for-each (lambda (x)
197 (ly:set-option (car x) (cdr x)))
198 (eval-string (ly:command-line-options)))
202 (if (defined? 'set-debug-cell-accesses!)
203 (set-debug-cell-accesses! #f))
205 ;;(set-debug-cell-accesses! 1000)
207 (use-modules (ice-9 regex)
220 (define-public _ gettext)
221 ;;; There are new modules defined in Guile V2.0 which we need to use.
223 ;; Modules and scheme files loaded by lily.scm use currying
224 ;; in Guile V2 this needs a module which is not present in Guile V1.8
229 (ly:debug (_ "Using (ice-9 curried-definitions) module\n"))
230 (use-modules (ice-9 curried-definitions)))
232 (ly:debug (_ "Guile 1.8\n"))))
234 ;; TODO add in modules for V1.8.7 deprecated in V2.0 and integrated
235 ;; into Guile base code, like (ice-9 syncase).
238 (define-public fancy-format
241 (define-public (ergonomic-simple-format dest . rest)
242 "Like ice-9's @code{format}, but without the memory consumption."
244 (apply simple-format (cons #f (cons dest rest)))
245 (apply simple-format (cons dest rest))))
248 ergonomic-simple-format)
251 (define-public (myd k v)
258 (define-public (print . args)
259 (apply format (cons (current-output-port) args)))
262 ;;; General settings.
264 ;;; Debugging evaluator is slower. This should have a more sensible
267 (if (or (ly:get-option 'verbose)
268 (ly:get-option 'trace-memory-frequency)
269 (ly:get-option 'trace-scheme-coverage))
271 (ly:set-option 'protected-scheme-parsing #f)
272 (debug-enable 'backtrace)
273 (read-enable 'positions)))
275 (if (ly:get-option 'trace-scheme-coverage)
278 (define-public parser #f)
280 (define music-string-to-path-backends
283 (if (memq (ly:get-option 'backend) music-string-to-path-backends)
284 (ly:set-option 'music-strings-to-paths #t))
287 (define-public (ly:load x)
288 (let* ((file-name (%search-load-path x)))
289 (ly:debug "[~A" file-name)
291 (ly:error (_ "cannot find: ~A") x))
292 (primitive-load-path file-name) ;; to support Guile V2 autocompile
293 ;; TODO: Any chance to use ly:debug here? Need to extend it to prevent
294 ;; a newline in this case
295 (if (ly:get-option 'verbose)
296 (ly:progress "]\n"))))
299 (let ((platform (string-tokenize
300 (vector-ref (uname) 0) char-set:letter+digit)))
301 (if (null? (cdr platform)) #f
302 (member (string-downcase (cadr platform)) '("95" "98" "me")))))
305 (if (string-index x #\\)
307 (string-regexp-substitute
309 (string-regexp-substitute "\\\\" "/" x))))
311 (define-public (ly-getcwd)
312 (if (eq? PLATFORM 'windows)
316 (define-public (is-absolute? file-name)
317 (let ((file-name-length (string-length file-name)))
318 (if (= file-name-length 0)
320 (or (eq? (string-ref file-name 0) #\/)
321 (and (eq? PLATFORM 'windows)
322 (> file-name-length 2)
323 (eq? (string-ref file-name 1) #\:)
324 (eq? (string-ref file-name 2) #\/))))))
326 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
327 ;;; If necessary, emulate Guile V2 module_export_all! for Guile V1.8.n
330 (define (module-export-all! mod)
331 (define (fresh-interface!)
332 (let ((iface (make-module)))
333 (set-module-name! iface (module-name mod))
334 ;; for guile 2: (set-module-version! iface (module-version mod))
335 (set-module-kind! iface 'interface)
336 (set-module-public-interface! mod iface)
338 (let ((iface (or (module-public-interface mod)
339 (fresh-interface!))))
340 (set-module-obarray! iface (module-obarray mod))))))
342 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
343 (define (type-check-list location signature arguments)
344 "Typecheck a list of arguments against a list of type predicates.
345 Print a message at LOCATION if any predicate failed."
346 (define (recursion-helper signature arguments count)
347 (define (helper pred? arg count)
348 (if (not (pred? arg))
353 #f (_ "wrong type for argument ~a. Expecting ~a, found ~s")
354 count (type-name pred?) arg))
358 (if (null? signature)
360 (and (helper (car signature) (car arguments) count)
361 (recursion-helper (cdr signature) (cdr arguments) (1+ count)))))
362 (recursion-helper signature arguments 1))
365 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
366 ;; Safe definitions utility
371 (define-macro (define-safe-public arglist . body)
372 "Define a variable, export it, and mark it as safe, i.e. usable in
373 LilyPond safe mode. The syntax is the same as `define*-public'."
374 (define (get-symbol arg)
376 (get-symbol (car arg))
379 (let ((safe-symbol (get-symbol arglist)))
381 (define*-public ,arglist
383 (set! safe-objects (cons (cons ',safe-symbol ,safe-symbol)
387 (define-safe-public (lilypond-version)
389 (map (lambda (x) (if (symbol? x)
395 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
398 (ly:set-default-scale (ly:make-scale #(0 1 2 5/2 7/2 9/2 11/2)))
400 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
403 (define init-scheme-files
406 "define-event-classes.scm"
407 "define-music-callbacks.scm"
408 "define-music-types.scm"
409 "define-note-names.scm"
412 "chord-ignatzek-names.scm"
414 "chord-generic-names.scm"
417 "modal-transforms.scm"
418 "music-functions.scm"
421 "define-music-properties.scm"
422 "time-signature-settings.scm"
425 "parser-ly-from-scheme.scm"
426 "ly-syntax-constructors.scm"
428 "define-context-properties.scm"
429 ;; guile 1.9 wants markups defined before referenced
430 "define-markup-commands.scm"
433 "translation-functions.scm"
446 "define-woodwind-diagrams.scm"
447 "display-woodwind-diagrams.scm"
448 "predefined-fretboards.scm"
449 "define-grob-properties.scm"
451 "define-grob-interfaces.scm"
452 "define-stencil-commands.scm"
456 "backend-library.scm"
459 ;; must be after everything has been defined
462 (for-each ly:load init-scheme-files)
464 (define-public r5rs-primary-predicates
465 `((,boolean? . "boolean")
466 (,char? . "character")
467 (,number? . "number")
470 (,procedure? . "procedure")
471 (,string? . "string")
472 (,symbol? . "symbol")
473 (,vector? . "vector")))
475 (define-public r5rs-secondary-predicates
476 `((,char-alphabetic? . "alphabetic character")
477 (,char-lower-case? . "lower-case character")
478 (,char-numeric? . "numeric character")
479 (,char-upper-case? . "upper-case character")
480 (,char-whitespace? . "whitespace character")
482 (,complex? . "complex number")
483 (,even? . "even number")
484 (,exact? . "exact number")
485 (,inexact? . "inexact number")
486 (,integer? . "integer")
487 (,negative? . "negative number")
488 (,odd? . "odd number")
489 (,positive? . "positive number")
490 (,rational? . "rational number")
491 (,real? . "real number")
497 (,input-port? . "input port")
498 (,output-port? . "output port")
500 ;; would this ever be used?
501 (,eof-object? . "end-of-file object")
504 (define-public guile-predicates
505 `((,hash-table? . "hash table")
508 (define-public lilypond-scheme-predicates
509 `((,boolean-or-symbol? . "boolean or symbol")
511 (,cheap-list? . "list")
512 (,grob-list? . "list of grobs")
513 ;; this is built on cheap-list
514 (,list-or-symbol? . "list or symbol")
515 (,markup? . "markup")
516 (,markup-command-list? . "markup command list")
517 (,markup-list? . "markup list")
518 (,moment-pair? . "pair of moment objects")
519 (,number-or-grob? . "number or grob")
520 (,number-or-pair? . "number or pair")
521 (,number-or-string? . "number or string")
522 (,number-pair? . "pair of numbers")
523 (,rhythmic-location? . "rhythmic location")
524 (,scheme? . "any type")
525 (,string-or-pair? . "string or pair")
526 (,string-or-symbol? . "string or symbol")
529 (define-public lilypond-exported-predicates
531 (,ly:context? . "context")
532 (,ly:dimension? . "dimension, in staff space")
533 (,ly:dir? . "direction")
534 (,ly:dispatcher? . "dispatcher")
535 (,ly:duration? . "duration")
536 (,ly:font-metric? . "font metric")
537 (,ly:grob? . "graphical (layout) object")
538 (,ly:grob-array? . "array of grobs")
539 (,ly:input-location? . "input location")
541 (,ly:iterator? . "iterator")
542 (,ly:lily-lexer? . "lily-lexer")
543 (,ly:lily-parser? . "lily-parser")
544 (,ly:listener? . "listener")
545 (,ly:moment? . "moment")
546 (,ly:music? . "music")
547 (,ly:music-function? . "music function")
548 (,ly:music-list? . "list of music objects")
549 (,ly:music-output? . "music output")
550 (,ly:otf-font? . "OpenType font")
551 (,ly:output-def? . "output definition")
552 (,ly:page-marker? . "page marker")
553 (,ly:pango-font? . "pango font")
554 (,ly:paper-book? . "paper book")
555 (,ly:paper-system? . "paper-system Prob")
556 (,ly:pitch? . "pitch")
557 (,ly:prob? . "property object")
558 (,ly:score? . "score")
559 (,ly:simple-closure? . "simple closure")
560 (,ly:skyline? . "skyline")
561 (,ly:skyline-pair? . "pair of skylines")
562 (,ly:source-file? . "source file")
563 (,ly:spanner? . "spanner")
564 (,ly:stencil? . "stencil")
565 (,ly:stream-event? . "stream event")
566 (,ly:translator? . "translator")
567 (,ly:translator-group? . "translator group")
571 (set! type-p-name-alist
572 (append r5rs-primary-predicates
573 r5rs-secondary-predicates
575 lilypond-scheme-predicates
576 lilypond-exported-predicates))
579 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
582 (define (profile-measurements)
585 (list (- (+ (tms:cutime t)
587 (assoc-get 'gc-time-taken stats))
588 (assoc-get 'total-cells-allocated stats 0))))
590 (define (dump-profile base last this)
591 (let* ((outname (format #f "~a.profile" (dir-basename base ".ly")))
592 (diff (map (lambda (y) (apply - y)) (zip this last))))
593 (ly:progress "\nWriting timing to ~a..." outname)
594 (format (open-file outname "w")
595 "time: ~a\ncells: ~a\n"
596 (if (ly:get-option 'dump-cpu-profile)
601 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
602 ;; debug memory leaks
607 (define gc-protect-stat-count
610 (define-public (dump-live-object-stats outfile)
611 (for-each (lambda (x)
612 (format outfile "~a: ~a\n" (car x) (cdr x)))
613 (sort (gc-live-object-stats)
615 (string<? (car x) (car y))))))
617 (define-public (dump-gc-protects)
618 (set! gc-protect-stat-count (1+ gc-protect-stat-count))
619 (let* ((protects (sort (hash-table->alist (ly:protects))
621 (< (object-address (car a))
622 (object-address (car b))))))
623 (out-file-name (string-append
624 "gcstat-" (number->string gc-protect-stat-count)
626 (outfile (open-file out-file-name "w")))
628 (format #t "Dumping GC statistics ~a...\n" out-file-name)
629 (for-each (lambda (y)
632 (format outfile "~a (~a) = ~a\n" (object-address x) c x)))
635 (not (symbol? (car x))))
637 (format outfile "\nprotected symbols: ~a\n"
638 (apply + (map (lambda (obj-count)
639 (if (symbol? (car obj-count))
644 ;; (display (ly:smob-protects))
646 (if (defined? 'gc-live-object-stats)
648 (display "Live object statistics: GC'ing\n")
652 (display "Asserting dead objects\n")
653 (ly:set-option 'debug-gc-assert-parsed-dead #t)
655 (ly:set-option 'debug-gc-assert-parsed-dead #f)
656 (set! stats (gc-live-object-stats))
657 (display "Dumping live object statistics.\n")
658 (dump-live-object-stats outfile)))
660 (let* ((stats (gc-stats)))
661 (for-each (lambda (sym)
662 (format outfile "~a ~a ~a\n"
663 gc-protect-stat-count
665 (assoc-get sym stats "?")))
666 '(protected-objects bytes-malloced cell-heap-size)))
668 (close-port outfile)))
670 (define (check-memory)
671 "Read `/proc/self' to check up on memory use."
672 (define (gulp-file name)
673 (let* ((file (open-input-file name))
674 (text (read-delimited "" file)))
678 (let* ((stat (gulp-file "/proc/self/status"))
679 (lines (string-split stat #\newline))
680 (interesting (filter identity
683 (string-match "^VmData:[ \t]*([0-9]*) kB" l))
685 (mem (string->number (match:substring (car interesting) 1))))
686 (format #t "VMDATA: ~a\n" mem)
689 (begin (dump-gc-protects)
692 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
694 (define (multi-fork count)
695 "Split this process into COUNT helpers. Returns either a list of
696 PIDs or the number of the process."
697 (define (helper count acc)
699 (let* ((pid (primitive-fork)))
702 (helper (1- count) (cons pid acc))))
707 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
709 (define* (ly:exit status #:optional (silently #f))
710 "Exit function for lilypond"
713 ((0) (ly:success (_ "Compilation successfully completed")))
714 ((1) (ly:warning (_ "Compilation completed with warnings or errors")))
715 (else (ly:message ""))))
718 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
720 (define-public (lilypond-main files)
721 "Entry point for LilyPond."
722 (eval-string (ly:command-line-code))
723 (if (ly:get-option 'help)
724 (begin (ly:option-usage)
726 (if (ly:get-option 'show-available-fonts)
727 (begin (ly:font-config-display-fonts)
729 (if (ly:get-option 'gui)
734 (if (ly:get-option 'read-file-list)
737 (> (string-length s) 0))
740 (string-split (ly:gulp-file f) #\nl))
742 (if (and (number? (ly:get-option 'job-count))
743 (>= (length files) (ly:get-option 'job-count)))
744 (let* ((count (ly:get-option 'job-count))
745 (split-todo (split-list files count))
746 (joblist (multi-fork count))
748 (if (not (string-or-symbol? (ly:get-option 'log-file)))
749 (ly:set-option 'log-file "lilypond-multi-run"))
750 (if (number? joblist)
751 (begin (ly:set-option
752 'log-file (format #f "~a-~a"
753 (ly:get-option 'log-file) joblist))
754 (set! files (vector-ref split-todo joblist)))
755 (begin (ly:progress "\nForking into jobs: ~a\n" joblist)
758 (let* ((stat (cdr (waitpid pid))))
761 (acons (list-element-index joblist pid)
768 (logfile (format #f "~a-~a.log"
769 (ly:get-option 'log-file) job))
770 (log (ly:gulp-file logfile))
771 (len (string-length log))
772 (tail (substring log (max 0 (- len 1024)))))
773 (if (status:term-sig state)
776 (format #f (_ "job ~a terminated with signal: ~a")
777 job (status:term-sig state)))
779 (_ "logfile ~a (exit ~a):\n~a")
780 logfile (status:exit-val state) tail))))
783 (ly:error "Children ~a exited with errors."
785 ;; must overwrite individual entries
786 (if (ly:get-option 'dump-profile)
787 (dump-profile "lily-run-total"
788 '(0 0) (profile-measurements)))
793 (if (string-or-symbol? (ly:get-option 'log-file))
794 (ly:stderr-redirect (format #f "~a.log" (ly:get-option 'log-file)) "w"))
795 (let ((failed (lilypond-all files)))
796 (if (ly:get-option 'trace-scheme-coverage)
798 (coverage:show-all (lambda (f)
799 (string-contains f "lilypond")))))
801 (begin (ly:error (_ "failed files: ~S") (string-join failed))
807 (define-public (lilypond-all files)
809 (separate-logs (ly:get-option 'separate-log-files))
812 (open-file (if (string-or-symbol? (ly:get-option 'log-file))
813 (format #f "~a.log" (ly:get-option 'log-file))
814 "/dev/stderr") "a") #f))
815 (do-measurements (ly:get-option 'dump-profile))
816 (handler (lambda (key failed-file)
817 (set! failed (append (list failed-file) failed)))))
821 (let* ((start-measurements (if do-measurements
822 (profile-measurements)
824 (base (dir-basename x ".ly"))
825 (all-settings (ly:all-options)))
827 (ly:stderr-redirect (format #f "~a.log" base) "w"))
829 (format ping-log "Processing ~a\n" base))
830 (if (ly:get-option 'trace-memory-frequency)
831 (mtrace:start-trace (ly:get-option 'trace-memory-frequency)))
832 (lilypond-file handler x)
833 (if start-measurements
834 (dump-profile x start-measurements (profile-measurements)))
835 (if (ly:get-option 'trace-memory-frequency)
836 (begin (mtrace:stop-trace)
837 (mtrace:dump-results base)))
838 (for-each (lambda (s)
839 (ly:set-option (car s) (cdr s)))
841 (ly:set-option 'debug-gc-assert-parsed-dead #t)
843 (ly:set-option 'debug-gc-assert-parsed-dead #f)
844 (if (ly:get-option 'debug-gc)
846 (ly:reset-all-fonts))))
849 ;; Ensure a notice re failed files is written to aggregate logfile.
851 (format ping-log "Failed files: ~a\n" failed))
852 (if (ly:get-option 'dump-profile)
853 (dump-profile "lily-run-total" '(0 0) (profile-measurements)))
856 (define (lilypond-file handler file-name)
857 (catch 'ly-file-failed
858 (lambda () (ly:parse-file file-name))
859 (lambda (x . args) (handler x file-name))))
861 (use-modules (scm editor))
863 (define-public (gui-main files)
865 (gui-no-files-handler))
866 (if (not (string? (ly:get-option 'log-file)))
867 (let* ((base (dir-basename (car files) ".ly"))
868 (log-name (string-append base ".log")))
869 (if (not (ly:get-option 'gui))
870 (ly:message (_ "Redirecting output to ~a...") log-name))
871 (ly:stderr-redirect log-name "w")
872 (ly:message "# -*-compilation-*-"))
873 (let ((failed (lilypond-all files)))
877 (ly:stderr-redirect "foo" "r")
878 (system (get-editor-command log-name 0 0 0))
879 (ly:error (_ "failed files: ~S") (string-join failed))
884 (define (gui-no-files-handler)
885 (let* ((ly (string-append (ly:effective-prefix) "/ly/"))
886 ;; FIXME: soft-code, localize
887 (welcome-ly (string-append ly "Welcome_to_LilyPond.ly"))
888 (cmd (get-editor-command welcome-ly 0 0 0)))
889 (ly:message (_ "Invoking `~a'...\n") cmd)