From 2b8f3241e3c840434fc675e6974ca5bf8dc3fd93 Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer Date: Sun, 16 Nov 2008 19:16:03 +0100 Subject: [PATCH] lilypond-book: Pass lilypond version to lilypond-book via env var in makefiles When lilypond-book.py is called from our makefiles to build the documentation, the @TOPLEVEL_VERSION@ string has not been expanded and the lilypond version will not be available to lilypond-book. This patch detects this case and uses the LILYPOND_VERSION environment variable in that case, which is passed to lilypond-book.py by the makefiles. --- make/ly-rules.make | 6 +++--- scripts/lilypond-book.py | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/make/ly-rules.make b/make/ly-rules.make index 4908997f9d..c8605a3173 100644 --- a/make/ly-rules.make +++ b/make/ly-rules.make @@ -5,7 +5,7 @@ LYS_OUTPUT_OPTION= --lily-output-dir $(LYS_OUTPUT_DIR) LYS_OUTPUT_DIR=$(top-build-dir)/out/lybook-db/ LILYPOND_BOOK_FLAGS += $(LYS_OUTPUT_OPTION) $(outdir)/%.latex: %.doc - $(PYTHON) $(LILYPOND_BOOK) $(LILYPOND_BOOK_INCLUDES) --process='$(LILYPOND_BOOK_PROCESS) $(LILYPOND_BOOK_LILYPOND_FLAGS)' --output=$(outdir) $(LILYPOND_BOOK_FLAGS) $< + LILYPOND_VERSION=$(TOPLEVEL_VERSION) $(PYTHON) $(LILYPOND_BOOK) $(LILYPOND_BOOK_INCLUDES) --process='$(LILYPOND_BOOK_PROCESS) $(LILYPOND_BOOK_LILYPOND_FLAGS)' --output=$(outdir) $(LILYPOND_BOOK_FLAGS) $< # This allows -j make option while making sure only one lilypond-book instance @@ -20,11 +20,11 @@ $(eval $(firstword $(MASTER_TEXI_FILES)): $(foreach i, $(wordlist 2, $(words $(M # don't do ``cd $(outdir)'', and assume that $(outdir)/.. is the src dir. # it is not, for --srcdir builds $(outdir)/%.texi: %.tely $(outdir)/version.itexi $(DOCUMENTATION_LOCALE_TARGET) - $(PYTHON) $(LILYPOND_BOOK) $(LILYPOND_BOOK_INCLUDES) --process='$(LILYPOND_BOOK_PROCESS) $(LILYPOND_BOOK_LILYPOND_FLAGS)' --output=$(outdir) --format=$(LILYPOND_BOOK_FORMAT) $(LILYPOND_BOOK_FLAGS) $< + LILYPOND_VERSION=$(TOPLEVEL_VERSION) $(PYTHON) $(LILYPOND_BOOK) $(LILYPOND_BOOK_INCLUDES) --process='$(LILYPOND_BOOK_PROCESS) $(LILYPOND_BOOK_LILYPOND_FLAGS)' --output=$(outdir) --format=$(LILYPOND_BOOK_FORMAT) $(LILYPOND_BOOK_FLAGS) $< $(outdir)/%.texi: $(outdir)/%.tely $(outdir)/version.itexi $(DOCUMENTATION_LOCALE_TARGET) - $(PYTHON) $(LILYPOND_BOOK) $(LILYPOND_BOOK_INCLUDES) --process='$(LILYPOND_BOOK_PROCESS) $(LILYPOND_BOOK_INCLUDES) $(LILYPOND_BOOK_LILYPOND_FLAGS)' --output=$(outdir) --format=$(LILYPOND_BOOK_FORMAT) $(LILYPOND_BOOK_FLAGS) $< + LILYPOND_VERSION=$(TOPLEVEL_VERSION) $(PYTHON) $(LILYPOND_BOOK) $(LILYPOND_BOOK_INCLUDES) --process='$(LILYPOND_BOOK_PROCESS) $(LILYPOND_BOOK_INCLUDES) $(LILYPOND_BOOK_LILYPOND_FLAGS)' --output=$(outdir) --format=$(LILYPOND_BOOK_FORMAT) $(LILYPOND_BOOK_FLAGS) $< $(outdir)/%.html.omf: %.tely diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py index 9998f1ceec..d42a77a787 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -51,6 +51,17 @@ ly.require_python_version () program_version = '@TOPLEVEL_VERSION@' program_name = os.path.basename (sys.argv[0]) +# Check if program_version contains @ characters. This will be the case if +# the .py file is called directly while building the lilypond documentation. +# If so, try to check for the env var LILYPOND_VERSION, which is set by our +# makefiles and use its value. +at_re = re.compile (r'@') +if at_re.match (program_version): + if os.environ.has_key('LILYPOND_VERSION'): + program_version = os.environ['LILYPOND_VERSION'] + else: + program_version = "unknown" + original_dir = os.getcwd () backend = 'ps' -- 2.39.5