Update MicroCode build rules
[mirror_edk2.git] / BaseTools / Conf / build_rule.template
1 # file extention : file type
2 FileTypeMapping = {
3 ".c" : "C-Code",
4 ".C" : "C-Code",
5 ".cpp" : "C-Code",
6 ".Cpp" : "C-Code",
7 ".CPP" : "C-Code",
8 ".h" : "C-Header",
9 ".H" : "C-Header",
10 ".inc" : "Masm-Header",
11 ".asm" : "Masm-Code",
12 ".Asm" : "Masm-Code",
13 ".ASM" : "Masm-Code",
14 ".asm16" : "Masm16-Code", #RealAsm16 Link Code
15 ".Asm16" : "Masm16-Code",
16 ".ASM16" : "Masm16-Code",
17 ".s" : "Iasm-Code", # IPF assembly code
18 ".S" : "Gasm-Code", # GNU assembly code
19 ".uni" : "Unicode-Text",
20 ".Uni" : "Unicode-Text",
21 ".UNI" : "Unicode-Text",
22 ".vfr" : "Visual-Form-Representation",
23 ".Vfr" : "Visual-Form-Representation",
24 ".VFR" : "Visual-Form-Representation",
25 ".dxs" : "Dependency-Expression",
26 ".Dxs" : "Dependency-Expression",
27 ".DXS" : "Dependency-Expression",
28 ".TXT" : "MicorCode-Text",
29 ".txt" : "MicorCode-Text",
30 ".fv" : "FirmwareVolume",
31 ".Fv" : "FirmwareVolume",
32 ".FV" : "FirmwareVolume",
33 ".efi" : "Efi-Image",
34 ".Efi" : "Efi-Image",
35 ".EFI" : "Efi-Image",
36 ".SEC" : "Firmware-File-System",
37 ".PEI" : "Firmware-File-System",
38 ".DXE" : "Firmware-File-System",
39 ".APP" : "Firmware-File-System",
40 ".FYI" : "Firmware-File-System",
41 ".FFS" : "Firmware-File-System",
42 ".bmp" : "Bmp-Image",
43 ".i" : "Preprocessed-Code",
44 ".asl" : "Acpi-Source-Language",
45 ".Asl" : "Acpi-Source-Language",
46 ".ASL" : "Acpi-Source-Language",
47 ".aslc" : "Acpi-Table-Source",
48 ".obj" : "Object",
49 ".o" : "Object",
50 ".lib" : "Static-Library",
51 ".a" : "Static-Library",
52 ".dll" : "Dynamic-Library",
53 ".so" : "Dynamic-Library",
54 }
55
56 ObjectFileMapping = {
57 "C-Code" : ".obj",
58 # "C-Header" : ".gch",
59 "Masm-Code" : ".obj",
60 "Iasm-Code" : ".obj", # IPF assembly code
61 "Gasm-Code" : ".obj", # GNU assembly code
62 "Visual-Form-Representation" : ".obj",
63 "Preprocessed-Code" : ".obj",
64 "Object" : ".dll",
65 "Static-Library" : ".dll",
66 "Dynamic-Library" : ".efi",
67 "Dependency-Expression" : ".depex",
68 "Acpi-Source-Language" : ".aml",
69 "Acpi-Table-Source" : ".acpi",
70 "Masm16-Code" : ".com",
71 "MicorCode-Text" : ".bin",
72 }
73
74 DefaultToolCode = ["CC", "ASM", "SLINK", "DLINK", "PCH", "PP", "ASL", "ASMLINK"]
75
76 ToolCodeMapping = {
77 "C-Code" : ["CC"],
78 # "C-Header" : ["PCH"],
79 "Masm-Code" : ["PP", "ASM"],
80 "Iasm-Code" : ["PP", "ASM"], # IPF assembly code
81 "Gasm-Code" : ["ASM"], # GNU assembly code
82 "Visual-Form-Representation" : ["PP", "CC"],
83 "Preprocessed-Code" : ["CC"],
84 "Acpi-Source-Language" : ["ASL"],
85 "Object" : ["SLINK"],
86 "Static-Library" : ["DLINK"],
87 "Dependency-Expression" : ["PP"],
88 "Acpi-Source-Language" : ["PP", "ASL"],
89 "Acpi-Table-Source" : ["CC", "DLINK"],
90 "Masm16-Code" : ["ASM", "ASMLINK"],
91 "MicorCode-Text" : ["CC"],
92 }
93
94 ToolChainFamilyMapping = {
95 "C-Code" : ["MSFT", "INTEL", "GCC"],
96 "C-Header" : ["MSFT", "INTEL", "GCC"],
97 "Masm-Code" : ["MSFT", "INTEL"],
98 "Iasm-Code" : ["MSFT", "INTEL"], # IPF assembly code
99 "Gasm-Code" : ["GCC"], # GNU assembly code
100 "Unicode-Text" : ["MSFT", "INTEL", "GCC"],
101 "Visual-Form-Representation" : ["MSFT", "INTEL", "GCC"],
102 "Dependency-Expression" : ["MSFT", "INTEL", "GCC"],
103 "FirmwareVolume" : ["MSFT", "INTEL", "GCC"],
104 "Efi-Image" : ["MSFT", "INTEL", "GCC"],
105 "Firmware-File-System" : ["MSFT", "INTEL", "GCC"],
106 "Bmp-Image" : ["MSFT", "INTEL", "GCC"],
107 "Preprocessed-Code" : ["MSFT", "INTEL"],
108 "Acpi-Source-Language" : ["MSFT", "INTEL"],
109 "Acpi-Table-Source" : ["MSFT", "INTEL"],
110 "Masm16-Code" : ["MSFT"],
111 "MicorCode-Text" : ["MSFT", "INTEL"],
112 }
113
114 ## Build rules for makefile
115 # Placeholders for string substitution
116 # ${fpath} File path relative to $(WORKSPACE)
117 # ${fdir} File relative directory within a module
118 # ${fname} File full name without path
119 # ${fbase} File name without extension and path
120 # ${fext} File extension
121 # ${fdep} File dependencies
122 # ${_sep_} Directory separator
123 # ${_of_} Output flag
124 # ${_if_} Include flag
125 #
126 Makefile = {
127 # MSFT tool chain family
128 "MSFT" : {
129 "C-Code" : '''\
130 $(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.obj : $(COMMON_DEPS)
131 ${BEGIN}$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.obj : $(WORKSPACE)${_sep_}${fdep}
132 ${END}\t"$(CC)" /Fo$@ $(CC_FLAGS) $(INC) $(WORKSPACE)${_sep_}${fpath}
133 ''',
134
135 "Masm-Code" : '''\
136 $(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.obj : $(COMMON_DEPS)
137 ${BEGIN}$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.obj : $(WORKSPACE)${_sep_}${fdep}
138 ${END}\t"$(PP)" $(PP_FLAGS) $(INC) $(WORKSPACE)${_sep_}${fpath} > $(@D)${_sep_}${fbase}.i
139 \tTrim -s -c $(@D)${_sep_}${fbase}.i
140 \t"$(ASM)" /Fo$@ $(ASM_FLAGS) $(INC) $(@D)${_sep_}${fbase}.iii
141 ''',
142
143 "Iasm-Code" : '''\
144 $(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.obj : $(COMMON_DEPS)
145 ${BEGIN}$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.obj : $(WORKSPACE)${_sep_}${fdep}
146 ${END}\t"$(APP)" $(APP_FLAGS) $(INC) $(WORKSPACE)${_sep_}${fpath} > $(@D)${_sep_}${fbase}.i
147 \t"$(ASM)" -o $@ $(ASM_FLAGS) $(@D)${_sep_}${fbase}.i
148 ''',
149
150 "Visual-Form-Representation" : '''\
151 $(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.obj : $(COMMON_DEPS)
152 ${BEGIN}$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.obj : $(WORKSPACE)${_sep_}${fdep}
153 ${END}\t"$(PP)" $(VFRPP_FLAGS) $(INC) $(WORKSPACE)${_sep_}${fpath} > $(@D)${_sep_}${fbase}.i
154 \tTrim -v $(@D)${_sep_}${fbase}.i
155 \t-mkdir $(DEBUG_DIR)${_sep_}${fdir} > NUL 2>&1
156 \tVfrCompile -od $(DEBUG_DIR)${_sep_}${fdir} $(@D)${_sep_}${fbase}.iii
157 \t"$(CC)" /Fo$@ $(CC_FLAGS) $(INC) $(DEBUG_DIR)${_sep_}${fdir}${_sep_}${fbase}.c
158 ''',
159
160 "Acpi-Source-Language" :
161 '''
162 $(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.aml : $(COMMON_DEPS)
163 ${BEGIN}$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.aml : $(WORKSPACE)${_sep_}${fdep}
164 ${END}\t"$(PP)" $(APP_FLAGS) $(INC) $(WORKSPACE)${_sep_}${fpath} > $(@D)${_sep_}${fbase}.i
165 \t"$(ASL)" -p $@ $(@D)${_sep_}${fbase}.i
166 \t-copy $(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.aml $(OUTPUT_DIR)${_sep_}${fbase}.aml /Y
167 ''',
168
169 "Acpi-Table-Source" :
170 '''
171 $(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.acpi : $(COMMON_DEPS)
172 ${BEGIN}$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.acpi : $(WORKSPACE)${_sep_}${fdep}
173 ${END}\t"$(CC)" /Fo$(@D)${_sep_}${fbase}.obj $(CC_FLAGS) $(INC) $(WORKSPACE)${_sep_}${fpath}
174 \t"$(DLINK)" $(@D)${_sep_}${fbase}.obj /out:$(@D)${_sep_}${fbase}.dll $(DLINK_FLAGS) $(DLINK_SPATH) $(LIBS)
175 \tGenFw -o $@ -c $(@D)${_sep_}${fbase}.dll
176 \t-copy $(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.acpi $(OUTPUT_DIR)${_sep_}${fbase}.acpi /Y
177 ''',
178
179 "Masm16-Code" : '''\
180 $(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.com : $(COMMON_DEPS)
181 ${BEGIN}$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.com : $(WORKSPACE)${_sep_}${fdep}
182 ${END}\tpushd .
183 \tcd $(OUTPUT_DIR)${_sep_}${fdir}
184 \t"$(ASM)" /nologo /omf $(WORKSPACE)${_sep_}${fpath} /Bl"$(ASMLINK)" $(ASMLINK_FLAGS)
185 \t-copy ${fbase}.com $(OUTPUT_DIR)${_sep_}${fbase}.com /Y & popd
186 ''',
187
188 "MicorCode-Text" : '''\
189 $(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.bin : $(COMMON_DEPS)
190 ${BEGIN}$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.bin : $(WORKSPACE)${_sep_}${fdep}
191 ${END}\tGenFw -o $@ -m $(WORKSPACE)${_sep_}${fpath}
192 ''',
193 },
194
195 #
196 # INTEL tool chain family
197 #
198 "INTEL" : {
199 "C-Code" : '''\
200 $(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.obj : $(COMMON_DEPS)
201 ${BEGIN}$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.obj : $(WORKSPACE)${_sep_}${fdep}
202 ${END}\t"$(CC)" /Fo$@ $(CC_FLAGS) $(INC) $(WORKSPACE)${_sep_}${fpath}
203 ''',
204
205 "Masm-Code" : '''\
206 $(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.obj : $(COMMON_DEPS)
207 ${BEGIN}$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.obj : $(WORKSPACE)${_sep_}${fdep}
208 ${END}\t"$(PP)" $(PP_FLAGS) $(INC) $(WORKSPACE)${_sep_}${fpath} > $(@D)${_sep_}${fbase}.i
209 \tTrim -s -c $(@D)${_sep_}${fbase}.i
210 \t"$(ASM)" /Fo$@ $(ASM_FLAGS) $(INC) $(@D)${_sep_}${fbase}.iii
211 ''',
212
213 "Iasm-Code" : '''\
214 $(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.obj : $(COMMON_DEPS)
215 ${BEGIN}$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.obj : $(WORKSPACE)${_sep_}${fdep}
216 ${END}\t"$(APP)" $(APP_FLAGS) $(INC) $(WORKSPACE)${_sep_}${fpath} > $(@D)${_sep_}${fbase}.i
217 \t"$(ASM)" -o $@ $(ASM_FLAGS) $(@D)${_sep_}${fbase}.i
218 ''',
219
220 "Visual-Form-Representation" : '''\
221 $(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.obj : $(COMMON_DEPS)
222 ${BEGIN}$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.obj : $(WORKSPACE)${_sep_}${fdep}
223 ${END}\t"$(PP)" $(VFRPP_FLAGS) $(INC) $(WORKSPACE)${_sep_}${fpath} > $(@D)${_sep_}${fbase}.i
224 \tTrim -v $(@D)${_sep_}${fbase}.i
225 \t-mkdir $(DEBUG_DIR)${_sep_}${fdir} > NUL 2>&1
226 \tVfrCompile -od $(DEBUG_DIR)${_sep_}${fdir} $(@D)${_sep_}${fbase}.iii
227 \t"$(CC)" /Fo$@ $(CC_FLAGS) $(INC) $(DEBUG_DIR)${_sep_}${fdir}${_sep_}${fbase}.c
228 ''',
229
230 "Acpi-Source-Language" :
231 '''
232 $(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.aml : $(COMMON_DEPS)
233 ${BEGIN}$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.aml : $(WORKSPACE)${_sep_}${fdep}
234 ${END}\t"$(PP)" $(APP_FLAGS) $(INC) $(WORKSPACE)${_sep_}${fpath} > $(@D)${_sep_}${fbase}.i
235 \t"$(ASL)" -p $@ $(@D)${_sep_}${fbase}.i
236 \t-copy $(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.aml $(OUTPUT_DIR)${_sep_}${fbase}.aml /Y
237 ''',
238
239 "Acpi-Table-Source" :
240 '''
241 $(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.acpi : $(COMMON_DEPS)
242 ${BEGIN}$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.acpi : $(WORKSPACE)${_sep_}${fdep}
243 ${END}\t"$(CC)" /Fo$(@D)${_sep_}${fbase}.obj $(CC_FLAGS) $(INC) $(WORKSPACE)${_sep_}${fpath}
244 \t"$(DLINK)" $(@D)${_sep_}${fbase}.obj /out:$(@D)${_sep_}${fbase}.dll $(DLINK_FLAGS) $(DLINK_SPATH) $(LIBS)
245 \tGenFw -o $@ -c $(@D)${_sep_}${fbase}.dll
246 \t-copy $(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.acpi $(OUTPUT_DIR)${_sep_}${fbase}.acpi /Y
247 ''',
248 },
249
250 #
251 # GCC tool chain family
252 #
253 "GCC" : {
254
255 "C-Code" :
256 '''
257 $(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.obj : $(COMMON_DEPS)
258 ${BEGIN}$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.obj : $(WORKSPACE)${_sep_}${fdep}
259 ${END}\t"$(CC)" -o $@ $(CC_FLAGS) $(INC) $(WORKSPACE)${_sep_}${fpath}
260 ''',
261
262 "Gasm-Code" :
263 '''
264 $(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.obj : $(COMMON_DEPS)
265 ${BEGIN}$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.obj : $(WORKSPACE)${_sep_}${fdep}
266 ${END}\t"$(ASM)" -o $@ $(ASM_FLAGS) $(INC) $(WORKSPACE)${_sep_}${fpath}
267 ''',
268
269 "Visual-Form-Representation" :
270 '''
271 $(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.obj : $(COMMON_DEPS)
272 ${BEGIN}$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.obj : $(WORKSPACE)${_sep_}${fdep}
273 ${END}\t"$(PP)" $(VFRPP_FLAGS) $(INC) $(WORKSPACE)${_sep_}${fpath} -o $(@D)${_sep_}${fbase}.i
274 \tTrim -v $(@D)${_sep_}${fbase}.i
275 \t-mkdir $(DEBUG_DIR)${_sep_}${fdir} > NUL 2>&1
276 \tVfrCompile -od $(DEBUG_DIR)${_sep_}${fdir} $(@D)${_sep_}${fbase}.iii
277 \t"$(CC)" -o $@ $(CC_FLAGS) $(INC) $(DEBUG_DIR)${_sep_}${fdir}${_sep_}${fbase}.c
278 ''',
279 }
280 }
281
282 # This acts like the main() function for the script, unless it is 'import'ed into another
283 # script.
284 if __name__ == '__main__':
285 for ext in FileTypeMapping:
286 print ext,":",FileTypeMapping[ext]
287
288 for type in Makefile["nmake"]:
289 print "[",type,"]\n",Makefile["nmake"][type]
290 print
291
292 for type in Makefile["gmake"]:
293 print "[",type,"]\n",Makefile["gmake"][type]
294 print
295