blob: 0384b8fa4fc9716607aad22fb3fd221fe163e387 [file] [log] [blame]
Daniel Dunbara5677512009-01-05 19:53:30 +00001import Util
2
3class Action(object):
4 def __init__(self, inputs, type):
5 self.inputs = inputs
6 self.type = type
7
8class BindArchAction(Action):
9 """BindArchAction - Represent an architecture binding for child
10 actions."""
11
12 def __init__(self, input, arch):
13 super(BindArchAction, self).__init__([input], input.type)
14 self.arch = arch
15
16 def __repr__(self):
17 return Util.prefixAndPPrint(self.__class__.__name__,
18 (self.inputs[0], self.arch))
19
20class InputAction(Action):
21 """InputAction - Adapt an input file to an action & type. """
22
23 def __init__(self, filename, type):
24 super(InputAction, self).__init__([], type)
25 self.filename = filename
26
27 def __repr__(self):
28 return Util.prefixAndPPrint(self.__class__.__name__,
29 (self.filename, self.type))
30
31class JobAction(Action):
32 """JobAction - Represent a job tied to a particular compilation
33 phase."""
34
35 def __init__(self, phase, inputs, type):
36 super(JobAction, self).__init__(inputs, type)
37 self.phase = phase
38
39 def __repr__(self):
40 return Util.prefixAndPPrint(self.__class__.__name__,
41 (self.phase, self.inputs, self.type))
42
43###
44
45class Phase(object):
46 """Phase - Represent an abstract task in the compilation
47 pipeline."""
48
49 eOrderNone = 0
50 eOrderPreprocess = 1
51 eOrderCompile = 2
52 eOrderAssemble = 3
53 eOrderPostAssemble = 4
54
55 def __init__(self, name, order):
56 self.name = name
57 self.order = order
58
59 def __repr__(self):
60 return Util.prefixAndPPrint(self.__class__.__name__,
61 (self.name, self.order))
62
63class PreprocessPhase(Phase):
64 def __init__(self):
65 super(PreprocessPhase, self).__init__("preprocessor", Phase.eOrderPreprocess)
66
67class PrecompilePhase(Phase):
68 def __init__(self):
69 super(PrecompilePhase, self).__init__("precompiler", Phase.eOrderCompile)
70
71class CompilePhase(Phase):
72 def __init__(self):
73 super(CompilePhase, self).__init__("compiler", Phase.eOrderCompile)
74
75class AssemblePhase(Phase):
76 def __init__(self):
77 super(AssemblePhase, self).__init__("assembler", Phase.eOrderAssemble)
78
79class LinkPhase(Phase):
80 def __init__(self):
81 super(LinkPhase, self).__init__("linker", Phase.eOrderPostAssemble)
82
83class LipoPhase(Phase):
84 def __init__(self):
85 super(LipoPhase, self).__init__("lipo", Phase.eOrderPostAssemble)
86