out_file_name.ext_ = "";
out_file_name.root_ = "";
- out_file_name.dir_ = "";
-
+ if (ly_get_option (ly_symbol2scm ("gui")) != SCM_BOOL_T
+ && ly_get_option (ly_symbol2scm ("strip-output-dir")) == SCM_BOOL_T) {
+ out_file_name.dir_ = "";
+ }
+
/* When running from gui, generate output in .ly source directory. */
- if (output_name_global.empty ()
- && ly_get_option (ly_symbol2scm ("gui")) == SCM_BOOL_T)
- {
- File_name f (file);
- f.base_ = "";
- f.ext_ = "";
- output_name_global = f.to_string ();
- }
-
- if (!output_name_global.empty ())
+ string output_name = output_name_global;
+ if (!output_name.empty ())
{
-
/* Interpret --output=DIR to mean --output=DIR/BASE. */
string dir;
- if (is_dir (output_name_global))
+ if (is_dir (output_name))
{
- dir = output_name_global;
- output_name_global = "";
+ dir = output_name;
+ output_name = "";
}
else
{
- File_name out (output_name_global);
+ File_name out (output_name);
if (is_dir (out.dir_part ()))
{
dir = out.dir_part ();
chdir (dir.c_str ());
}
else
- out_file_name = File_name (output_name_global);
+ out_file_name = File_name (output_name);
}
string init;
init = "init.ly";
string out_file = out_file_name.to_string ();
-
if (init.length () && global_path.find (init).empty ())
{
warning (_f ("cannot find init file: `%s'", init));
try_load_text_metrics (out_name);
// TODO: use $parser
- lexer_->set_identifier (ly_symbol2scm ("parser"),
- self_scm ());
+ lexer_->set_identifier (ly_symbol2scm ("parser"), self_scm ());
output_basename_ = out_name;
lexer_->main_input_name_ = name;
(define-public (postscript->pdf paper-width paper-height name)
(let* ((pdf-name (string-append
- (basename (basename name ".ps") ".eps")
+ (dir-basename name ".ps" ".eps")
".pdf"))
(is-eps (string-match "\\.eps$" name))
(paper-size-string (if is-eps
(use-modules (scm ps-to-png))
(define-public (postscript->png resolution paper-width paper-height name)
- ;; Do not try to guess the name of the png file,
- ;; GS produces PNG files like BASE-page%d.png.
- ;;(ly:message (_ "Converting to `~a'...")
- ;; (string-append (basename name ".ps") "-page1.png" )))
(let* ((verbose (ly:get-option 'verbose))
(rename-page-1 #f))
+
+ ;; Do not try to guess the name of the png file,
+ ;; GS produces PNG files like BASE-page%d.png.
(ly:message (_ "Converting to ~a...") "PNG")
(make-ps-images name
#:resolution resolution
(output-scale (ly:output-def-lookup defs 'output-scale)))
(postscript->pdf (* paper-width output-scale (/ (ly:bp 1)))
(* paper-height output-scale (/ (ly:bp 1)))
- (string-append (basename name ".tex") ".ps"))))
+ (string-append (dir-basename name ".tex") ".ps"))))
(define-public (convert-to-png book name)
(let* ((defs (ly:paper-book-paper book))
(* paper-width output-scale (/ (ly:bp 1)))
(* paper-height output-scale (/ (ly:bp 1)))
- (string-append (basename name ".tex") ".ps"))))
+ (string-append (dir-basename name ".tex") ".ps"))))
(define-public (convert-to-ps book name)
(let* ((paper (ly:paper-book-paper book))
(preview? (string-contains name ".preview"))
(papersizename (ly:output-def-lookup paper 'papersizename))
(landscape? (eq? #t (ly:output-def-lookup paper 'landscape)))
- (base (basename name ".tex"))
+ (base (dir-basename name ".tex"))
(ps-name (format "~a.ps" base ".ps"))
(cmd (string-append "dvips"
(if preview?
#f " *%.*\n?"
(ly:kpathsea-expand-variable "extra_mem_top")
'pre "" 'post)))
- (base (basename name ".tex"))
+ (base (dir-basename name ".tex"))
(cmd (format
#f "latex \\\\nonstopmode \\\\input '~a'" name)))
(string-append (ly:number->string (car c)) " "
(ly:number->string (cdr c))))
+(define-public (dir-basename file . rest)
+ "Strip suffixes in REST, but leave directory component for FILE."
+ (define (inverse-basename x y) (basename y x))
+ (simple-format #f "~a/~a" (dirname file)
+ (fold inverse-basename file rest)))
(define-public (write-me message x)
"Return X. Display MESSAGE and write X. Handy for debugging,
(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")
(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)
(define-public (lilypond-main files)
"Entry point for LilyPond."
-
(eval-string (ly:command-line-code))
(if (ly:get-option 'help)
((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
(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))
((string-contains format-str "jpeg") "jpeg")
(else
(ly:error "Unknown pixmap format ~a" pixmap-format))))
- (base (basename (re-sub "[.]e?ps" "" ps-name)))
+ (base (dir-basename ps-name ".ps" ".eps"))
(png1 (format "~a.~a" base extension))
(pngn (format "~a-page%d.~a" base extension))
(page-count (ps-page-count ps-name))
return self.checksum
def basename (self):
- if FILENAME in self.option_dict:
- return self.option_dict[FILENAME]
-
cs = self.get_checksum ()
# TODO: use xx/xxxxx directory layout.