-
Notifications
You must be signed in to change notification settings - Fork 83
Support CLCACHE_BASEDIR in nodirect mode #349
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -469,6 +469,11 @@ def computeKeyNodirect(compilerBinary, commandLine, environment): | |
| compilerHash = getCompilerHash(compilerBinary) | ||
| normalizedCmdLine = CompilerArtifactsRepository._normalizedCommandLine(commandLine) | ||
|
|
||
| if "CLCACHE_BASEDIR" in os.environ: | ||
| baseDir = normalizeBaseDir(os.environ["CLCACHE_BASEDIR"]).replace("\\", "\\\\").encode("UTF-8") | ||
| newBaseDir = BASEDIR_REPLACEMENT.encode("UTF-8") | ||
| preprocessedSourceCode = re.sub(re.escape(baseDir), newBaseDir, preprocessedSourceCode, flags=re.IGNORECASE) | ||
|
|
||
| h = HashAlgorithm() | ||
| h.update(compilerHash.encode("UTF-8")) | ||
| h.update(' '.join(normalizedCmdLine).encode("UTF-8")) | ||
|
|
@@ -495,7 +500,7 @@ def _normalizedCommandLine(cmdline): | |
| argsToStrip += ("MP",) | ||
|
|
||
| return [arg for arg in cmdline | ||
| if not (arg[0] in "/-" and arg[1:].startswith(argsToStrip))] | ||
| if arg[0] in "/-" and not arg[1:].startswith(argsToStrip)] | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, did you mean to change the behaviour here? I suspect the That being said, I'm not sure the new version is any nicer than the old one, so maybe it's not worth touching this at all.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I only now noticed that you meant to fix a bug here. In that case, can you please add a test case which demonstrates the bug?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| class CacheFileStrategy: | ||
| def __init__(self, cacheDirectory=None): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| #include <iostream> | ||
|
|
||
| int main() | ||
| { | ||
| std::cout << __FILE__ << '\n'; | ||
| } | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, why are backslashes escaped here?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's to match the backslashes that are escaped in the preprocessor output because
__FILE__expands to a C string literal.