blob: 46146b5eae42381e880ddcc4b9456092a4f8e630 [file] [log] [blame]
Daniel Dunbar43124722009-01-10 02:07:54 +00001import Phases
2import Tools
3
4###
5
6class ToolChain(object):
7 """ToolChain - Provide mappings of Actions to Tools."""
8
9 def __init__(self, driver):
10 self.driver = driver
11
12 def selectTool(self, action):
13 """selectTool - Return a Tool instance to use for handling
14 some particular action."""
15 abstract
16
17class Darwin_ToolChain(ToolChain):
18 def __init__(self, driver):
19 super(Darwin_ToolChain, self).__init__(driver)
20 self.toolMap = {
21 Phases.PreprocessPhase : Tools.GCC_PreprocessTool(),
22 Phases.CompilePhase : Tools.GCC_CompileTool(),
23 Phases.PrecompilePhase : Tools.GCC_PrecompileTool(),
24 Phases.AssemblePhase : Tools.DarwinAssembleTool(),
25 Phases.LinkPhase : Tools.Collect2Tool(),
26 Phases.LipoPhase : Tools.LipoTool(),
27 }
28
29 def selectTool(self, action):
30 assert isinstance(action, Phases.JobAction)
31 return self.toolMap[action.phase.__class__]
32
33class Generic_GCC_ToolChain(ToolChain):
34 """Generic_GCC_ToolChain - A tool chain using the 'gcc' command to
35 perform all subcommands; this relies on gcc translating the
36 options appropriately."""
37
38 def __init__(self, driver):
39 super(Generic_GCC_ToolChain, self).__init__(driver)
40 self.toolMap = {
41 Phases.PreprocessPhase : Tools.GCC_PreprocessTool(),
42 Phases.CompilePhase : Tools.GCC_CompileTool(),
43 Phases.PrecompilePhase : Tools.GCC_PrecompileTool(),
44 Phases.AssemblePhase : Tools.GCC_AssembleTool(),
45 Phases.LinkPhase : Tools.GCC_LinkTool(),
46 }
47
48 def selectTool(self, action):
49 assert isinstance(action, Phases.JobAction)
50 return self.toolMap[action.phase.__class__]