summaryrefslogtreecommitdiffstats
path: root/clang/tools/ccc/ccclib/ToolChain.py
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-01-10 02:07:54 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-01-10 02:07:54 +0000
commitcb8d7e131cfb06cb251c2ddceddf83f9cb5bc57d (patch)
tree85245d311e2db8e44b3dedd529a893069a287cc9 /clang/tools/ccc/ccclib/ToolChain.py
parenteacf5b174dd6e7b910a84cd88be5580ff8277e3c (diff)
downloadbcm5719-llvm-cb8d7e131cfb06cb251c2ddceddf83f9cb5bc57d.tar.gz
bcm5719-llvm-cb8d7e131cfb06cb251c2ddceddf83f9cb5bc57d.zip
ccc: Introduce ToolChains for mapping Actions to Tools which can
perform them. - A ToolChain is a coherent set of tools use in a compilation process. The idea is that a ToolChain holds roughly the information (specs, search paths, etc.) that is in a single gcc binary. - The default ToolChain is selected by the host and will generally correspond to what the default system compiler would do. However, this can be over-riden for a variety of purposes, for example the by the driver driver or for testing. llvm-svn: 62021
Diffstat (limited to 'clang/tools/ccc/ccclib/ToolChain.py')
-rw-r--r--clang/tools/ccc/ccclib/ToolChain.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/clang/tools/ccc/ccclib/ToolChain.py b/clang/tools/ccc/ccclib/ToolChain.py
new file mode 100644
index 00000000000..46146b5eae4
--- /dev/null
+++ b/clang/tools/ccc/ccclib/ToolChain.py
@@ -0,0 +1,50 @@
+import Phases
+import Tools
+
+###
+
+class ToolChain(object):
+ """ToolChain - Provide mappings of Actions to Tools."""
+
+ def __init__(self, driver):
+ self.driver = driver
+
+ def selectTool(self, action):
+ """selectTool - Return a Tool instance to use for handling
+ some particular action."""
+ abstract
+
+class Darwin_ToolChain(ToolChain):
+ def __init__(self, driver):
+ super(Darwin_ToolChain, self).__init__(driver)
+ self.toolMap = {
+ Phases.PreprocessPhase : Tools.GCC_PreprocessTool(),
+ Phases.CompilePhase : Tools.GCC_CompileTool(),
+ Phases.PrecompilePhase : Tools.GCC_PrecompileTool(),
+ Phases.AssemblePhase : Tools.DarwinAssembleTool(),
+ Phases.LinkPhase : Tools.Collect2Tool(),
+ Phases.LipoPhase : Tools.LipoTool(),
+ }
+
+ def selectTool(self, action):
+ assert isinstance(action, Phases.JobAction)
+ return self.toolMap[action.phase.__class__]
+
+class Generic_GCC_ToolChain(ToolChain):
+ """Generic_GCC_ToolChain - A tool chain using the 'gcc' command to
+ perform all subcommands; this relies on gcc translating the
+ options appropriately."""
+
+ def __init__(self, driver):
+ super(Generic_GCC_ToolChain, self).__init__(driver)
+ self.toolMap = {
+ Phases.PreprocessPhase : Tools.GCC_PreprocessTool(),
+ Phases.CompilePhase : Tools.GCC_CompileTool(),
+ Phases.PrecompilePhase : Tools.GCC_PrecompileTool(),
+ Phases.AssemblePhase : Tools.GCC_AssembleTool(),
+ Phases.LinkPhase : Tools.GCC_LinkTool(),
+ }
+
+ def selectTool(self, action):
+ assert isinstance(action, Phases.JobAction)
+ return self.toolMap[action.phase.__class__]
OpenPOWER on IntegriCloud