aboutsummaryrefslogtreecommitdiff
path: root/tools/ccc/ccclib/Phases.py
blob: 0384b8fa4fc9716607aad22fb3fd221fe163e387 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import Util

class Action(object):
    def __init__(self, inputs, type):
        self.inputs = inputs
        self.type = type

class BindArchAction(Action):
    """BindArchAction - Represent an architecture binding for child
    actions."""

    def __init__(self, input, arch):
        super(BindArchAction, self).__init__([input], input.type)
        self.arch = arch

    def __repr__(self):
        return Util.prefixAndPPrint(self.__class__.__name__,
                                    (self.inputs[0], self.arch))

class InputAction(Action):
    """InputAction - Adapt an input file to an action & type. """

    def __init__(self, filename, type):
        super(InputAction, self).__init__([], type)
        self.filename = filename

    def __repr__(self):
        return Util.prefixAndPPrint(self.__class__.__name__,
                                    (self.filename, self.type))

class JobAction(Action):
    """JobAction - Represent a job tied to a particular compilation
    phase."""

    def __init__(self, phase, inputs, type):
        super(JobAction, self).__init__(inputs, type)
        self.phase = phase

    def __repr__(self):
        return Util.prefixAndPPrint(self.__class__.__name__,
                                    (self.phase, self.inputs, self.type))

###

class Phase(object):
    """Phase - Represent an abstract task in the compilation
    pipeline."""

    eOrderNone = 0
    eOrderPreprocess = 1
    eOrderCompile = 2
    eOrderAssemble = 3
    eOrderPostAssemble = 4
    
    def __init__(self, name, order):
        self.name = name
        self.order = order

    def __repr__(self):
        return Util.prefixAndPPrint(self.__class__.__name__,
                                    (self.name, self.order))

class PreprocessPhase(Phase):
    def __init__(self):
        super(PreprocessPhase, self).__init__("preprocessor", Phase.eOrderPreprocess)

class PrecompilePhase(Phase):
    def __init__(self):
        super(PrecompilePhase, self).__init__("precompiler", Phase.eOrderCompile)

class CompilePhase(Phase):
    def __init__(self):
        super(CompilePhase, self).__init__("compiler", Phase.eOrderCompile)

class AssemblePhase(Phase):
    def __init__(self):
        super(AssemblePhase, self).__init__("assembler", Phase.eOrderAssemble)

class LinkPhase(Phase):
    def __init__(self):
        super(LinkPhase, self).__init__("linker", Phase.eOrderPostAssemble)

class LipoPhase(Phase):
    def __init__(self):
        super(LipoPhase, self).__init__("lipo", Phase.eOrderPostAssemble)