From 4eeca0046602a7083480496eee2fe5c3e185bdc3 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sat, 24 Jul 2004 12:13:09 +0000 Subject: [PATCH] * scripts/lilypond-latex.py (run_dvips): remove -bin everywhere. * lily/GNUmakefile (NAME): create lilypond, not lilypond-bin * scripts/lilypond-latex.py: move from lilypond.py * make/lilypond-vars.make: centralize LILYPOND_BOOK_FLAGS setting. (LILYPOND_BOOK_FLAGS): use -f tex for lilypond-book. * lily/paper-book.cc (post_processing): call convert-to-{dvi,ps,png,pdf} * lily/paper-book.cc (output): call output-preview-framework (post_processing): new function. Do PDF/PNG conversion. * scm/framework-ps.scm (convert-to-pdf): new function. Call ps2pdf. (output-preview-framework): new function. Generate a preview .ps --- ChangeLog | 9 + Documentation/topdocs/NEWS.texi | 5 + Documentation/user/GNUmakefile | 1 - Documentation/user/invoking.itexi | 230 ++++++++++----------- input/regression/GNUmakefile | 1 - input/template/GNUmakefile | 1 - input/test/GNUmakefile | 1 - lily/GNUmakefile | 2 +- lily/include/main.hh | 5 + lily/main.cc | 18 +- lily/paper-book.cc | 1 + make/lilypond-vars.make | 1 + scm/framework-ps.scm | 3 + scm/framework-tex.scm | 5 +- scripts/lilypond-book.py | 12 +- scripts/{lilypond.py => lilypond-latex.py} | 16 +- 16 files changed, 173 insertions(+), 138 deletions(-) rename scripts/{lilypond.py => lilypond-latex.py} (98%) diff --git a/ChangeLog b/ChangeLog index 6d57c41b9e..652f7c07a6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2004-07-24 Han-Wen Nienhuys + * scripts/lilypond-latex.py (run_dvips): remove -bin everywhere. + + * lily/GNUmakefile (NAME): create lilypond, not lilypond-bin + + * scripts/lilypond-latex.py: move from lilypond.py + + * make/lilypond-vars.make: centralize LILYPOND_BOOK_FLAGS setting. + (LILYPOND_BOOK_FLAGS): use -f tex for lilypond-book. + * scm/lily.scm (postscript->png): new function (postscript->pdf): new function diff --git a/Documentation/topdocs/NEWS.texi b/Documentation/topdocs/NEWS.texi index 580d94c99d..af1a26a572 100644 --- a/Documentation/topdocs/NEWS.texi +++ b/Documentation/topdocs/NEWS.texi @@ -8,6 +8,11 @@ @itemize @bullet +@item The LilyPond binary now supports output options +@code{--dvi} @code{--png} @code{--ps} @code{--pdf} and +@code{--preview}. The old wrapper script for La@TeX{} has been +renamed to @code{lilypond-latex}. + @item Support ambituses has been rewritten. The Ambitus object is now a grouping object, composed of @code{AmbitusLine}, @code{AmbitusAccidental} and @code{AmbitusNoteHead}. These objects may diff --git a/Documentation/user/GNUmakefile b/Documentation/user/GNUmakefile index 5a033da3b5..f06890b465 100644 --- a/Documentation/user/GNUmakefile +++ b/Documentation/user/GNUmakefile @@ -26,7 +26,6 @@ STEPMAKE_TEMPLATES=tex texinfo omf documentation OMF_FILES += $(outdir)/lilypond-internals.html.omf LOCALSTEPMAKE_TEMPLATES=lilypond ly -LILYPOND_BOOK_FLAGS = --process="lilypond-bin -I $(srcdir)/input/test -e '(ly:set-option (quote internal-type-checking) \#t)'" include $(depth)/make/stepmake.make diff --git a/Documentation/user/invoking.itexi b/Documentation/user/invoking.itexi index 92fe71fddb..4aef5cf1f6 100644 --- a/Documentation/user/invoking.itexi +++ b/Documentation/user/invoking.itexi @@ -13,121 +13,6 @@ This chapter details the technicalities of running LilyPond. * Editor support:: * Point and click:: @end menu - -@node Invoking lilypond -@section Invoking lilypond - -Nicely titled output is created through a separate program: -@file{@code{lilypond}} is a script that uses the LilyPond formatting -engine (which is in a separate program) and La@TeX{} to create a -nicely titled piece of sheet music, in PDF (Portable Document Format) -format. - -@example - @code{lilypond} [@var{option}]@dots{} @var{file}@dots{} -@end example - -To have @code{lilypond} read from stdin, use a dash @code{-} for -@var{file}. The program supports the following options. - -@cindex stdin, reading - -@table @code -@item -k,--keep - Keep the temporary directory with all output -files. The temporary directory is created in the current directory as @code{@code{lilypond}.dir}. -@item -h,--help - Print usage help. -@item -I,--include=@var{dir} - Add @var{dir} to LilyPond's include path. -@item -o,--output=@var{file} - Generate output to @var{file}. The extension of @var{file} is ignored. -@item --png - Also generate pictures of each page, in PNG format. -@item --preview - Also generate a picture of the first system of the score. - -@cindex preview -@cindex picture -@cindex bitmap -@cindex pixmap -@cindex thumbnail -@cindex screen shot - -@item -s,--set=@var{key}=@var{val} - Add @var{key}= @var{val} to the settings, overriding those specified -in the files. Possible keys: @code{language}, @code{latexheaders}, -@code{latexpackages}, @code{latexoptions}, @code{papersize}, -@code{linewidth}, @code{orientation}, -@code{textheight}. -@item -v,--version -Show version information. -@item -V,--verbose -Be verbose. This prints out commands as they are executed, and more -information about the formatting process is printed. -@item --debug -Print even more information. This is useful when generating bug reports. -@item -w,--warranty -Show the warranty with which GNU LilyPond comes. (It comes with -@strong{NO WARRANTY}!) -@end table - - - -@subsection Additional parameters - -The @code{lilypond} program responds to several parameters specified -in a @code{\paper} section of the input file. They can be overridden -by supplying a @code{--set} command line option. - -@table @code -@item language - Specify La@TeX{} language: the @code{babel} package will be -included. Default: unset. - - Read from the @code{\header} block. - -@item latexheaders - Specify additional La@TeX{} headers file. -< - Normally read from the @code{\header} block. Default value: empty. - -@item latexpackages - Specify additional La@TeX{} packages file. This works cumulative, -so you can add multiple packages using multiple @code{-s=latexpackages} options. - Normally read from the @code{\header} block. Default value: -@code{geometry}. - -@item latexoptions - Specify additional options for the La@TeX{} -@code{\documentclass}. You can put any valid value here. This was -designed to allow @code{lilypond} to produce output for double-sided -paper, with balanced margins and page numbers on alternating sides. To -achieve this specify @code{twoside}. - -@item orientation - Set orientation. Choices are @code{portrait} or @code{landscape}. Is -read from the @code{\paper} block, if set. - -@item textheight - The vertical extension of the music on the page. It is normally - calculated automatically, based on the paper size. - -@item linewidth - The music line width. It is normally read from the @code{\paper} -block. - -@item papersize - The paper size (as a name, e.g. @code{a4}). It is normally read from -the @code{\paper} block. - -@item fontenc - The font encoding, should be set identical to the @code{font-encoding} - property in the score. -@end table - - - @node Invoking the lilypond binary @section Invoking the lilypond binary @cindex Invoking LilyPond @@ -137,7 +22,7 @@ the @code{\paper} block. The formatting system consists of two parts: a binary executable -(@file{lilypond-bin}), which is responsible for the formatting +(@file{lilypond}), which is responsible for the formatting functionality, and support scripts, which post-process the resulting output. Normally, the support scripts are called, which in turn invoke the @code{lilypond-bin} binary. However, @code{lilypond-bin} may be @@ -583,3 +468,116 @@ and set @code{XEDITOR} to @code{emacsclient --no-wait +%l:%c %f}. Vim users can set @var{XEDITOR} to @code{gvim --remote +:%l:norm%c| %f}. + +@node Invoking lilypond-latex +@section Invoking lilypond-latex + +Before LilyPond 3.0, the task of generating nicely titled output was +relegated to a separate program. This wrapper script +@code{lilypond-latex} uses the LilyPond program and La@TeX{} to create +a nicely titled piece of sheet music. + +@example + @code{lilypond} [@var{option}]@dots{} @var{file}@dots{} +@end example + +To have @code{lilypond} read from stdin, use a dash @code{-} for +@var{file}. The program supports the following options. + +@cindex stdin, reading + +@table @code +@item -k,--keep + Keep the temporary directory with all output +files. The temporary directory is created in the current directory as @code{@code{lilypond}.dir}. +@item -h,--help + Print usage help. +@item -I,--include=@var{dir} + Add @var{dir} to LilyPond's include path. +@item -o,--output=@var{file} + Generate output to @var{file}. The extension of @var{file} is ignored. +@item --png + Also generate pictures of each page, in PNG format. +@item --preview + Also generate a picture of the first system of the score. + +@cindex preview +@cindex picture +@cindex bitmap +@cindex pixmap +@cindex thumbnail +@cindex screen shot + +@item -s,--set=@var{key}=@var{val} + Add @var{key}= @var{val} to the settings, overriding those specified +in the files. Possible keys: @code{language}, @code{latexheaders}, +@code{latexpackages}, @code{latexoptions}, @code{papersize}, +@code{linewidth}, @code{orientation}, +@code{textheight}. +@item -v,--version +Show version information. +@item -V,--verbose +Be verbose. This prints out commands as they are executed, and more +information about the formatting process is printed. +@item --debug +Print even more information. This is useful when generating bug reports. +@item -w,--warranty +Show the warranty with which GNU LilyPond comes. (It comes with +@strong{NO WARRANTY}!) +@end table + + + +@subsection Additional parameters + +The @code{lilypond} program responds to several parameters specified +in a @code{\paper} section of the input file. They can be overridden +by supplying a @code{--set} command line option. + +@table @code +@item language + Specify La@TeX{} language: the @code{babel} package will be +included. Default: unset. + + Read from the @code{\header} block. + +@item latexheaders + Specify additional La@TeX{} headers file. + Normally read from the @code{\header} block. Default value: empty. + +@item latexpackages + Specify additional La@TeX{} packages file. This works cumulative, +so you can add multiple packages using multiple @code{-s=latexpackages} options. + Normally read from the @code{\header} block. Default value: +@code{geometry}. + +@item latexoptions + Specify additional options for the La@TeX{} +@code{\documentclass}. You can put any valid value here. This was +designed to allow @code{lilypond} to produce output for double-sided +paper, with balanced margins and page numbers on alternating sides. To +achieve this specify @code{twoside}. + +@item orientation + Set orientation. Choices are @code{portrait} or @code{landscape}. Is +read from the @code{\paper} block, if set. + +@item textheight + The vertical extension of the music on the page. It is normally + calculated automatically, based on the paper size. + +@item linewidth + The music line width. It is normally read from the @code{\paper} +block. + +@item papersize + The paper size (as a name, e.g. @code{a4}). It is normally read from +the @code{\paper} block. + +@item fontenc + The font encoding, should be set identical to the @code{font-encoding} + property in the score. +@end table + + + diff --git a/input/regression/GNUmakefile b/input/regression/GNUmakefile index 5b51006a89..220219881a 100644 --- a/input/regression/GNUmakefile +++ b/input/regression/GNUmakefile @@ -2,7 +2,6 @@ depth = ../.. STEPMAKE_TEMPLATES=documentation texinfo tex LOCALSTEPMAKE_TEMPLATES=lilypond ly lysdoc -LILYPOND_BOOK_FLAGS = --process="lilypond-bin --header=texidoc -I $(srcdir)/input/test -e '(ly:set-option (quote internal-type-checking) \#t)'" include $(depth)/make/stepmake.make diff --git a/input/template/GNUmakefile b/input/template/GNUmakefile index 370b3e4398..2e22296084 100644 --- a/input/template/GNUmakefile +++ b/input/template/GNUmakefile @@ -1,7 +1,6 @@ depth = ../.. STEPMAKE_TEMPLATES=documentation texinfo tex -LILYPOND_BOOK_FLAGS = --process="lilypond-bin --header=texidoc -I $(srcdir)/input/regression -e '(ly:set-option (quote internal-type-checking) \#t)'" LOCALSTEPMAKE_TEMPLATES=lilypond ly lysdoc EXTRA_DIST_FILES=README diff --git a/input/test/GNUmakefile b/input/test/GNUmakefile index 9aa3d84a97..7e38336fe7 100644 --- a/input/test/GNUmakefile +++ b/input/test/GNUmakefile @@ -3,7 +3,6 @@ depth = ../.. STEPMAKE_TEMPLATES=documentation texinfo tex LOCALSTEPMAKE_TEMPLATES=lilypond ly lysdoc -LILYPOND_BOOK_FLAGS = --process="lilypond-bin --header=texidoc -I $(srcdir)/input/regression -e '(ly:set-option (quote internal-type-checking) \#t)'" ## Hmm, would this work? No -- if we really want examples, move ## to other dir (input/) comes to mind. diff --git a/lily/GNUmakefile b/lily/GNUmakefile index a306551671..66ed748b46 100644 --- a/lily/GNUmakefile +++ b/lily/GNUmakefile @@ -1,7 +1,7 @@ depth = .. -NAME = lilypond-bin +NAME = lilypond SUBDIRS = include MODULE_LIBS=$(depth)/flower diff --git a/lily/include/main.hh b/lily/include/main.hh index 6319df9b68..21171a71a4 100644 --- a/lily/include/main.hh +++ b/lily/include/main.hh @@ -35,10 +35,15 @@ extern bool safe_global_b; extern bool verbose_global_b; extern bool store_locations_global_b; extern bool internal_type_checking_global_b; + +/* + todo: collect in Output_option struct? + */ extern bool make_png; extern bool make_dvi; extern bool make_ps; extern bool make_pdf; +extern bool make_tex; extern bool make_preview; /* misc */ diff --git a/lily/main.cc b/lily/main.cc index 35d07b844a..33e50ce334 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -65,9 +65,10 @@ String init_scheme_code_string = "(begin #t "; bool make_pdf = false; bool make_dvi = false; -bool make_ps = true; +bool make_ps = false; bool make_png = false; bool make_preview = false; +bool make_tex = false; /* * Miscellaneous global stuff. @@ -137,7 +138,8 @@ static Long_option_init options_static[] = {0, "png", 0, _i ("generate PNG")}, {0, "ps", 0, _i ("generate PostScript")}, {0, "dvi", 0, _i ("generate DVI")}, - {0, "pdf", 0, _i ("generate PDF")}, + {0, "pdf", 0, _i ("generate PDF (default)")}, + {0, "tex", 0, _i ("generate TeX")}, {0, "safe-mode", 's', _i ("run in safe mode")}, {0, "version", 'v', _i ("print version number")}, {0, "verbose", 'V', _i ("be verbose")}, @@ -251,6 +253,7 @@ prepend_load_path (String dir) static void determine_output_options () { + bool found_tex = false; SCM formats = ly_output_formats (); for (SCM s = formats; ly_c_pair_p (s); s = ly_cdr (s)) @@ -258,6 +261,7 @@ determine_output_options () found_tex = found_tex || (ly_scm2string (ly_car (s)) == "tex"); } + if (make_ps && found_tex) { make_dvi = true; @@ -266,6 +270,16 @@ determine_output_options () { make_ps = true; } + if (make_dvi && found_tex) + { + make_tex = true; + } + if (!(make_dvi + || make_tex + || make_ps + || make_png + || make_pdf)) + make_pdf = true; } static void diff --git a/lily/paper-book.cc b/lily/paper-book.cc index a94be54856..6121bf8946 100644 --- a/lily/paper-book.cc +++ b/lily/paper-book.cc @@ -122,6 +122,7 @@ Paper_book::post_processing (SCM module, bool do_it_; char const *func_name_; } settings[] = { + {make_tex, "convert-to-tex"}, {make_dvi, "convert-to-dvi"}, {make_ps, "convert-to-ps"}, {make_pdf, "convert-to-pdf"}, diff --git a/make/lilypond-vars.make b/make/lilypond-vars.make index 45c35c02f4..b571b4c160 100644 --- a/make/lilypond-vars.make +++ b/make/lilypond-vars.make @@ -38,6 +38,7 @@ CONVERT_LY = $(script-dir)/convert-ly.py LILYPOND = $(builddir)/lily/$(outconfbase)/lilypond LILYPOND_BOOK = $(script-dir)/lilypond-book.py LILYPOND_BOOK_INCLUDES = -I $(pwd) -I $(outdir) -I$(input-dir) -I $(input-dir)/regression/ -I $(input-dir)/test/ -I $(input-dir)/tutorial/ -I $(builddir)/mf/$(outconfbase)/ -I $(builddir)/mf/out/ +LILYPOND_BOOK_FLAGS = --process="lilypond-bin -f tex --header=texidoc -I $(srcdir)/input/test -e '(ly:set-option (quote internal-type-checking) \#t)'" #texi-html for www only: LILYPOND_BOOK_FORMAT=$(if $(subst out-www,,$(notdir $(outdir))),texi,texi-html) diff --git a/scm/framework-ps.scm b/scm/framework-ps.scm index f265932197..1fd5949691 100644 --- a/scm/framework-ps.scm +++ b/scm/framework-ps.scm @@ -274,6 +274,9 @@ (define-public (convert-to-dvi book name) (ly:warn "Can not generate DVI via the postscript back-end")) +(define-public (convert-to-tex book name) + (ly:warn "Can not generate TeX via the postscript back-end")) + (define-public (convert-to-ps book name) #t) diff --git a/scm/framework-tex.scm b/scm/framework-tex.scm index 754c50160d..ba2992b042 100644 --- a/scm/framework-tex.scm +++ b/scm/framework-tex.scm @@ -192,7 +192,7 @@ (ly:outputter-dump-string outputter x)) (list ;;FIXME - (header "creator" "timestamp" bookpaper (length lines) #f) + (header bookpaper (length lines) #f) "\\def\\lilypondclassic{1}%\n" (output-scopes scopes fields basename) (define-fonts bookpaper) @@ -257,3 +257,6 @@ (display (format #f "invoking ~S\n" cmd)) (system cmd))) +(define-public (convert-to-tex book name) + #t) + diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py index 90fd9e57b3..4c3348247a 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -10,12 +10,12 @@ convert-ly on book: lilypond-book --filter="convert-ly --no-version --from=1.6.11 -" BOOK classic lilypond-book: - lilypond-book --process="lilypond-bin" BOOK.tely + lilypond-book --process="lilypond" BOOK.tely TODO: * ly-options: intertext ? * --linewidth? - * eps in latex / eps by lilypond-bin -fps ? + * eps in latex / eps by lilypond -fps ? * check latex parameters, twocolumn, multicolumn? * Converting from lilypond-book source, substitute: @@ -71,7 +71,7 @@ Example usage: lilypond-book --filter="tr '[a-z]' '[A-Z]'" BOOK lilypond-book --filter="convert-ly --no-version --from=2.0.0 -" BOOK - lilypond-book --process='lilypond-bin -I include' BOOK + lilypond-book --process='lilypond -I include' BOOK """) @@ -91,11 +91,11 @@ option_definitions = [ ] include_path = [ly.abspath (os.getcwd ())] -lilypond_binary = os.path.join ('@bindir@', 'lilypond-bin') +lilypond_binary = os.path.join ('@bindir@', 'lilypond') # only use installed binary when we're installed too. if '@bindir@' == ('@' + 'bindir@') or not os.path.exists (lilypond_binary): - lilypond_binary = 'lilypond-bin' + lilypond_binary = 'lilypond' use_hash_p = 1 @@ -415,7 +415,7 @@ def compose_ly (code, options): return (PREAMBLE_LY + body) % vars () # BARF -# use lilypond-bin for latex (.lytex) books, +# use lilypond for latex (.lytex) books, # and lilypond --preview for html, texinfo books? def to_eps (file): cmd = r'latex "\nonstopmode \input %s"' % file diff --git a/scripts/lilypond.py b/scripts/lilypond-latex.py similarity index 98% rename from scripts/lilypond.py rename to scripts/lilypond-latex.py index 025cd4df79..faec0d33f9 100644 --- a/scripts/lilypond.py +++ b/scripts/lilypond-latex.py @@ -1,13 +1,13 @@ #!@PYTHON@ -# lilypond.py -- frontend for lilypond-bin +# lilypond.py -- frontend for lilypond # # source file of the GNU LilyPond music typesetter # # (c) 1998--2004 Han-Wen Nienhuys # Jan Nieuwenhuizen # -# Run lilypond-bin, generate printable document -# Invokes: lilypond-bin, latex (or pdflatex), dvips, ps2pdf, gs +# Run lilypond, generate printable document +# Invokes: lilypond, latex (or pdflatex), dvips, ps2pdf, gs # # This is the third incarnation of ly2dvi, renamed to lilypond. @@ -87,7 +87,7 @@ program_version = '@TOPLEVEL_VERSION@' # input without \book, use classic latex definitions classic_p = 0 verbose_p = 0 -latex_p = 0 +latex_p = 1 pseudo_filter_p = 0 original_dir = os.getcwd () temp_dir = os.path.join (original_dir, '%s.dir' % program_name) @@ -151,11 +151,11 @@ tex_extension = '.tex' ## yuk. #lilypond_binary = 'valgrind --suppressions=%(home)s/usr/src/guile-1.6.supp --num-callers=10 %(home)s/usr/src/lilypond/lily/out/lilypond '% { 'home' : '/home/hanwen' } -lilypond_binary = os.path.join ('@bindir@', 'lilypond-bin') +lilypond_binary = os.path.join ('@bindir@', 'lilypond') # only use installed binary when we're installed too. if '@bindir@' == ('@' + 'bindir@') or not os.path.exists (lilypond_binary): - lilypond_binary = 'lilypond-bin' + lilypond_binary = 'lilypond' ## Init to empty; values here take precedence over values in the file @@ -401,7 +401,7 @@ def global_latex_preamble (extra): unit = extra['unit'][-1] - # FIXME, must (only) from lilypond-bin + # FIXME, must (only) from lilypond s += r''' \usepackage{inputenc} \pagestyle{empty} @@ -487,7 +487,7 @@ def run_dvips (outbase, extra): '''Run dvips using the correct options taken from EXTRA, leaving a PS file in OUTBASE.ps ''' - #FIXME: papersize, orientation must come from lilypond-bin + #FIXME: papersize, orientation must come from lilypond opts = '' if extra['papersize']: opts = ' -t%s' % extra['papersize'][0] -- 2.39.2