summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorJean-Charles Malahieude <lilyfan@orange.fr>2014-08-31 12:24:26 +0200
committerJean-Charles Malahieude <lilyfan@orange.fr>2014-08-31 12:24:26 +0200
commit324ff94afc62c7011b7377f24392f95391ed3b84 (patch)
treed84453c4ca9000fee657347758ccdded780ffaa1 /scripts
parent59edf02a1acae41e21a080617aa7bd8673125762 (diff)
parent5e7ba357ed642cad2e07f53d8c27d96128fe7dab (diff)
Merge branch 'master' of /home/jcharles/GIT/Lily/. into translation
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/auxiliar/update-with-convert-ly.sh2
-rw-r--r--scripts/lilypond-book.py35
2 files changed, 25 insertions, 12 deletions
diff --git a/scripts/auxiliar/update-with-convert-ly.sh b/scripts/auxiliar/update-with-convert-ly.sh
index 7f40b63fb8..bb51d83e41 100755
--- a/scripts/auxiliar/update-with-convert-ly.sh
+++ b/scripts/auxiliar/update-with-convert-ly.sh
@@ -14,7 +14,7 @@ fi
### make sure convert-ly is up-to-date
cd $BUILD_DIR
-make pythonmodules
+make python-modules
cd $TOP_SRC_DIR
### update manuals
diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py
index 9cdd14742b..f38fb4f7e3 100644
--- a/scripts/lilypond-book.py
+++ b/scripts/lilypond-book.py
@@ -417,7 +417,7 @@ def process_snippets (cmd, snippets,
logfile = name.replace('.ly', '')
file (name, 'wb').write (contents)
- system_in_directory (' '.join ([cmd, ly.mkarg (name)]),
+ system_in_directory (' '.join ([cmd, ly.mkarg (name.replace (os.path.sep, '/'))]),
lily_output_dir,
logfile)
@@ -621,12 +621,25 @@ def do_file (input_filename, included=False):
progress (_ ("Removing `%s'") % output_filename)
raise BookSnippet.CompileError
+def adjust_include_path (path, outpath):
+ """Rewrite an include path relative to the dir where lilypond is launched.
+ Always use forward slashes since this is what lilypond expects."""
+ path = os.path.expanduser (path)
+ path = os.path.expandvars (path)
+ path = os.path.normpath (path)
+ if os.path.isabs (outpath):
+ return os.path.abspath (path).replace (os.path.sep, '/')
+ if os.path.isabs (path):
+ return path.replace (os.path.sep, '/')
+ return os.path.join (inverse_relpath (original_dir, outpath), path).replace (os.path.sep, '/')
+
def inverse_relpath (path, relpath):
"""Given two paths, the second relative to the first,
- return the first path relative to the second."""
+ return the first path relative to the second.
+ Always use forward slashes since this is what lilypond expects."""
if os.path.isabs (relpath):
- return os.path.abspath (path)
- relparts = []
+ return os.path.abspath (path).replace (os.path.sep, '/')
+ relparts = ['']
parts = os.path.normpath (path).split (os.path.sep)
for part in os.path.normpath (relpath).split (os.path.sep):
if part == '..':
@@ -635,7 +648,7 @@ def inverse_relpath (path, relpath):
else:
relparts.append ('..')
parts.append (part)
- return os.path.sep.join (relparts[::-1])
+ return '/'.join (relparts[::-1])
def do_options ():
global global_options
@@ -648,13 +661,17 @@ def do_options ():
if global_options.lily_output_dir:
global_options.lily_output_dir = os.path.expanduser (global_options.lily_output_dir)
+ for i, path in enumerate(global_options.include_path):
+ global_options.include_path[i] = adjust_include_path (path, global_options.lily_output_dir)
global_options.include_path.insert (0, inverse_relpath (original_dir, global_options.lily_output_dir))
- if global_options.output_dir:
+ elif global_options.output_dir:
global_options.output_dir = os.path.expanduser (global_options.output_dir)
+ for i, path in enumerate(global_options.include_path):
+ global_options.include_path[i] = adjust_include_path (path, global_options.output_dir)
global_options.include_path.insert (0, inverse_relpath (original_dir, global_options.output_dir))
- global_options.include_path.insert (0, ".")
+ global_options.include_path.insert (0, "./")
# Load the python packages (containing e.g. custom formatter classes)
# passed on the command line
@@ -701,10 +718,6 @@ def main ():
if global_options.process_cmd:
includes = global_options.include_path
- if global_options.lily_output_dir:
- # This must be first, so lilypond prefers to read .ly
- # files in the other lybookdb dir.
- includes = [global_options.lily_output_dir] + includes
global_options.process_cmd += ' '.join ([' -I %s' % ly.mkarg (p)
for p in includes])