;;;;
;;;; source file of the GNU LilyPond music typesetter
;;;;
-;;;; (c) 1998--2006 Jan Nieuwenhuizen <janneke@gnu.org>
+;;;; (c) 1998--2007 Jan Nieuwenhuizen <janneke@gnu.org>
;;;; Han-Wen Nienhuys <hanwen@xs4all.nl>
;; Internationalisation: (_i "to be translated") gets an entry in the
(read-enable 'positions)
(debug-enable 'debug)
+(define scheme-options-definitions
+ `(
-(define (define-scheme-options)
- (for-each (lambda (x)
- (ly:add-option (car x) (cadr x) (caddr x)))
-
- `(
-
- ;; NAMING: either
+ ;; NAMING: either
- ;; - [subject-]object-object-verb +"ing"
- ;; - [subject-]-verb-object-object
+ ;; - [subject-]object-object-verb +"ing"
+ ;; - [subject-]-verb-object-object
- (anti-alias-factor 1 "render at higher resolution and scale down result\nto prevent jaggies in PNG")
- (check-internal-types #f "check every property assignment for types")
- (clip-systems #f "Generate cut-out snippets of a score")
- (debug-gc #f "dump memory debugging statistics")
- (debug-gc-assert-parsed-dead #f "for memory debugging:
+ (anti-alias-factor 1 "render at higher resolution and scale down result\nto prevent jaggies in PNG")
+ (backend ps "which backend to use by default; Options: eps, ps [default], scm, svg, tex, texstr)")
+ (check-internal-types #f "check every property assignment for types")
+ (clip-systems #f "Generate cut-out snippets of a score")
+ (datadir #f "LilyPond prefix for data files (Readonly).")
+ (debug-gc #f "dump memory debugging statistics")
+ (debug-gc-assert-parsed-dead #f "for memory debugging:
ensure that all refs to parsed objects are dead. This is an internal option, and is switched on automatically for -ddebug-gc.")
- (debug-lexer #f "debug the flex lexer")
- (debug-parser #f "debug the bison parser")
- (debug-skylines #f "debug skylines")
- (delete-intermediate-files #f
- "delete unusable PostScript files")
- (dump-profile #f "dump timing information for each file")
- (dump-signatures #f "dump output signatures of each system. Used for regression testing.")
-
- (eps-box-padding #f "Pad EPS bounding box left edge. Guarantee alignment between systems in LaTeX.")
- (gs-load-fonts #f
- "load fonts via Ghostscript.")
- (gui #f "running from gui; redirect stderr to log file")
-
- (include-book-title-preview #t "include book-titles in preview images.")
- (include-eps-fonts #t "Include fonts in separate-system EPS files.")
- (job-count #f "Process in parallel")
- (log-file #f "redirect output to log FILE.log")
-
- (old-relative #f
- "relative for simultaneous music works
+ (debug-lexer #f "debug the flex lexer")
+ (debug-page-breaking-scoring #f "dump scores for many different page breaking configurations")
+ (debug-parser #f "debug the bison parser")
+ (debug-property-callbacks #f "debug cyclic callback chains")
+ (debug-skylines #f "debug skylines")
+ (delete-intermediate-files #f
+ "delete unusable PostScript files")
+ (dump-profile #f "dump memory and time information for each file")
+ (dump-cpu-profile #f "dump timing information (system-dependent)")
+ (dump-signatures #f "dump output signatures of each system. Used for regression testing.")
+
+ (eps-box-padding #f "Pad EPS bounding box left edge. Guarantee alignment between systems in LaTeX.")
+ (gs-load-fonts #f
+ "load fonts via Ghostscript.")
+ (gs-load-lily-fonts #f
+ "load only lilypond fonts via Ghostscript.")
+ (gui #f "running from gui; redirect stderr to log file")
+ (help #f "show this help.")
+ (include-book-title-preview #t "include book-titles in preview images.")
+ (include-eps-fonts #t "Include fonts in separate-system EPS files.")
+ (job-count #f "Process in parallel")
+ (log-file #f "redirect output to log FILE.log")
+
+ (old-relative #f
+ "relative for simultaneous music works
similar to chord syntax")
- (point-and-click #t "use point & click")
- (paper-size "a4" "the default paper size")
- (pixmap-format "png16m" "GS format to use for pixel images")
- (protected-scheme-parsing #t "continue when finding errors in inline
+ (point-and-click #t "use point & click")
+ (paper-size "a4" "the default paper size")
+ (pixmap-format "png16m" "GS format to use for pixel images")
+ (preview #f "make a incipit image. ")
+ (print-pages #t "print pages normally. ")
+ (protected-scheme-parsing #t "continue when finding errors in inline
scheme are caught in the parser. If off, halt
on errors, and print a stack trace.")
- (profile-property-accesses #f "keep statistics of get_property() calls.")
-
- (resolution 101 "resolution for generating PNG bitmaps")
- (read-file-list #f "Read files to be processed from command line arguments")
-
- (safe #f "Run safely")
- (strict-infinity-checking #f "If yes, crash on encountering Inf/NaN.")
- (separate-log-files #f "Output to FILE.log per file.")
- (trace-memory-frequency #f "Record Scheme cell usage this many times per second, and dump to file.")
- (ttf-verbosity 0
- "how much verbosity for TTF font embedding?")
- (show-available-fonts #f
- "List font names available.")
- (verbose ,(ly:command-line-verbose?) "value for the --verbose flag")
- ))
-
- (map
- (lambda (x)
- (ly:set-option (car x) (cdr x)))
- (eval-string (ly:command-line-options))))
-
+ (profile-property-accesses #f "keep statistics of get_property() calls.")
+
+ (resolution 101 "resolution for generating PNG bitmaps")
+ (read-file-list #f "Read files to be processed from command line arguments")
+
+ (safe #f "Run safely")
+ (strict-infinity-checking #f "If yes, crash on encountering Inf/NaN.")
+ (separate-log-files #f "Output to FILE.log per file.")
+ (trace-memory-frequency #f "Record Scheme cell usage this many times per second, and dump to file.")
+ (trace-scheme-coverage #f "Record coverage of Scheme files")
+ (ttf-verbosity 0
+ "how much verbosity for TTF font embedding?")
+ (show-available-fonts #f
+ "List font names available.")
+ (verbose ,(ly:command-line-verbose?) "value for the --verbose flag")
+ ))
;; need to do this in the beginning. Other parts of the
;; Scheme init depend on these options.
;;
-(define-scheme-options)
-
+(for-each
+ (lambda (x)
+ (ly:add-option (car x) (cadr x) (caddr x)))
+ scheme-options-definitions)
+(for-each
+ (lambda (x)
+ (ly:set-option (car x) (cdr x)))
+ (eval-string (ly:command-line-options)))
(debug-set! stack 0)
(use-modules (ice-9 regex)
(ice-9 safe)
+ (ice-9 format)
(ice-9 rdelim)
(ice-9 optargs)
(oop goops)
(srfi srfi-14)
(scm clip-region)
(scm memory-trace)
+ (scm coverage)
)
+(define-public fancy-format format)
+(define-public (ergonomic-simple-format dest . rest)
+ "Like ice-9 format, but without the memory consumption."
+
+ (if (string? dest)
+ (apply simple-format (cons #f (cons dest rest)))
+ (apply simple-format (cons dest rest))))
+
+(define format ergonomic-simple-format)
;; my display
(define-public (myd k v) (display k) (display ": ") (display v) (display ", ")
;;; debugging evaluator is slower. This should
;;; have a more sensible default.
-(if (ly:get-option 'verbose)
+(if (or (ly:get-option 'verbose)
+ (ly:get-option 'trace-memory-frequencency)
+ (ly:get-option 'trace-scheme-coverage)
+ )
(begin
(ly:set-option 'protected-scheme-parsing #f)
(debug-enable 'debug)
(debug-enable 'backtrace)
(read-enable 'positions)))
+
+(if (ly:get-option 'trace-scheme-coverage)
+ (coverage:enable))
+
(define-public tex-backend?
- (member (ly:output-backend) '("texstr" "tex")))
+ (member (ly:get-option 'backend) '(texstr tex)))
(define-public parser #f)
-(define-public (lilypond-version)
- (string-join
- (map (lambda (x) (if (symbol? x)
- (symbol->string x)
- (number->string x)))
- (ly:version))
- "."))
-
;; TeX C++ code actually hooks into TEX_STRING_HASHLIMIT
(define-public TEX_STRING_HASHLIMIT 10000000)
safe-objects))
,safe-symbol)))
+(define-safe-public (lilypond-version)
+ (string-join
+ (map (lambda (x) (if (symbol? x)
+ (symbol->string x)
+ (number->string x)))
+ (ly:version))
+ "."))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; init pitch system
"safe-lily.scm"))
-
-
(for-each ly:load init-scheme-files)
(ly:progress "\nWriting timing to ~a..." outname)
(format (open-file outname "w")
"time: ~a\ncells: ~a\n"
- (car diff)
+ (if (ly:get-option 'dump-cpu-profile)
+ (car diff)
+ 0)
(cadr diff)
)))
outfile)
(format outfile "\nprotected symbols: ~a\n"
- (length (filter symbol? (map car protects))))
-
-
+ (apply + (map (lambda (obj-count) (if (symbol? (car obj-count))
+ (cdr obj-count)
+ 0))
+ protects)))
;; (display (ly:smob-protects))
(newline outfile)
(define-public (lilypond-main files)
"Entry point for LilyPond."
- (define (no-files-handler)
- (ly:usage)
- (exit 2))
(eval-string (ly:command-line-code))
+
+ (if (ly:get-option 'help)
+ (begin
+ (ly:option-usage)
+ (exit 0)))
+
+ (if (ly:get-option 'show-available-fonts)
+ (begin
+ (ly:font-config-display-fonts)
+ (exit 0)
+ ))
+
(if (ly:get-option 'gui)
(gui-main files))
(if (null? files)
- (no-files-handler))
+ (begin
+ (ly:usage)
+ (exit 2)))
(if (ly:get-option 'read-file-list)
(set! files
(let ((failed (lilypond-all files)))
+ (if (ly:get-option 'trace-scheme-coverage)
+ (begin
+ (coverage:show-all (lambda (f) (string-contains f "lilypond"))
+ )))
+
+
(if (pair? failed)
(begin
(ly:error (_ "failed files: ~S") (string-join failed))
(exit 0)))))
(define-public (lilypond-all files)
-
-
- (if (ly:get-option 'show-available-fonts)
- (begin
- (ly:font-config-display-fonts)
- (exit 0)
- ))
-
(let* ((failed '())
(separate-logs (ly:get-option 'separate-log-files))
(do-measurements (ly:get-option 'dump-profile))