summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael E Brown <mebrown@michaels-house.net>2007-10-31 03:34:31 -0500
committerMichael E Brown <mebrown@michaels-house.net>2007-10-31 03:34:31 -0500
commit397b60db6e3ebf48802b4fbec0af5f531102a930 (patch)
tree4ff4005acfb05c2c5f8253049bf67a9bc10a21c1
parentb2303e57b18ab9fcad7442508dc20f62a23e306e (diff)
downloadmock-397b60db6e3ebf48802b4fbec0af5f531102a930.tar.gz
mock-397b60db6e3ebf48802b4fbec0af5f531102a930.tar.xz
mock-397b60db6e3ebf48802b4fbec0af5f531102a930.zip
use symlink vs creating a shell script. more scalable and we can cache more types of cc invokations.mock-0.8.5
-rw-r--r--src/py-libs/plugins/ccache.py28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/py-libs/plugins/ccache.py b/src/py-libs/plugins/ccache.py
index c72bccc..be536b2 100644
--- a/src/py-libs/plugins/ccache.py
+++ b/src/py-libs/plugins/ccache.py
@@ -56,20 +56,18 @@ class CCache(object):
os.environ['PATH'] = "/tmp/ccache:%s" % (os.environ['PATH'])
os.environ['CCACHE_DIR'] = "/tmp/ccache"
os.environ['CCACHE_UMASK'] = "002"
- self._dumpToFile(os.path.join(self.ccachePath, "cc"),
- '#!/bin/sh\nexec ccache /usr/bin/cc "$@"\n', mode=0555)
- self._dumpToFile(os.path.join(self.ccachePath, "gcc"),
- '#!/bin/sh\nexec ccache /usr/bin/gcc "$@"\n', mode=0555)
- self._dumpToFile(os.path.join(self.ccachePath, "g++"),
- '#!/bin/sh\nexec ccache /usr/bin/g++ "$@"\n', mode=0555)
-
- @traceLog(moduleLog)
- def _dumpToFile(self, filename, contents, *args, **kargs):
- fd = open(filename, "w+")
- fd.write(contents)
- fd.close()
- mode = kargs.get("mode", None)
- if mode is not None:
- os.chmod(filename, mode)
+ for i in ("cc", "gcc", "gcc296", "gcc32", "gcc33", "gcc34",
+ "g++", "c++", "c++32", "c++33", "c++34", "g++296", "g++32", "g++33", "g++34",
+ "g++-libstdc++-so_7",):
+ forceLink("/usr/bin/ccache", os.path.join(self.ccachePath, "%s" % i))
+ forceLink("/usr/bin/ccache", os.path.join(self.ccachePath, "x86_64-redhat-linux-%s" % i))
+ forceLink("/usr/bin/ccache", os.path.join(self.ccachePath, "i386-redhat-linux-%s" % i))
+@traceLog(moduleLog)
+def forceLink( existing, linkname ):
+ try:
+ os.unlink(linkname)
+ except OSError:
+ pass
+ os.symlink(existing, linkname)