diff options
| -rw-r--r-- | clang/tools/ccc/ccclib/Arguments.py | 2 | ||||
| -rw-r--r-- | clang/tools/ccc/ccclib/ToolChain.py | 15 | ||||
| -rw-r--r-- | clang/tools/ccc/ccclib/Tools.py | 37 |
3 files changed, 46 insertions, 8 deletions
diff --git a/clang/tools/ccc/ccclib/Arguments.py b/clang/tools/ccc/ccclib/Arguments.py index 97564558a61..a3c25f197be 100644 --- a/clang/tools/ccc/ccclib/Arguments.py +++ b/clang/tools/ccc/ccclib/Arguments.py @@ -556,7 +556,7 @@ class OptionParser: self.addOption(JoinedOrSeparateOption('-idirafter', self.iGroup)) self.addOption(JoinedOrSeparateOption('-iquote', self.iGroup)) self.isysrootOption = self.addOption(JoinedOrSeparateOption('-isysroot', self.iGroup)) - self.addOption(JoinedOrSeparateOption('-include', self.iGroup)) + self.includeOption = self.addOption(JoinedOrSeparateOption('-include', self.iGroup)) self.addOption(JoinedOption('-i', self.iGroup)) self.keep_private_externsOption = self.addOption(JoinedOrSeparateOption('-keep_private_externs')) diff --git a/clang/tools/ccc/ccclib/ToolChain.py b/clang/tools/ccc/ccclib/ToolChain.py index 083ce38e58b..85113285120 100644 --- a/clang/tools/ccc/ccclib/ToolChain.py +++ b/clang/tools/ccc/ccclib/ToolChain.py @@ -76,12 +76,15 @@ class Darwin_X86_ToolChain(ToolChain): def selectTool(self, action): assert isinstance(action, Phases.JobAction) - if (self.driver.cccClang and - self.archName == 'i386' and - action.inputs[0].type in (Types.CType, Types.CTypeNoPP, - Types.ObjCType, Types.ObjCTypeNoPP) and - isinstance(action.phase, Phases.CompilePhase)): - return self.clangTool + if self.driver.cccClang and self.archName == 'i386': + if (action.inputs[0].type in (Types.CType, Types.CTypeNoPP, + Types.ObjCType, Types.ObjCTypeNoPP) and + isinstance(action.phase, Phases.CompilePhase)): + return self.clangTool + elif (action.inputs[0].type in (Types.CHeaderType, Types.CHeaderNoPPType, + Types.ObjCHeaderType, Types.ObjCHeaderNoPPType) and + isinstance(action.phase, Phases.PrecompilePhase)): + return self.clangTool return self.toolMap[action.phase.__class__] diff --git a/clang/tools/ccc/ccclib/Tools.py b/clang/tools/ccc/ccclib/Tools.py index 3341287a85d..a12c84a1551 100644 --- a/clang/tools/ccc/ccclib/Tools.py +++ b/clang/tools/ccc/ccclib/Tools.py @@ -183,10 +183,28 @@ class Clang_CompileTool(Tool): output, outputType, arglist): cmd_args = [] + patchOutputNameForPTH = False if output is None: cmd_args.append('-fsyntax-only') elif outputType is Types.AsmTypeNoPP: cmd_args.append('-S') + elif outputType is Types.PCHType: + # No special option needed, driven by -x. However, we + # patch the output name to try and not conflict with gcc. + patchOutputNameForPTH = True + + # FIXME: This is a total hack. Copy the input header file + # to the output, so that it can be -include'd by clang. + assert len(inputs) == 1 + assert not isinstance(output, Jobs.PipedJob) + assert not isinstance(inputs[0].source, Jobs.PipedJob) + inputPath = arglist.getValue(inputs[0].source) + outputPath = os.path.join(os.path.dirname(arglist.getValue(output)), + os.path.basename(inputPath)) + # Only do copy when the output doesn't exist. + if not os.path.exists(outputPath): + import shutil + shutil.copyfile(inputPath, outputPath) else: raise ValueError,"Unexpected output type for clang tool." @@ -205,6 +223,13 @@ class Clang_CompileTool(Tool): # FIXME: Clang isn't going to accept just anything here. arglist.addAllArgs(cmd_args, arglist.parser.iGroup) + # Automatically load .pth files which match -include options. + for arg in arglist.getArgs(arglist.parser.includeOption): + pthPath = arglist.getValue(arg) + '.pth' + if os.path.exists(pthPath): + cmd_args.append('-token-cache') + cmd_args.append(pthPath) + # FIXME: Dehardcode this. cmd_args.append('-fblocks') @@ -228,7 +253,17 @@ class Clang_CompileTool(Tool): if arch is not None: cmd_args.extend(arglist.render(arch)) - cmd_args.extend(arglist.render(output)) + if isinstance(output, Jobs.PipedJob): + cmd_args.extend(['-o', '-']) + else: + if patchOutputNameForPTH: + base,suffix = os.path.splitext(arglist.getValue(output)) + if suffix == '.gch': + suffix = '.pth' + cmd_args.append('-o') + cmd_args.append(base + suffix) + else: + cmd_args.extend(arglist.render(output)) for input in inputs: cmd_args.append('-x') |

