[ccache] Patch: Xcode compatibility

Sean Gies sean.gies at discreet.com
Fri Nov 21 23:35:11 GMT 2003


Looks like mailman ate my attachment.  Here's the patch again: <<EOT
Index: ccache.c
===================================================================
RCS file: /cvsroot/ccache/ccache.c,v
retrieving revision 1.91
diff -u -r1.91 ccache.c
--- ccache.c	28 Sep 2003 04:47:59 -0000	1.91
+++ ccache.c	21 Nov 2003 23:03:32 -0000
@@ -64,6 +64,11 @@

  /* a list of supported file extensions, and the equivalent
     extension for code that has been through the pre-processor
+	
+   i   = C
+   mi  = Objective-C
+   ii  = C++
+   mii = Objective-C++
  */
  static struct {
  	char *extension;
@@ -74,14 +79,21 @@
  	{"m", "mi"},
  	{"cc", "ii"},
  	{"CC", "ii"},
+	{"cp", "ii"},
+	{"CP", "ii"},
  	{"cpp", "ii"},
  	{"CPP", "ii"},
  	{"cxx", "ii"},
  	{"CXX", "ii"},
  	{"c++", "ii"},
  	{"C++", "ii"},
+	{"M", "mii"},
+	{"mm", "mii"},
+	{"MM", "mii"},
  	{"i", "i"},
  	{"ii", "ii"},
+	{"mi", "mi"},
+	{"mii", "mii"},
  	{NULL, NULL}};

  /*
@@ -616,6 +628,7 @@
  	int found_c_opt = 0;
  	int found_S_opt = 0;
  	struct stat st;
+	int file_missing;
  	char *e;

  	stripped_args = args_init(0, NULL);
@@ -729,11 +742,21 @@
  		/* if an argument isn't a plain file then assume its
  		   an option, not an input file. This allows us to
  		   cope better with unusual compiler options */
-		if (stat(argv[i], &st) != 0 || !S_ISREG(st.st_mode)) {
+		if ((file_missing = stat(argv[i], &st)) != 0 || 
!S_ISREG(st.st_mode)) {
  			args_add(stripped_args, argv[i]);
  			continue;			
  		}

+		/* if the first argument contains "distcc" and the second argument
+		   is a regular, executable file, then assume it's the compiler
+		   being specified to distcc:
+		      ccache distcc gcc ... */
+		if (i == 1 && strstr(argv[0], "distcc") != NULL && !file_missing &&
+		    S_ISREG(st.st_mode) && (st.st_mode & (S_IXUSR | S_IXGRP | 
S_IXOTH))) {
+			args_add(stripped_args, argv[i]);
+			continue;			
+		}
+		
  		if (input_file) {
  			if (check_extension(argv[i], NULL)) {
  				cc_log("multiple input files (%s and %s)\n",
EOT

-Sean

On Nov 21, 2003, at 3:28 PM, Sean Gies wrote:

> Here's a patch I created so that I can use ccache with Apple's Xcode 
> IDE.
>
> 1. Added more extensions to better support Objective-C and 
> Objective-C++.
>
> 2. Added a check to the argument processing logic to handle this sort 
> of invocation:
> 	/usr/share/bin/ccache /usr/bin/distcc /usr/bin/gcc-3.3 ...
>
> In order to handle multiple compiler versions, Xcode uses full paths 
> to invoke an explicit version of distcc or gcc.  This confused ccache 
> because it thought the gcc-3.3 argument to distcc was a source file.
>
> -Sean
>
> _______________________________________________
> ccache mailing list
> ccache at lists.samba.org
> http://lists.samba.org/mailman/listinfo/ccache




More information about the ccache mailing list