From 0740e39f7013de90d1ecebc0113298f22d7fd97d Mon Sep 17 00:00:00 2001 From: MikeR Date: Sun, 15 Apr 2018 20:10:38 -0700 Subject: [PATCH 1/2] adding a source base directory for people who have separate build and source locations --- clcache.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/clcache.py b/clcache.py index 896d6356..b2d2d25b 100644 --- a/clcache.py +++ b/clcache.py @@ -63,6 +63,7 @@ # ? is invalid character for file name, so it seems ok # to use it as mark for relative path. BASEDIR_REPLACEMENT = '?' +SOURCEDIR_REPLACEMENT = '*' # Define some Win32 API constants here to avoid dependency on win32pipe NMPWAIT_WAIT_FOREVER = wintypes.DWORD(0xFFFFFFFF) @@ -271,8 +272,10 @@ def getManifestHash(compilerBinary, commandLine, sourceFile): commandLine.extend(collapseBasedirInCmdPath(arg) for arg in inputFiles) + printTraceStatement("Hashing commandLine: {}".format(commandLine)) additionalData = "{}|{}|{}".format( compilerHash, commandLine, ManifestRepository.MANIFEST_FILE_FORMAT_VERSION) + printTraceStatement("Hashing additionalData: {}".format(additionalData)) return getFileHash(sourceFile, additionalData) @staticmethod @@ -918,24 +921,34 @@ def getStringHash(dataString): def expandBasedirPlaceholder(path): baseDir = normalizeBaseDir(os.environ.get('CLCACHE_BASEDIR')) + sourceDir = normalizeBaseDir(os.environ.get('CLCACHE_SOURCEDIR')) if path.startswith(BASEDIR_REPLACEMENT): if not baseDir: raise LogicException('No CLCACHE_BASEDIR set, but found relative path ' + path) return path.replace(BASEDIR_REPLACEMENT, baseDir, 1) + elif path.startswith(SOURCEDIR_REPLACEMENT): + if not sourceDir: + raise LogicException('No CLCACHE_SOURCEDIR set, but found relative path ' + path) + return path.replace(SOURCEDIR_REPLACEMENT, sourceDir, 1) else: return path def collapseBasedirToPlaceholder(path): baseDir = normalizeBaseDir(os.environ.get('CLCACHE_BASEDIR')) - if baseDir is None: + sourceDir = normalizeBaseDir(os.environ.get('CLCACHE_SOURCEDIR')) + if baseDir is None and sourceDir is None: return path else: assert path == os.path.normcase(path) + if not baseDir is None: assert baseDir == os.path.normcase(baseDir) if path.startswith(baseDir): return path.replace(baseDir, BASEDIR_REPLACEMENT, 1) - else: + if not sourceDir is None: + assert sourceDir == os.path.normcase(sourceDir) + if path.startswith(sourceDir): + return path.replace(sourceDir, SOURCEDIR_REPLACEMENT, 1) return path From 91b688c165354e751d7cefc034f4316050738f41 Mon Sep 17 00:00:00 2001 From: MikeR Date: Mon, 16 Apr 2018 10:07:31 -0700 Subject: [PATCH 2/2] fix indentation --- clcache.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/clcache.py b/clcache.py index b2d2d25b..2a439b8a 100644 --- a/clcache.py +++ b/clcache.py @@ -942,14 +942,14 @@ def collapseBasedirToPlaceholder(path): else: assert path == os.path.normcase(path) if not baseDir is None: - assert baseDir == os.path.normcase(baseDir) - if path.startswith(baseDir): + assert baseDir == os.path.normcase(baseDir) + if path.startswith(baseDir): return path.replace(baseDir, BASEDIR_REPLACEMENT, 1) if not sourceDir is None: assert sourceDir == os.path.normcase(sourceDir) if path.startswith(sourceDir): return path.replace(sourceDir, SOURCEDIR_REPLACEMENT, 1) - return path + return path def ensureDirectoryExists(path):