]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-book: Pass lilypond version to lilypond-book via env var in makefiles
authorReinhold Kainhofer <reinhold@kainhofer.com>
Sun, 16 Nov 2008 18:16:03 +0000 (19:16 +0100)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Sun, 16 Nov 2008 20:29:20 +0000 (21:29 +0100)
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
scripts/lilypond-book.py

index 4908997f9d83074b1fbc120fc909a8cc0ad4bfe4..c8605a3173962384fa39dbe9895524012f24079b 100644 (file)
@@ -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
index 9998f1ceec367277a181091b4646479e1c3c2af1..d42a77a78760c551d5b5ec76d38766ee35be878b 100644 (file)
@@ -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'