From: fred Date: Wed, 27 Mar 2002 01:02:26 +0000 (+0000) Subject: lilypond-1.3.146 X-Git-Tag: release/1.5.59~723 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=41f0668dfa6afaca5c0bc411f91e9d8c2612c492;p=lilypond.git lilypond-1.3.146 --- diff --git a/Documentation/user/GNUmakefile b/Documentation/user/GNUmakefile index 08a4b139c5..d36ffe5d6d 100644 --- a/Documentation/user/GNUmakefile +++ b/Documentation/user/GNUmakefile @@ -46,7 +46,7 @@ $(outdir)/%.info: $(outdir)/%.texi default: # Info is now built by default via texinfo-rules. -# We must build them by defaulbt, otherwise they get built during make install +# We must build them by default, otherwise they get built during make install info: $(INFO_FILES) @@ -115,14 +115,27 @@ local-clean: rm -f fonts.aux fonts.log feta*.tfm feta*.*pk rm -rf $(outdir)/lilypond $(outdir)/lilypond-internals -# when cross-compiling, we don't have lilypond +$(outdir)/lilypond.nexi: $(outdir)/interfaces.itexi +$(outdir)/lilypond.texi: $(outdir)/interfaces.itexi + +# Rules for the automatically generated documentation +# When cross-compiling, we don't have lilypond, so we fake ifneq ($(CROSS),yes) -$(outdir)/lilypond-internals.nexi $(outdir)/lilypond-internals.texi: +dummy: +$(outdir)/lilypond-internals.nexi $(outdir)/lilypond-internals.texi: dummy cd $(outdir) && ../$(depth)/$(builddir)/lily/$(outconfbase)/lilypond ../$(src-depth)/ly/generate-documentation -ln $(outdir)/lilypond-internals.texi $(outdir)/lilypond-internals.nexi + +$(outdir)/interfaces.itexi: dummy + cd $(outdir) && ../$(depth)/$(builddir)/lily/$(outconfbase)/lilypond ../$(src-depth)/ly/generate-interface-doc + else + $(outdir)/lilypond-internals.nexi $(outdir)/lilypond-internals.texi: touch $@ touch $(outdir)/$(*F).nexi + +$(outdir)/interfaces.itexi: + cp dummy-interfaces.itexi $@ endif diff --git a/Documentation/user/lilypond.tely b/Documentation/user/lilypond.tely index 96f3ae35b6..1c88efb334 100644 --- a/Documentation/user/lilypond.tely +++ b/Documentation/user/lilypond.tely @@ -79,7 +79,8 @@ this and other documentation. * Conversion tools:: Converting to lilypond source format. * lilypond-book:: Interleaving text with music. * Internals:: How it all works. -* Literature:: additional reading +* Literature:: Additional reading +* Full Grob interface list:: Generated list of all Grob properties. * Index of internals:(lilypond-internals). Auto generated detailed documentation. * Index:: Unified index. * Function Index:: Function index. @@ -102,8 +103,9 @@ this and other documentation. @mbinclude ly2dvi.itexi @mbinclude convert-ly.itexi @mbinclude lilypond-book.itely -@mbinclude convertors.itely +@mbinclude converters.itely @mbinclude literature.itely +@mbinclude interfaces.itexi @c FIXME: Index has two alphabetically sorted lists @code vs plain? @node Index diff --git a/Documentation/user/ly2dvi.itexi b/Documentation/user/ly2dvi.itexi index e2351c5eae..abb6dc2f2b 100644 --- a/Documentation/user/ly2dvi.itexi +++ b/Documentation/user/ly2dvi.itexi @@ -15,33 +15,40 @@ one or more DVI files. @subsection Invoking ly2dvi @example - ly2dvi [options] inputfile[.ly] [....] +ly2dvi [OPTION]... [FILE]... @end example @unnumberedsec Options @table @code -@item -s,--set=@var{KEY}=@var{VAL} - Add @var{key}= @var{val} to the settings, overriding those specified -in the files. Possible keys: language, latexheaders, latexpackages, -papersizename, pagenumber, linewidth, orientation, textheight. - @item -k,--keep Keep the temporary directory including LilyPond and ly2dvi output files. The temporary directory is created in the current directory as @code{ly2dvi.dir}. -@item -P,--postscript - Generate PostScript in stead of DVI. -@item --no-lily - Do not run LilyPond; useful for debugging ly2dvi. +@item -d,--dependencies + Write makefile dependencies for every input file. @item -h,--help Print help. -@item -I,--include - Add to the lilypond include path. -@item -d,--dependencies - Make a dependency file for the output. -@item --outdir=@var{dir} - Generate output (including MIDI files) in @var{dir} - +@item -I,--include=@var{DIR} + Add @var{DIR} to LilyPond's include path. +@item -m,--no-paper + Produce MIDI output only. +@item --no-lily + Do not run LilyPond; useful for debugging ly2dvi. +@item -o,--output=@var{FILE} + Generate output to @var{FILE}. The extension of @var{FILE} is ignored. +@item -P,--postscript + Also generate PostScript output. +@item -s,--set=@var{KEY}=@var{VAL} + Add @var{key}= @var{val} to the settings, overriding those specified +in the files. Possible keys: language, latexheaders, latexpackages, +papersize, pagenumber, linewidth, orientation, textheight. +@item -v,--version +Show version information +@item -V,--verbose +Be verbose +@item -w,--warranty +Show the warranty with which GNU LilyPond comes. (It comes with +@strong{NO WARRANTY}!) @end table @subsection Titling layout @@ -102,14 +109,22 @@ read from the @code{\paper} block, if set. @item linewidth Is read from the @code{\paper} block. -@item papersizename - Specify name of papersize. Is read from the @code{\paper} block. +@item papersize + Specify the papersize. Is read from the @code{\paper} block. +@end table + +@subsection Environment variables + +@table @code +@item LANG +selects the language for the warning messages of Ly2dvi and LilyPond. @end table @subsection Bugs -Assumes that settings for LilyPond are correct. Assumes that @code{cp} -and @code{rm} are in the path. +Assumes that @code{cp} and @code{rm} are in the path. + +Cannot generate @TeX{} or @code{PostScript} only. If find something that you consider a bug, please send a bugreport (See @ref{Bug reports}) to @email{bug-gnu-music@@gnu.org}. diff --git a/Documentation/user/preface.itely b/Documentation/user/preface.itely index 9211d00fa3..20a85a9ce3 100644 --- a/Documentation/user/preface.itely +++ b/Documentation/user/preface.itely @@ -22,10 +22,11 @@ flexibility and good documentation. We hope you will have as much fun in using LilyPond as we have when hacking it. This manual was written to help you learn LilyPond, but as you might -imagine, we don't have much to learn about it. Therefore, we can't -really judge whether the manual is clear for a newbie, but maybe you -can! So, should you find any part of the manual vague or outdated, -please tell us your suggestions: if you don't, we'll never know. +imagine, we ourselves don't have much to learn about it. Therefore, +we can't really judge whether the manual is clear for a newbie, but +maybe you can! So, should you find any part of the manual vague or +outdated, please tell us your suggestions: if you don't, we'll never +know. Han-Wen and Jan diff --git a/NEWS b/NEWS index c80c4bc83e..aec5cbde50 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,7 @@ New features in 1.4 -* Finale (.etf), PMX (.pmx) and musedata import tools. +* Finale (.etf), PMX, Musedata and Mup import tools. * Point and click functionality using emacs and Xdvi. diff --git a/input/bugs/lyrics-bar.ly b/input/bugs/lyrics-bar.ly new file mode 100644 index 0000000000..26a675ce34 --- /dev/null +++ b/input/bugs/lyrics-bar.ly @@ -0,0 +1,45 @@ + +% +% Lyrics with barline colliding is fine now, BUT +% There's an horizontal gap between staff and end bar +% + +\header{ +texidoc=" +Adding a @code{Bar_engraver} to the LyricsVoice context makes sure that +lyrics don't collide with barlines. +"; +} + +\score { + \context StaffGroup < + \notes \context Staff { + b1 \bar "|:"; b1 \bar ":|"; + } + \lyrics\context Lyrics < + \context LyricsVoiceWithBars { +% thisContextHasBarEngraver1 added + ThisContextCertainlyHasBarEngraverAddedButThereHasBeenSomethingFunnyBefore1. Here. + } + \context LyricsVoice { + this4 one has no BarEngraverAddedToContext1 + } + > + \notes \context Staff = SB { b1 b1 } + > + \paper { + linewidth = -1.0\cm; + \translator { + \LyricsContext + \accepts "LyricsVoiceWithBars"; + } + \translator { + \LyricsVoiceContext + \consists "Bar_engraver"; + \name "LyricsVoiceWithBars"; + } + \translator { + \LyricsVoiceContext + } + } +} diff --git a/lily/system-start-delimiter.cc b/lily/system-start-delimiter.cc index 811a4171e3..5ebe192023 100644 --- a/lily/system-start-delimiter.cc +++ b/lily/system-start-delimiter.cc @@ -143,9 +143,13 @@ System_start_delimiter::staff_brace (Grob*me,Real y) { /* - FIXME: should look at afm/tfm file for dimensions. + FIXME: + * should look at afm/tfm file for dimensions. + (This breaks ascii-art output: it hasn't got 255 symbols) - (This breaks ascii-art output: it hasn't got 255 symbols) + * more glyphs (or maybe just better sized (fixed # of staff-spaces)), + the size mismatches with the staffs are very ugly + */ // ugrhn diff --git a/ly/generate-interface-doc.ly b/ly/generate-interface-doc.ly new file mode 100644 index 0000000000..a50eeaf3d0 --- /dev/null +++ b/ly/generate-interface-doc.ly @@ -0,0 +1,5 @@ + +% +% Running LilyPond on this file generates the short interface doc +% +#(eval-string (ly-gulp-file "generate-interface-doc.scm")) diff --git a/make/lilypond-vars.make b/make/lilypond-vars.make index 83f330c9fd..2135a39c83 100644 --- a/make/lilypond-vars.make +++ b/make/lilypond-vars.make @@ -22,7 +22,7 @@ ABC2LY = $(script-dir)/abc2ly.py CONVERT_LY = $(script-dir)/convert-ly.py LILYPOND = $(depth)/$(builddir)/lily/$(outconfbase)/lilypond LILYPOND_BOOK = $(script-dir)/lilypond-book.py -LILYPOND_BOOK_INCLUDES = -I $(pwd) -I $(input-dir)/tricks/ -I $(input-dir)/regression/ -I $(input-dir)/test/ -I $(input-dir)/tutorial/ +LILYPOND_BOOK_INCLUDES = -I $(pwd) -I $(outdir) -I$(input-dir) -I $(input-dir)/tricks/ -I $(input-dir)/regression/ -I $(input-dir)/test/ -I $(input-dir)/tutorial/ LY2DVI = $(script-dir)/ly2dvi.py PS_TO_GIFS = $(buildscript-dir)/ps-to-gifs.sh PS_TO_PNGS = $(buildscript-dir)/ps-to-pngs.sh diff --git a/make/lilypond.spec.in b/make/lilypond.spec.in index f98142ef72..8916512e46 100644 --- a/make/lilypond.spec.in +++ b/make/lilypond.spec.in @@ -124,6 +124,7 @@ fi %{_prefix}/bin/ly2dvi %{_prefix}/bin/midi2ly %{_prefix}/bin/lilypond-book +%{_prefix}/bin/mup2ly %{_prefix}/bin/musedata2ly %{_prefix}/bin/pmx2ly %else @@ -144,6 +145,7 @@ fi %{_prefix}/man/man1/midi2ly.1.gz %{_prefix}/man/man1/lilypond-book.1.gz %{_prefix}/man/man1/musedata2ly.1.gz +%{_prefix}/man/man1/mup2ly.1.gz %{_prefix}/man/man1/pmx2ly.1.gz %{_prefix}/share/lilypond/ diff --git a/make/ly-rules.make b/make/ly-rules.make index 81b623957d..8c6dc1e97e 100644 --- a/make/ly-rules.make +++ b/make/ly-rules.make @@ -33,3 +33,11 @@ $(outdir)/%.info: $(outdir)/%.nexi # nfo: info from non-lily texi #$(outdir)/%.nfo: $(outdir)/%.nexi # $(MAKEINFO) --output=$(outdir)/$(*F).info $< + + +# +# Timothy's booklet +# +$(outdir)/%-book.ps: $(outdir)/%.ps + psbook $< $<.tmp + pstops '2:0L@.7(21cm,0)+1L@.7(21cm,14.85cm)' $<.tmp $@ diff --git a/make/ly.make b/make/ly.make index 8355a3dc65..caee2d2245 100644 --- a/make/ly.make +++ b/make/ly.make @@ -57,12 +57,12 @@ examples= # mutopia-examples=$(name) $(parts) -# +# moved to ly-rules.make # Timothy's booklet # -$(outdir)/%-book.ps: $(outdir)/%.ps - psbook $< $<.tmp - pstops '2:0L(11.45in,0.25in)+1L(11.45in,5.6in)' $<.tmp $@ +#$(outdir)/%-book.ps: $(outdir)/%.ps +# psbook $< $<.tmp +# pstops '2:0L@.7(21cm,0)+1L@.7(21cm,14.85cm)' $<.tmp $@ # # Catch-all target: type `make foo' to make out/foo.ps, diff --git a/make/mutopia-rules.make b/make/mutopia-rules.make index a901a3be97..cf3db53943 100644 --- a/make/mutopia-rules.make +++ b/make/mutopia-rules.make @@ -21,15 +21,16 @@ $(outdir)/%.ly: %.abc $(PYTHON) $(ABC2LY) -o $@ $< $(outdir)/%.dvi: $(outdir)/%.ly - $(PYTHON) $(LY2DVI) --outdir=$(outdir) --dependencies $< + $(PYTHON) $(LY2DVI) --output=$@ --dependencies $< # don't junk intermediate .dvi files. They're easier to view than # .ps or .png .PRECIOUS: $(outdir)/%.dvi $(outdir)/%.dvi: %.ly - $(PYTHON) $(LY2DVI) --outdir=$(outdir) --dependencies $< + $(PYTHON) $(LY2DVI) --output=$@ --dependencies $< $(outdir)-$(PAPERSIZE)/%.dvi: %.ly - $(PYTHON) $(LY2DVI) --outdir=$(outdir)-$(PAPERSIZE) --dependencies --set=papersize=$(PAPERSIZE) $< + $(PYTHON) $(LY2DVI) --output=$@ --dependencies --set=papersize=$(PAPERSIZE) $< + diff --git a/mf/feta-generic.mf b/mf/feta-generic.mf index 2e31f1ada8..7be674ce32 100644 --- a/mf/feta-generic.mf +++ b/mf/feta-generic.mf @@ -39,12 +39,12 @@ if test = 0: else: % input feta-bolletjes; % input feta-banier; - input feta-eindelijk; +% input feta-eindelijk; % input feta-klef; % input feta-toevallig; % input feta-schrift; % input feta-haak; -% input feta-timesig; + input feta-timesig; % input feta-pendaal; % input feta-accordion; fi diff --git a/mf/feta-timesig.mf b/mf/feta-timesig.mf index 488e8ea732..cc22ca8ab9 100644 --- a/mf/feta-timesig.mf +++ b/mf/feta-timesig.mf @@ -3,15 +3,15 @@ % % source file of the Feta (not an abbreviation of Font-En-Tja) music font % -% (c) 1998--1999 Mats Bengtsson , -% Christian Mondrup +% (c) 1998--2001 Mats Bengtsson , +% Christian Mondrup fet_begingroup("timesig"); def set_C_width = save left_width, right_width; - left_width# := 0.9 staff_space#; - right_width# := .7 staff_space#; + left_width# := 1.0 staff_space#; + right_width# := 0.8 staff_space#; define_pixels(left_width,right_width); enddef; @@ -31,27 +31,28 @@ def draw_C = z4 = (0, -staff_space); z5r = (right_width - stafflinethickness, -0.4 staff_space); - penpos1(hair, 0); + penpos1(hair, 10); penpos2(stafflinethickness, 90); penpos3(left_fatness * staff_space, 180); penpos4(stafflinethickness, -90); penpos5(hair, -5); + z6l = z1l; + penpos6(hair, 0); - draw_bulb(-1, z1l, z1r, bulb_rad, .8); + draw_bulb(-1, z6l, z6r, bulb_rad, .8); - fill z1l{up} .. z2l{left} .. z3l{down} .. z4l{right} .. + fill z1l{dir (100)} .. z2l{left} .. z3l{down} .. z4l{right} .. simple_serif(z5l, z5r, -90) .. - z4r{left} .. z3r{up} .. z2r{right} .. z1r -- cycle; + z4r{left} .. z3r{up} .. z2r{right} .. {dir (-80)}z1r -- cycle; -% labels(1,2,3,4,5); - penlabels(1,2,3,4,5); + penlabels(1,2,3,4,5,6); enddef; fet_beginchar ("4/4 meter", "C4/4", "fourfourmeter") set_C_width; set_char_box(left_width# + staff_space#, right_width# + staff_space#, staff_space#, staff_space#); - + draw_C; fet_endchar; diff --git a/scm/documentation-lib.scm b/scm/documentation-lib.scm index b12860eeb9..02f5a56063 100644 --- a/scm/documentation-lib.scm +++ b/scm/documentation-lib.scm @@ -134,13 +134,23 @@ Add a ref if REF is set ;; prepend GNU for dir, must be unique "\n* GNU " name ": (" file-name "). " name "." "\n@end direntry" - (node "Top") ",(lilypond)Index,(lilypond)Development," top + ;; ugh, prev and next should be settable, of course + (node "Top") ",(lilypond)Index,(lilypond)Full Grob interface list," top "\n@top" (texi-section 1 name #f) (texi-menu items-alist) "\n@contents" )) +(define (itexi-file-head name file-name top items-alist) + (string-append + "@c -*-texinfo-*-" + (node name) ",,," top + (texi-section 1 name #f) + (texi-menu items-alist) + "\n@contents" + )) + (define (context-name name) name) diff --git a/scm/generate-interface-doc.scm b/scm/generate-interface-doc.scm new file mode 100644 index 0000000000..565f72a240 --- /dev/null +++ b/scm/generate-interface-doc.scm @@ -0,0 +1,52 @@ + +;;; generate-interface-doc.scm -- Generate list of all intefaces, for refman +;;; +;;; source file of the GNU LilyPond music typesetter +;;; +;;; (c) 2000--2001 Han-Wen Nienhuys +;;; Jan Nieuwenhuizen + +;;; File entry point for generated documentation + +;;; Running LilyPond on this file generates the documentation + + + +;; We use ly-gulp because these files live in +;; +;; PATH=$LILYPONDPREFIX/scm:/scm +;; +(eval-string (ly-gulp-file "documentation-lib.scm")) +(eval-string (ly-gulp-file "engraver-documentation-lib.scm")) +(eval-string (ly-gulp-file "backend-documentation-lib.scm")) + +;;(define no-copies #t) ; from 490 to 410K, but doesn't look nice yet +;; +;; Also, copies of interfaces use up lots more space, but that's +;; functional because the default property values of the interfaces +;; are described... +(define no-copies #f) + +(let* ((doc (string-append + (document-all-interfaces "Full Grob interface list") + ) + ) + (name "interfaces") + (outname (string-append name ".itexi")) + (out (open-output-file outname))) + + (writing-wip outname) + (display + (string-append + ;;(itexi-file-head + ;; + ;; ;; we can't use (dir) and top if we're included by lilypond.tely + ;; "Grob interfaces" name "" + ;; '( + ;; ("Grob interfaces" . "Grob Interfaces") + ;; )) + doc + "\n") + out)) + +(newline (current-error-port)) diff --git a/scripts/ly2dvi.py b/scripts/ly2dvi.py index 56de2cb14a..fe178eb96d 100644 --- a/scripts/ly2dvi.py +++ b/scripts/ly2dvi.py @@ -1,5 +1,13 @@ #!@PYTHON@ -# run lily, setup LaTeX input. +# Run lilypond, latex, dvips. +# +# This is the third incarnation of ly2dvi. +# +# Earlier incarnations of ly2dvi were written by +# Jeffrey B. Reed (Python version) +# Jan Arne Fagertun (Bourne shell script) +# + # Note: gettext work best if we use ' for docstrings and " # for gettextable strings @@ -7,8 +15,20 @@ ''' TODO: - * check --dependencies + * figure out which set of command line options should make ly2dvi: + na: create tex only? + na: create latex only? + na: create tex and latex + default: create dvi only + na: create tex, latex and dvi + -P: create dvi and ps + na: * create ps only + + etc. + + for foo.ly, rename ly2dvi.dir to out-ly2dvi, foo.ly2dvi, foo.dir ? + * move versatile taglines, \header { @@ -73,17 +93,23 @@ extra_fields = extra_init.keys () fields = layout_fields + extra_fields program_name = 'ly2dvi' -help_summary = _("Generate .dvi with LaTeX for LilyPond") +help_summary = _ ("Generate .dvi with LaTeX for LilyPond") include_path = ['.'] -no_lily = 0 -outdir = '.' +lily_p = 1 +paper_p = 1 + +output = 0 +targets = { + 'DVI' : 0, + 'LATEX' : 0, + 'MIDI' : 0, + 'TEX' : 0, + } + track_dependencies_p = 0 dependency_files = [] -# generate ps ? -postscript_p = 0 - # be verbose? verbose_p = 0 @@ -221,8 +247,6 @@ def help (): sys.stdout.write ('\n\n') sys.stdout.write (_ ("Report bugs to %s") % 'bug-gnu-music@gnu.org') sys.stdout.write ('\n') - sys.exit (0) - def setup_temp (): global temp_dir @@ -238,11 +262,12 @@ def setup_temp (): def system (cmd, ignore_error = 0): if verbose_p: progress (_ ("Invoking `%s\'") % cmd) - st = os.system (cmd) + st = os.system (cmd) >> 8 if st: - msg = ( _ ("error: ") + _ ("command exited with value %d") % st) + name = re.match ('[ \t]*([^ \t]*)', cmd).group (1) + msg = name + ': ' + _ ("command exited with value %d") % st if ignore_error: - sys.stderr.write (msg + ' ' + _ ("(ignored)") + ' ') + warning (msg + ' ' + _ ("(ignored)") + ' ') else: error (msg) @@ -278,36 +303,51 @@ def strip_extension (f, ext): # END Library option_definitions = [ + ('', 'd', 'dependencies', _ ("write Makefile dependencies for every input file")), ('', 'h', 'help', _ ("this help")), - ('KEY=VAL', 's', 'set', _ ("change global setting KEY to VAL")), - ('DIR', 'I', 'include', _ ("add DIR to LilyPond\'s search path")), - ('', 'P', 'postscript', _ ("generate PostScript output")), - ('', 'k', 'keep', _ ("keep all output, and name the directory ly2dvi.dir")), + (_ ("DIR"), 'I', 'include', _ ("add DIR to LilyPond's search path")), + ('', 'k', 'keep', _ ("keep all output, and name the directory %s.dir") % program_name), ('', '', 'no-lily', _ ("don't run LilyPond")), + ('', 'm', 'no-paper', _ ("produce MIDI output only")), + (_ ("FILE"), 'o', 'output', _ ("write ouput to FILE")), + # why capital P? + ('', 'P', 'postscript', _ ("generate PostScript output")), + (_ ("KEY=VAL"), 's', 'set', _ ("change global setting KEY to VAL")), ('', 'V', 'verbose', _ ("verbose")), ('', 'v', 'version', _ ("print version number")), ('', 'w', 'warranty', _ ("show warranty and copyright")), - ('DIR', '', 'outdir', _ ("dump all final output into DIR")), - ('', 'd', 'dependencies', _ ("write Makefile dependencies for every input file")), ] -def run_lilypond (files): - opts = '' +def run_lilypond (files, outbase, dep_prefix): + opts = '--output=%s.tex' % outbase opts = opts + ' ' + string.join (map (lambda x : '-I ' + x, include_path)) - opts = opts + ' ' + string.join (map (lambda x : '-H ' + x, fields)) - + if paper_p: + opts = opts + ' ' + string.join (map (lambda x : '-H ' + x, fields)) + else: + opts = opts + ' --no-paper' + if track_dependencies_p: - opts = opts + " --dependencies " + opts = opts + " --dependencies" + if dep_prefix: + opts = opts + ' --dep-prefix=%s' % dep_prefix fs = string.join (files) + + if not verbose_p: + progress ( _("Running %s...") % 'LilyPond') + # cmd = cmd + ' 1> /dev/null 2> /dev/null' + else: + opts = opts + ' --verbose' - system ('lilypond %s %s ' % (opts, fs)) + system ('lilypond %s %s ' % (opts, fs)) def analyse_lilypond_output (filename, extra): + + # urg '''Grep FILENAME for interesting stuff, and put relevant info into EXTRA.''' filename = filename+'.tex' - progress (_ ("Analyzing `%s'") % filename) + progress (_ ("Analyzing %s...") % filename) s = open (filename).read () # search only the first 10k @@ -335,6 +375,7 @@ def find_tex_files_for_base (base, extra): def find_tex_files (files, extra): tfiles = [] + for f in files: x = 0 while 1: @@ -457,27 +498,22 @@ def global_latex_definition (tfiles, extra): return s -def do_files (fs, extra): - - '''process the list of filenames in FS, using standard settings in EXTRA. - ''' - if not no_lily: - run_lilypond (fs) - - wfs = find_tex_files (fs, extra) +def run_latex (files, outbase, extra): + wfs = find_tex_files ([outbase] + files[1:], extra) s = global_latex_definition (wfs, extra) - latex_file ='ly2dvi.out' - f = open (latex_file + '.tex', 'w') + f = open (outbase + '.latex', 'w') f.write (s) f.close () - # todo: nonstopmode - system ('latex \\\\nonstopmode \\\\input %s' % latex_file) - return latex_file + '.dvi' + cmd = 'latex \\\\nonstopmode \\\\input %s' % outbase + '.latex' + if not verbose_p: + progress ( _("Running %s...") % 'LaTeX') + cmd = cmd + ' 1> /dev/null 2> /dev/null' -def generate_postscript (dvi_name, extra): - '''Run dvips on DVI_NAME, optionally doing -t landscape''' + system (cmd) + +def run_dvips (outbase, extra): opts = '' if extra['papersize']: @@ -486,12 +522,13 @@ def generate_postscript (dvi_name, extra): if extra['orientation'] and extra['orientation'][0] == 'landscape': opts = opts + ' -t landscape' - ps_name = re.sub (r'\.dvi', r'.ps', dvi_name) - system ('dvips %s -o %s %s' % (opts, ps_name, dvi_name)) - - return ps_name + cmd = 'dvips %s -o %s %s' % (opts, outbase + '.ps', outbase + '.dvi') + + if not verbose_p: + progress ( _("Running %s...") % 'dvips') + cmd = cmd + ' 2> /dev/null' - + system (cmd) def generate_dependency_file (depfile, outname): df = open (depfile, 'w') @@ -525,16 +562,21 @@ for opt in options: pass elif o == '--help' or o == '-h': help () + sys.exit (0) elif o == '--include' or o == '-I': include_path.append (a) elif o == '--postscript' or o == '-P': - postscript_p = 1 + targets['PS'] = 0 elif o == '--keep' or o == '-k': keep_temp_dir_p = 1 elif o == '--no-lily': - no_lily = 1 - elif o == '--outdir': - outdir = a + lily_p = 0 + elif o == '--no-paper' or o == '-m': + targets = {} + targets['MIDI'] = 0 + paper_p = 0 + elif o == '--output' or o == '-o': + output = a elif o == '--set' or o == '-s': ss = string.split (a, '=') set_setting (extra_init, ss[0], ss[1]) @@ -546,7 +588,10 @@ for opt in options: identify () sys.exit (0) elif o == '--warranty' or o == '-w': - warranty () + try: + system ('lilypond -w') + except: + warranty () sys.exit (0) # On most platforms, this is equivalent to @@ -555,73 +600,102 @@ def compat_abspath (path): return os.path.normpath (os.path.join (os.getcwd (), path)) include_path = map (compat_abspath, include_path) -files = map (compat_abspath, files) -outdir = compat_abspath (outdir) - -files = map (lambda x: strip_extension (x, '.ly'), files) +original_output = output -if files: - setup_temp () - setup_environment () - - extra = extra_init - - dvi_name = do_files (files, extra) +if files and files[0] != '-': - if postscript_p: - ps_name = generate_postscript (dvi_name, extra) + files = map (lambda x: strip_extension (x, '.ly'), files) + if not output: + output = os.path.basename (files[0]) + for i in ('.dvi', '.latex', '.ly', '.ps', '.tex'): + output = strip_extension (output, i) - base = os.path.basename (files[0]) - dest = base - type = 'foobar' - srcname = 'foobar' - - if postscript_p: - srcname = ps_name - dest = dest + '.ps' - type = 'PS' + files = map (compat_abspath, files) + + if os.path.dirname (output) != '.': + dep_prefix = os.path.dirname (output) else: - srcname = dvi_name - dest= dest + '.dvi' - type = 'DVI' + dep_prefix = 0 - dest = os.path.join (outdir, dest) - midi = base + '.midi' - midi = os.path.join (outdir, midi) + reldir = os.path.dirname (output) + (outdir, outbase) = os.path.split (compat_abspath (output)) + + setup_environment () + setup_temp () + + extra = extra_init - if outdir != '.': + if lily_p: + try: + run_lilypond (files, outbase, dep_prefix) + except: + # TODO: friendly message about LilyPond setup/failing? + # + # TODO: lilypond should fail with different + # error codes for: + # - guile setup/startup failure + # - font setup failure + # - init.ly setup failure + # - parse error in .ly + # - unexpected: assert/core dump + targets = {} + + if targets.has_key ('DVI') or targets.has_key ('PS'): + try: + run_latex (files, outbase, extra) + # unless: add --tex, or --latex? + del targets['TEX'] + del targets['LATEX'] + except: + # TODO: friendly message about TeX/LaTeX setup, + # trying to run tex/latex by hand + if targets.has_key ('DVI'): + del targets['DVI'] + if targets.has_key ('PS'): + del targets['PS'] + + # TODO: does dvips ever fail? + if targets.has_key ('PS'): + run_dvips (outbase, extra) + + if outdir != '.' and (track_dependencies_p or targets.keys ()): system ('mkdir -p %s' % outdir) - - #if re.match ('.*[.]dvi', string.join (os.listdir ('.'))): - if os.path.isfile (srcname): - # huh, and what bout all other (-1, -2) scores? - system ('cp \"%s\" \"%s\"' % (srcname, dest)) - else: - dest = 0 - if re.match ('.*[.]midi', string.join (os.listdir ('.'))): - system ('cp *.midi %s' % outdir) - else: - midi = 0 - - depfile = os.path.join (outdir, base + '.dep') + # add DEP to targets? if track_dependencies_p: - generate_dependency_file (depfile, dest) + depfile = os.path.join (outdir, outbase + '.dep') + generate_dependency_file (depfile, depfile) + if os.path.isfile (depfile): + progress (_ ("dependencies output to %s...") % depfile) + + for i in targets.keys (): + ext = string.lower (i) + if re.match ('.*[.]%s' % ext, string.join (os.listdir ('.'))): + system ('cp *.%s %s' % (ext, outdir)) + outname = outbase + '.' + string.lower (i) + abs = os.path.join (outdir, outname) + if reldir != '.': + outname = os.path.join (reldir, outname) + if os.path.isfile (abs): + progress (_ ("%s output to %s...") % (i, outname)) + elif verbose_p: + warning (_ ("can't find file: `%s'") % outname) os.chdir (original_dir) cleanup_temp () - - # most insteresting info last - # don't say silly things - if os.path.isfile (depfile): - progress (_ ("dependencies output to %s...") % depfile) - if dest and os.path.isfile (dest): - progress (_ ("%s output to %s...") % (type, dest)) - if midi and os.path.isfile (midi): - progress (_ ("%s output to %s...") % ('MIDI', midi)) + +else: + # FIXME + help () + sys.stderr.write ('\n') + try: + error (_ ("no FILEs specified, can't invoke as filter")) + except: + pass + sys.exit (2)