X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scripts%2Flilypond-book.py;h=903e5e522176b6a31b97a1edd424ae1179dda3a5;hb=2f7fe0c6bc80ad57ae73e213f9b20bc9719ba2ce;hp=395551ca0519f7fea206f9e62f461676be763615;hpb=549e872c56daec6ec4cf1b0a90fc6c8e58428417;p=lilypond.git diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py index 395551ca05..903e5e5221 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -464,12 +464,15 @@ def do_process_cmd (chunks, input_name, options): else: progress (_ ("All snippets are up to date...")) - if options.lily_output_dir != options.output_dir: - output_files = split_output_files (options.lily_output_dir) + progress (_ ("Linking files...")) + abs_lily_output_dir = os.path.join (options.original_dir, options.lily_output_dir) + abs_output_dir = os.path.join (options.original_dir, options.output_dir) + if abs_lily_output_dir != abs_output_dir: + output_files = split_output_files (abs_lily_output_dir) for snippet in snippets: - snippet.link_all_output_files (options.lily_output_dir, + snippet.link_all_output_files (abs_lily_output_dir, output_files, - options.output_dir) + abs_output_dir) ### @@ -608,6 +611,22 @@ def do_file (input_filename, included=False): progress (_ ("Removing `%s'") % output_filename) raise BookSnippet.CompileError +def inverse_relpath (path, relpath): + """Given two paths, the second relative to the first, + return the first path relative to the second.""" + if os.path.isabs (relpath): + return os.path.abspath (path) + relparts = [] + parts = os.path.normpath (path).split (os.path.sep) + for part in os.path.normpath (relpath).split (os.path.sep): + if part == '..': + relparts.append (parts[-1]) + parts.pop () + else: + relparts.append ('..') + parts.append (part) + return os.path.sep.join (relparts[::-1]) + def do_options (): global global_options @@ -617,12 +636,22 @@ def do_options (): global_options.information = {'program_version': ly.program_version, 'program_name': ly.program_name } global_options.original_dir = original_dir + if global_options.lily_output_dir: + global_options.lily_output_dir = os.path.expanduser (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: + global_options.output_dir = os.path.expanduser (global_options.output_dir) + global_options.include_path.insert (0, inverse_relpath (original_dir, global_options.output_dir)) + + global_options.include_path.insert (0, ".") + # Load the python packages (containing e.g. custom formatter classes) # passed on the command line nr = 0 for i in global_options.custom_packages: nr += 1 - print imp.load_source ("book_custom_package%s" % nr, i) + progress (str(imp.load_source ("book_custom_package%s" % nr, i))) if global_options.warranty: