X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Flily.scm;h=8344f80a8efa6ef8f382163c42e950c3d3e6db1c;hb=5c14a087ca6cbd665fd631452b7b1283ba0387c3;hp=48d911751aff6fbda380a2a6f4c735cc5e960704;hpb=c8f35b49edadbef240fe3ad4931a6c9f526cc6d6;p=lilypond.git diff --git a/scm/lily.scm b/scm/lily.scm index 48d911751a..8344f80a8e 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -2,7 +2,7 @@ ;;;; ;;;; source file of the GNU LilyPond music typesetter ;;;; -;;;; (c) 1998--2006 Jan Nieuwenhuizen +;;;; (c) 1998--2007 Jan Nieuwenhuizen ;;;; Han-Wen Nienhuys ;; Internationalisation: (_i "to be translated") gets an entry in the @@ -17,7 +17,10 @@ (read-enable 'positions) (debug-enable 'debug) - +(define-public PLATFORM + (string->symbol + (string-downcase + (car (string-tokenize (utsname:sysname (uname))))))) (define scheme-options-definitions `( @@ -31,6 +34,7 @@ (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.") @@ -41,18 +45,25 @@ ensure that all refs to parsed objects are dead. This is an internal option, an (debug-skylines #f "debug skylines") (delete-intermediate-files #f "delete unusable PostScript files") - (dump-profile #f "dump timing information for each file") + (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") + (midi-extension ,(if (eq? PLATFORM 'windows) + "mid" + "midi") + "set the default file extension for MIDI") (old-relative #f "relative for simultaneous music works @@ -72,6 +83,7 @@ on errors, and print a stack trace.") (safe #f "Run safely") (strict-infinity-checking #f "If yes, crash on encountering Inf/NaN.") + (strip-output-dir #t "If yes, strip directories from input files.") (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") @@ -104,6 +116,7 @@ on errors, and print a stack trace.") (use-modules (ice-9 regex) (ice-9 safe) + (ice-9 format) (ice-9 rdelim) (ice-9 optargs) (oop goops) @@ -114,6 +127,15 @@ on errors, and print a stack trace.") (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 ", ") @@ -128,7 +150,7 @@ on errors, and print a stack trace.") ;;; have a more sensible default. (if (or (ly:get-option 'verbose) - (ly:get-option 'trace-memory-frequencency) + (ly:get-option 'trace-memory-frequency) (ly:get-option 'trace-scheme-coverage) ) (begin @@ -146,14 +168,6 @@ on errors, and print a stack trace.") (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) @@ -175,22 +189,6 @@ on errors, and print a stack trace.") (if (ly:get-option 'verbose) (ly:progress "]")))) -;; Cygwin -;; #(CYGWIN_NT-5.1 Hostname 1.5.12(0.116/4/2) 2004-11-10 08:34 i686) -;; -;; Debian -;; #(Linux hostname 2.4.27-1-686 #1 Fri Sep 3 06:28:00 UTC 2004 i686) -;; -;; Mingw -;; #(Windows XP HOSTNAME build 2600 5.01 Service Pack 1 i686) -;; - -;; ugh, code dup. -(define-public PLATFORM - (string->symbol - (string-downcase - (car (string-tokenize (vector-ref (uname) 0) char-set:letter))))) - (define-public DOS (let ((platform (string-tokenize (vector-ref (uname) 0) char-set:letter+digit))) @@ -280,6 +278,14 @@ The syntax is the same as `define*-public'." 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 @@ -324,8 +330,11 @@ The syntax is the same as `define*-public'." "font.scm" "encoding.scm" + "flag-styles.scm" "fret-diagrams.scm" - "define-markup-commands.scm" + "harp-pedals.scm" + "predefined-fretboards.scm" + "define-markup-commands.scm" "define-grob-properties.scm" "define-grobs.scm" "define-grob-interfaces.scm" @@ -398,13 +407,15 @@ The syntax is the same as `define*-public'." (define (dump-profile base last this) (let* - ((outname (format "~a.profile" (basename base ".ly"))) + ((outname (format "~a.profile" (dir-basename base ".ly"))) (diff (map (lambda (y) (apply - y)) (zip this last)))) (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) ))) @@ -452,9 +463,10 @@ The syntax is the same as `define*-public'." 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) @@ -530,6 +542,8 @@ The syntax is the same as `define*-public'." (define (multi-fork count) + "Split this process in COUNT helpers. Returns either a list of pids, +or the number of the process." (define (helper count acc) (if (> count 0) (let* @@ -544,7 +558,6 @@ The syntax is the same as `define*-public'." (define-public (lilypond-main files) "Entry point for LilyPond." - (eval-string (ly:command-line-code)) (if (ly:get-option 'help) @@ -578,7 +591,6 @@ The syntax is the same as `define*-public'." (if (and (number? (ly:get-option 'job-count)) (>= (length files) (ly:get-option 'job-count))) - (let* ((count (ly:get-option 'job-count)) (split-todo (split-list files count)) @@ -590,8 +602,9 @@ The syntax is the same as `define*-public'." (if (number? joblist) (begin - (ly:set-option 'log-file (format "~a-~a" - (ly:get-option 'log-file) joblist)) + (ly:set-option + 'log-file (format "~a-~a" + (ly:get-option 'log-file) joblist)) (set! files (vector-ref split-todo joblist))) (begin @@ -601,25 +614,29 @@ The syntax is the same as `define*-public'." (let* ((stat (cdr (waitpid pid)))) (if (not (= stat 0)) - (set! errors (acons (list-element-index joblist pid) stat errors))))) + (set! errors + (acons (list-element-index joblist pid) + stat errors))))) joblist) (for-each (lambda (x) (let* ((job (car x)) (state (cdr x)) - (logfile (format "~a-~a.log" + (logfile (format "~a-~a.log" (ly:get-option 'log-file) job)) (log (ly:gulp-file logfile)) (len (string-length log)) (tail (substring log (max 0 (- len 1024))))) (if (status:term-sig state) - (ly:message "\n\n~a\n" - (format (_ "job ~a terminated with signal: ~a") - job - (status:term-sig state))) - (ly:message (_ "logfile ~a (exit ~a):\n~a") logfile (status:exit-val state) tail)))) + (ly:message + "\n\n~a\n" + (format (_ "job ~a terminated with signal: ~a") + job (status:term-sig state))) + (ly:message + (_ "logfile ~a (exit ~a):\n~a") + logfile (status:exit-val state) tail)))) errors) @@ -631,18 +648,15 @@ The syntax is the same as `define*-public'." (dump-profile "lily-run-total" '(0 0) (profile-measurements))) (exit (if (null? errors) 0 1)))))) - (if (string-or-symbol? (ly:get-option 'log-file)) (ly:stderr-redirect (format "~a.log" (ly:get-option 'log-file)) "w")) - (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 @@ -656,6 +670,11 @@ The syntax is the same as `define*-public'." (define-public (lilypond-all files) (let* ((failed '()) (separate-logs (ly:get-option 'separate-log-files)) + (ping-log + (if separate-logs + (open-file (if (string-or-symbol? (ly:get-option 'log-file)) + (format "~a.log" (ly:get-option 'log-file)) + "/dev/tty") "a") #f)) (do-measurements (ly:get-option 'dump-profile)) (handler (lambda (key failed-file) (set! failed (append (list failed-file) failed))))) @@ -667,11 +686,14 @@ The syntax is the same as `define*-public'." ((start-measurements (if do-measurements (profile-measurements) #f)) - (base (basename x ".ly")) + (base (dir-basename x ".ly")) (all-settings (ly:all-options))) (if separate-logs (ly:stderr-redirect (format "~a.log" base) "w")) + (if ping-log + (format ping-log "Procesing ~a\n" base)) + (if (ly:get-option 'trace-memory-frequency) (mtrace:start-trace (ly:get-option 'trace-memory-frequency))) @@ -703,12 +725,9 @@ The syntax is the same as `define*-public'." files) ;; we want the failed-files notice in the aggregrate logfile. - (if (ly:get-option 'separate-logs) - (ly:stderr-redirect - (if (string-or-symbol? (ly:get-option 'log-file)) - (format "~a.log" (ly:get-option 'log-file)) - "/dev/tty") "a")) - + (if ping-log + (format ping-log "Failed files: ~a\n" failed)) + (if (ly:get-option 'dump-profile) (dump-profile "lily-run-total" '(0 0) (profile-measurements))) @@ -726,7 +745,7 @@ The syntax is the same as `define*-public'." (gui-no-files-handler)) (if (not (string? (ly:get-option 'log-file))) - (let* ((base (basename (car files) ".ly")) + (let* ((base (dir-basename (car files) ".ly")) (log-name (string-append base ".log"))) (if (not (ly:get-option 'gui)) (ly:message (_ "Redirecting output to ~a...") log-name))