diff options
author | fergus.henderson@gmail.com <fergus.henderson@gmail.com@01de4be4-8c4a-0410-9132-4925637da917> | 2014-02-27 13:46:06 +0000 |
---|---|---|
committer | fergus.henderson@gmail.com <fergus.henderson@gmail.com@01de4be4-8c4a-0410-9132-4925637da917> | 2014-02-27 13:46:06 +0000 |
commit | 103c6bb0d4e6318302a53161746a1a92122d0a6e (patch) | |
tree | cdf90b83da54aa3abe7f94ab0f2d578bedd7078f | |
parent | a195f2735e782a25bd690d7f19a539bf619676b8 (diff) | |
download | distcc-103c6bb0d4e6318302a53161746a1a92122d0a6e.tar.gz |
Apply patch from Rafael Ávila de Espíndola <rafael.espindola@gmail.com>:
1. Add support for -isysroot and -arch.
2. Fix a really nasty corner case:
- CompressFiles::Compress uses os.makedirs to create a directory (foo)
for one compilation unit
- Another compilation unit does the equivalent of '#include
"foo/../bar.h"'
- The compilation unit uses no other file in foo
- We conclude that we don't have to create a dummy
foo/forcing_technique_271828
git-svn-id: http://distcc.googlecode.com/svn/trunk@783 01de4be4-8c4a-0410-9132-4925637da917
-rwxr-xr-x | include_server/compress_files.py | 8 | ||||
-rwxr-xr-x | include_server/include_analyzer.py | 6 | ||||
-rwxr-xr-x | include_server/parse_command.py | 16 |
3 files changed, 19 insertions, 11 deletions
diff --git a/include_server/compress_files.py b/include_server/compress_files.py index c286c6c..20512fd 100755 --- a/include_server/compress_files.py +++ b/include_server/compress_files.py @@ -27,7 +27,7 @@ import distcc_pump_c_extensions class CompressFiles(object): - def __init__(self, includepath_map, directory_map, realpath_map): + def __init__(self, includepath_map, directory_map, realpath_map, mirror_path): """Constructor. Arguments: @@ -38,10 +38,11 @@ class CompressFiles(object): self.includepath_map = includepath_map self.directory_map = directory_map self.realpath_map = realpath_map + self.mirror_path = mirror_path # The realpath_map indices of files that have been compressed already. self.files_compressed = set([]) - def Compress(self, include_closure, client_root_keeper): + def Compress(self, include_closure, client_root_keeper, currdir_idx): """Copy files in include_closure to the client_root directory, compressing them as we go, and also inserting #line directives. @@ -77,7 +78,8 @@ class CompressFiles(object): dirname = os.path.dirname(new_filepath) try: if not os.path.isdir(dirname): - os.makedirs(dirname) + my_root = client_root_keeper.client_root + self.mirror_path.DoPath(realpath, currdir_idx, my_root) except (IOError, OSError), why: # Kill include server sys.exit("Could not make directory '%s': %s" % (dirname, why)) diff --git a/include_server/include_analyzer.py b/include_server/include_analyzer.py index 2c0fa5c..450b593 100755 --- a/include_server/include_analyzer.py +++ b/include_server/include_analyzer.py @@ -83,7 +83,8 @@ class IncludeAnalyzer(object): # Make a compressor for source files. self.compress_files = compress_files.CompressFiles(self.includepath_map, self.directory_map, - self.realpath_map) + self.realpath_map, + self.mirror_path) # A fast cache for avoiding calls into the mirror_path object. self.mirrored = set([]) @@ -269,7 +270,8 @@ class IncludeAnalyzer(object): # handful. We add put the system links first, because there should be very # few of them. links = self.compiler_defaults.system_links + self.mirror_path.Links() - files = self.compress_files.Compress(include_closure, client_root_keeper) + files = self.compress_files.Compress(include_closure, client_root_keeper, + self.currdir_idx) files_and_links = files + links diff --git a/include_server/parse_command.py b/include_server/parse_command.py index 5b420ac..718affd 100755 --- a/include_server/parse_command.py +++ b/include_server/parse_command.py @@ -51,7 +51,7 @@ class ParseState: self.after_system_dirs = [] self.language = 'none' # equivalent to commandline of '-x none' - self.isysroot = None + self.isysroot = "" self.sysroot = "" self.output_file = None self.iprefix = "" @@ -63,6 +63,8 @@ class ParseState: def set_sysroot(self, x): self.sysroot = x def set_outputfile(self, x): self.output_file = x def set_iprefix(self, x): self.iprefix = x + def include_sysroot(self): + return self.isysroot if self.isysroot else self.sysroot def _SplitMacroArg(arg): """Split an arg as found in -Darg @@ -96,6 +98,7 @@ CPP_OPTIONS_MAYBE_TWO_WORDS = { '-MF': lambda ps, arg: None, '-MT': lambda ps, arg: None, '-MQ': lambda ps, arg: None, + '-arch': lambda ps, arg: None, '-include': lambda ps, arg: ps.include_files.append(arg), '-imacros': lambda ps, arg: ps.include_files.append(arg), '-idirafter': lambda ps, arg: ps.after_system_dirs.append(arg), @@ -104,13 +107,12 @@ CPP_OPTIONS_MAYBE_TWO_WORDS = { os.path.join(ps.iprefix, arg)), '-iwithprefixbefore': lambda ps, arg: ps.i_dirs.append( os.path.join(ps.iprefix, arg)), -# '-isysroot': lambda ps, arg: ps.set_isysroot(arg), - '-isysroot': lambda ps, arg: _RaiseNotImplemented('-isysroot'), + '-isysroot': lambda ps, arg: ps.set_isysroot(arg), '-imultilib': lambda ps, arg: _RaiseNotImplemented('-imultilib'), '-isystem': lambda ps, arg: ps.before_system_dirs.append(arg), '-iquote': lambda ps, arg: ps.quote_dirs.append(arg), } -CPP_OPTIONS_MAYBE_TWO_WORDS_FIRST_LETTERS = ('M', 'i', '-') +CPP_OPTIONS_MAYBE_TWO_WORDS_FIRST_LETTERS = ('M', 'i', '-', 'a') # A "compile-time" check to make sure the first-letter list is up-to-date for key in CPP_OPTIONS_MAYBE_TWO_WORDS.keys(): assert key[1] in CPP_OPTIONS_MAYBE_TWO_WORDS_FIRST_LETTERS @@ -447,7 +449,8 @@ def ParseCommandArgs(args, current_dir, includepath_map, dir_map, parse_state.language = basics.TRANSLATION_UNIT_MAP[suffix] assert parse_state.language in basics.LANGUAGES - compiler_defaults.SetSystemDirsDefaults(compiler, parse_state.sysroot, + sysroot = parse_state.include_sysroot() + compiler_defaults.SetSystemDirsDefaults(compiler, sysroot, parse_state.language, timer) def IndexDirs(dir_list): @@ -464,9 +467,10 @@ def ParseCommandArgs(args, current_dir, includepath_map, dir_map, angle_dirs = IndexDirs(parse_state.i_dirs) angle_dirs.extend(IndexDirs(parse_state.before_system_dirs)) if not parse_state.nostdinc: + sysroot = parse_state.include_sysroot() angle_dirs.extend( IndexDirs(compiler_defaults.system_dirs_default - [compiler][parse_state.sysroot][parse_state.language])) + [compiler][sysroot][parse_state.language])) angle_dirs.extend(IndexDirs(parse_state.after_system_dirs)) quote_dirs = IndexDirs(parse_state.quote_dirs) |