return SCM_UNSPECIFIED;
}
+LY_DEFINE (ly_success, "ly:success",
+ 1, 0, 1, (SCM str, SCM rest),
+ "A Scheme callable function to issue a success message @code{str}."
+ " The message is formatted with @code{format} and @code{rest}.")
+{
+ LY_ASSERT_TYPE (scm_is_string, str, 1);
+ str = scm_simple_format (SCM_BOOL_F, str, rest);
+ successful (ly_scm2string (str));
+ return SCM_UNSPECIFIED;
+
+}
LY_DEFINE (ly_warning, "ly:warning",
1, 0, 1, (SCM str, SCM rest),
"A Scheme callable function to issue the warning @code{str}."
LY_ASSERT_TYPE (scm_is_string, file_name, 1);
string m = "w";
+ FILE *stderrfile;
if (mode != SCM_UNDEFINED && scm_string_p (mode))
m = ly_scm2string (mode);
/* dup2 and (fileno (current-error-port)) do not work with mingw'c
gcc -mwindows. */
fflush (stderr);
- freopen (ly_scm2string (file_name).c_str (), m.c_str (), stderr);
+ stderrfile = freopen (ly_scm2string (file_name).c_str (), m.c_str (), stderr);
return SCM_UNSPECIFIED;
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(define* (ly:exit status #:optional (silently #f) )
+ "Exit function for lilypond"
+ (if (not silently)
+ (case status
+ ((0) (ly:success "Compilation successfully completed"))
+ ((1) (ly:warning "Compilation completed with warnings or errors"))
+ (else (ly:message "")))
+ )
+ (exit status)
+ )
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
(define-public (lilypond-main files)
"Entry point for LilyPond."
(eval-string (ly:command-line-code))
(if (ly:get-option 'help)
(begin (ly:option-usage)
- (exit 0)))
+ (ly:exit 0 #t )))
(if (ly:get-option 'show-available-fonts)
(begin (ly:font-config-display-fonts)
- (exit 0)))
+ (ly:exit 0 #t)))
(if (ly:get-option 'gui)
(gui-main files))
(if (null? files)
(begin (ly:usage)
- (exit 2)))
+ (ly:exit 2 #t)))
(if (ly:get-option 'read-file-list)
(set! files
(filter (lambda (s)
(if (ly:get-option 'dump-profile)
(dump-profile "lily-run-total"
'(0 0) (profile-measurements)))
- (exit (if (null? errors)
- 0
- 1))))))
+ (if (null? errors)
+ (ly:exit 0 #f)
+ (ly:exit 1 #f))))))
+
(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)))
(string-contains f "lilypond")))))
(if (pair? failed)
(begin (ly:error (_ "failed files: ~S") (string-join failed))
- (exit 1))
+ (ly:exit 1 #f))
(begin
- ;; HACK: be sure to exit with single newline
- (ly:message "")
- (exit 0)))))
+ (ly:exit 0 #f)))))
+
(define-public (lilypond-all files)
(let* ((failed '())
(ly:set-option 'debug-gc-assert-parsed-dead #f)
(if (ly:get-option 'debug-gc)
(dump-gc-protects)
- (ly:reset-all-fonts))))
+ (ly:reset-all-fonts))))
files)
;; we want the failed-files notice in the aggregrate logfile.
(ly:error (_ "failed files: ~S") (string-join failed))
;; not reached?
(exit 1))
- (exit 0)))))
+ (ly:exit 0 #f)))))
(define (gui-no-files-handler)
(let* ((ly (string-append (ly:effective-prefix) "/ly/"))
(cmd (get-editor-command welcome-ly 0 0 0)))
(ly:message (_ "Invoking `~a'...\n") cmd)
(system cmd)
- (exit 1)))
+ (ly:exit 1 #f)))