Resending since it looks like the previous message fell through the cracks.

The attached patch is not complete, but it adds enough features and
fixes to let distcc pump build a slightly patched version of firefox
on OS X.

What the patch does is

* add support for -isysroot and -arch
* 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

Cheers,
Rafael
Index: include_server/include_analyzer.py
===================================================================
--- include_server/include_analyzer.py  (revision 750)
+++ include_server/include_analyzer.py  (working copy)
@@ -83,7 +83,8 @@
     # 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 @@
     # 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)
 
     forcing_files = self._ForceDirectoriesToExist()
 
Index: include_server/parse_command.py
===================================================================
--- include_server/parse_command.py     (revision 750)
+++ include_server/parse_command.py     (working copy)
@@ -51,7 +51,7 @@
     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,11 @@
   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):
+    # FIXME: Is this the correct precedence for isysroot and sysroot?
+    if self.sysroot:
+      return self.sysroot
+    return self.isysroot
 
 def _SplitMacroArg(arg):
   """Split an arg as found in -Darg
@@ -96,6 +101,7 @@
   '-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 +110,12 @@
                                       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 +452,8 @@
     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 +470,10 @@
   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)
Index: include_server/compress_files.py
===================================================================
--- include_server/compress_files.py    (revision 750)
+++ include_server/compress_files.py    (working copy)
@@ -27,7 +27,7 @@
 
 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 @@
     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 @@
         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))
__
distcc mailing list            http://distcc.samba.org/
To unsubscribe or change options:
https://lists.samba.org/mailman/listinfo/distcc

Reply via email to