+
+
+;; debug mem leaks
+
+(define gc-protect-stat-count 0)
+(define-public (dump-gc-protects)
+ (set! gc-protect-stat-count (1+ gc-protect-stat-count) )
+ (let*
+ ((protects (sort
+ (hash-table->alist (ly:protects))
+ (lambda (a b)
+ (< (object-address (car a))
+ (object-address (car b))))))
+ (outfile (open-file (string-append
+ "gcstat-" (number->string gc-protect-stat-count)
+ ".scm"
+ ) "w"))
+ )
+
+ (display "DUMPING...\n")
+ (display
+ (filter
+ (lambda (x) (not (symbol? x)))
+ (map (lambda (y)
+ (let
+ ((x (car y))
+ (c (cdr y)))
+
+ (string-append
+ (string-join
+ (map object->string (list (object-address x) c x))
+ " ")
+ "\n")))
+ protects))
+ outfile)
+
+ ))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define-public (lilypond-main files)
+ "Entry point for Lilypond"
+ (let*
+ ((failed '())
+ (handler (lambda (key arg)
+ (set! failed (cons arg failed))))
+ )
+
+ (for-each
+ (lambda (fn)
+ (catch 'ly-file-failed
+ (lambda () (ly:parse-file fn))
+ handler))
+
+ files)
+
+ (if (pair? failed)
+ (begin
+ (display (string-append "\n *** Failed files: " (string-join failed) "\n" ))
+ (exit 1))
+ (exit 0))
+
+ ))
+
+