Daniel Dunbar | a567751 | 2009-01-05 19:53:30 +0000 | [diff] [blame] | 1 | import Util |
| 2 | |
| 3 | class Action(object): |
| 4 | def __init__(self, inputs, type): |
| 5 | self.inputs = inputs |
| 6 | self.type = type |
| 7 | |
| 8 | class 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 | |
| 20 | class 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 | |
| 31 | class 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 | |
| 45 | class 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 | |
| 63 | class PreprocessPhase(Phase): |
| 64 | def __init__(self): |
| 65 | super(PreprocessPhase, self).__init__("preprocessor", Phase.eOrderPreprocess) |
| 66 | |
| 67 | class PrecompilePhase(Phase): |
| 68 | def __init__(self): |
| 69 | super(PrecompilePhase, self).__init__("precompiler", Phase.eOrderCompile) |
| 70 | |
| 71 | class CompilePhase(Phase): |
| 72 | def __init__(self): |
| 73 | super(CompilePhase, self).__init__("compiler", Phase.eOrderCompile) |
| 74 | |
| 75 | class AssemblePhase(Phase): |
| 76 | def __init__(self): |
| 77 | super(AssemblePhase, self).__init__("assembler", Phase.eOrderAssemble) |
| 78 | |
| 79 | class LinkPhase(Phase): |
| 80 | def __init__(self): |
| 81 | super(LinkPhase, self).__init__("linker", Phase.eOrderPostAssemble) |
| 82 | |
| 83 | class LipoPhase(Phase): |
| 84 | def __init__(self): |
| 85 | super(LipoPhase, self).__init__("lipo", Phase.eOrderPostAssemble) |
| 86 | |