summaryrefslogtreecommitdiff
path: root/BaseTools/Conf/build_rule.template
blob: 44a3196b824d86b6de0cefeaee35519c431e24ae (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# file extention   :   file type
FileTypeMapping = {
    ".c"    :   "C-Code",
    ".C"    :   "C-Code",
    ".cpp"  :   "C-Code",
    ".Cpp"  :   "C-Code",
    ".CPP"  :   "C-Code",
    ".h"    :   "C-Header",
    ".H"    :   "C-Header",
    ".asm"  :   "Masm-Code",
    ".Asm"  :   "Masm-Code",
    ".ASM"  :   "Masm-Code",
    ".s"    :   "Iasm-Code",    # IPF assembly code
    ".S"    :   "Gasm-Code",    # GNU assembly code
    ".uni"  :   "Unicode-Text",
    ".Uni"  :   "Unicode-Text",
    ".UNI"  :   "Unicode-Text",
    ".vfr"  :   "Visual-Form-Representation",
    ".Vfr"  :   "Visual-Form-Representation",
    ".VFR"  :   "Visual-Form-Representation",
    ".dxs"  :   "Dependency-Expression",
    ".Dxs"  :   "Dependency-Expression",
    ".DXS"  :   "Dependency-Expression",
    ".fv"   :   "FirmwareVolume",
    ".Fv"   :   "FirmwareVolume",
    ".FV"   :   "FirmwareVolume",
    ".efi"  :   "Efi-Image",
    ".Efi"  :   "Efi-Image",
    ".EFI"  :   "Efi-Image",
    ".SEC"  :   "Firmware-File-System",
    ".PEI"  :   "Firmware-File-System",
    ".DXE"  :   "Firmware-File-System",
    ".APP"  :   "Firmware-File-System",
    ".FYI"  :   "Firmware-File-System",
    ".FFS"  :   "Firmware-File-System",
    ".bmp"  :   "Bmp-Image",
    ".i"    :   "Preprocessed-Code",
    ".asl"  :   "Acpi-Source-Language",
    ".Asl"  :   "Acpi-Source-Language",
    ".ASL"  :   "Acpi-Source-Language",
    ".obj"  :   "Object",
    ".o"    :   "Object",
    ".lib"  :   "Static-Library",
    ".a"    :   "Static-Library",
    ".dll"  :   "Dynamic-Library",
    ".so"   :   "Dynamic-Library",
}

DefaultToolCode = ["CC", "ASM", "SLINK", "DLINK", "PCH", "PP", "ASL", "VFRC", "AUTOGEN"]

ToolCodeMapping = {
    "C-Code"                        :   "CC",
    "C-Header"                      :   "PCH",
    "Masm-Code"                     :   "ASM",
    "Iasm-Code"                     :   "ASM",          # IPF assembly code
    "Gasm-Code"                     :   "ASM",          # GNU assembly code
    "Unicode-Text"                  :   "AUTOGEN",
    "Visual-Form-Representation"    :   "VFRC",
    "Preprocessed-Code"             :   "CC",
    "Acpi-Source-Language"          :   "ASL",
    "Object"                        :   "SLINK",
    "Static-Library"                :   "DLINK",
    "Dependency-Expression"         :   "PP",
}

ToolChainFamilyMapping = {
    "C-Code"                        :   ["MSFT", "INTEL", "GCC"],
    "C-Header"                      :   ["MSFT", "INTEL", "GCC"],
    "Masm-Code"                     :   ["MSFT", "INTEL"],
    "Iasm-Code"                     :   ["MSFT", "INTEL"],          # IPF assembly code
    "Gasm-Code"                     :   ["GCC"],                    # GNU assembly code
    "Unicode-Text"                  :   ["MSFT", "INTEL", "GCC"],
    "Visual-Form-Representation"    :   ["MSFT", "INTEL", "GCC"],
    "Dependency-Expression"         :   ["MSFT", "INTEL", "GCC"],
    "FirmwareVolume"                :   ["MSFT", "INTEL", "GCC"],
    "Efi-Image"                     :   ["MSFT", "INTEL", "GCC"],
    "Firmware-File-System"          :   ["MSFT", "INTEL", "GCC"],
    "Bmp-Image"                     :   ["MSFT", "INTEL", "GCC"],
    "Preprocessed-Code"             :   ["MSFT", "INTEL"],
    "Acpi-Source-Language"          :   ["MSFT", "INTEL"],
}

## Build rules for makefile
# Placeholders for string substitution
#   ${fpath}  File path relative to $(WORKSPACE)
#   ${fdir}  	File relative directory within a module
#   ${fname}	File full name without path
#   ${fbase}	File name without extension and path
#   ${fext}   File extension
#   ${fdep}   File dependencies
#   ${sep}    Directory separator
#
Makefile = {
"nmake"	: {
"C-Code"    : '''\
$(OUTPUT_DIR)${sep}${fdir}${sep}${fbase}.obj : $(COMMON_DEPS)
${BEGIN}$(OUTPUT_DIR)${sep}${fdir}${sep}${fbase}.obj : $(WORKSPACE)${sep}${fdep}
${END}	"$(CC)" $(CC_FLAGS) $(INC) /Fo$@ $(WORKSPACE)${sep}${fpath}
''',

"Masm-Code" : '''\
$(OUTPUT_DIR)${sep}${fdir}${sep}${fbase}.obj : $(COMMON_DEPS)
${BEGIN}$(OUTPUT_DIR)${sep}${fdir}${sep}${fbase}.obj : $(WORKSPACE)${sep}${fdep}
${END}	"$(PP)" $(PP_FLAGS) $(INC) $(WORKSPACE)${sep}${fpath} > $(@D)${sep}${fbase}.i
	Trim -CONVERT $(@D)${sep}${fbase}.i
	"$(ASM)" $(ASM_FLAGS) /Fo$@ $(@D)${sep}${fbase}.iii
''',

"Iasm-Code" : '''\
$(OUTPUT_DIR)${sep}${fdir}${sep}${fbase}.obj : $(COMMON_DEPS)
${BEGIN}$(OUTPUT_DIR)${sep}${fdir}${sep}${fbase}.obj : $(WORKSPACE)${sep}${fdep}
${END}	"$(APP)" $(APP_FLAGS) $(INC) $(WORKSPACE)${sep}${fpath} > $(@D)${sep}${fbase}.i
	"$(ASM)" $(ASM_FLAGS) /Fo$@ $(@D)${sep}${fbase}.i
''',

"Visual-Form-Representation" : '''\
$(OUTPUT_DIR)${sep}${fdir}${sep}${fbase}.obj : $(COMMON_DEPS)
${BEGIN}$(OUTPUT_DIR)${sep}${fdir}${sep}${fbase}.obj : $(WORKSPACE)${sep}${fdep}
${END}\t"$(VFRPP)" $(VFRPP_FLAGS) $(INC) $(WORKSPACE)${sep}${fpath} > $(@D)${sep}${fbase}.i
\tTrim -VFR $(@D)${sep}${fbase}.i
\t"$(VFRC)" $(VFRC_FLAGS) -od $(DEBUG_DIR)${sep}${fdir} $(@D)${sep}${fbase}.iii
\t"$(CC)" $(CC_FLAGS) $(INC) /Fo$@ $(DEBUG_DIR)${sep}${fdir}${sep}${fbase}.c
''',
},

"gmake" : {
"C-Code"    : 
'''$(OUTPUT_DIR)/%(fdir)s/%(fbase)s.obj : $(MODULE_DIR)/%(fdir)s/%(fname)s $(DEP_FILES)
\t"$(CC)" $(CC_FLAGS) $(INC) $(CC_OUTPUT)$@ $<''',

"Masm-Code" : 
'''$(OUTPUT_DIR)/%(fdir)s/%(fbase)s.obj : $(MODULE_DIR)/%(fdir)s/%(fname)s $(DEP_FILES)
\t"$(PP)" $(PP_FLAGS) $(INC) $? $(PP_OUTPUT)$(@D)/%(fbase)s.i
\tTrim -CONVERT $(@D)/%(fbase)s.i
\t"$(ASM)" $(ASM_FLAGS) $(ASM_OUTPUT)$@ $(@D)/%(fbase)s.iii''',
    
"Gasm-Code" : 
'''$(OUTPUT_DIR)/%(fdir)s/%(fbase)s.obj : $(MODULE_DIR)/%(fdir)s/%(fname)s $(DEP_FILES)
\t"$(ASM)" $(ASM_FLAGS) $(INC) $(ASM_OUTPUT)$@ $<''',

"Iasm-Code" : 
'''$(OUTPUT_DIR)/%(fdir)s/%(fbase)s.obj : $(MODULE_DIR)/%(fdir)s/%(fname)s $(DEP_FILES)
\t"$(APP)" $(APP_FLAGS) $(INC) $< $(PP_OUTPUT)$(@D)/%(fbase)s.i
\t"$(ASM)" $(ASM_FLAGS) $(ASM_OUTPUT)$@ $(@D)/%(fbase)s.i''',

"Visual-Form-Representation" : 
'''$(OUTPUT_DIR)/%(fdir)s/%(fbase)s.obj : $(MODULE_DIR)/%(fdir)s/%(fname)s $(DEP_FILES)
\t"$(PP)" $(PP_FLAGS) $(INC) $< $(PP_OUTPUT)$(@D)/%(fbase)s.i
\t"$(VFRC)" $(VFRC_FLAGS) $(INC) $(VFRC_OUTPUT)$(DEBUG_DIR)/%(fdir)s/%(fbase)s.c $(@D)/%(fbase)s.i
\t"$(CC)" $(CC_FLAGS) $(INC) $(CC_OUTPUT)$@ $(DEBUG_DIR)/%(fdir)s/%(fbase)s.c''',
}
}

# This acts like the main() function for the script, unless it is 'import'ed into another
# script.
if __name__ == '__main__':
    for ext in FileTypeMapping:
        print ext,":",FileTypeMapping[ext]

    for type in Makefile["nmake"]:
        print "[",type,"]\n",Makefile["nmake"][type]
        print

    for type in Makefile["gmake"]:
        print "[",type,"]\n",Makefile["gmake"][type]
        print