Update MicroCode build rules
[mirror_edk2.git] / BaseTools / Conf / build_rule.template
CommitLineData
589d5eaa 1# file extention : file type
2FileTypeMapping = {
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",
0963b13d 10 ".inc" : "Masm-Header",
589d5eaa 11 ".asm" : "Masm-Code",
12 ".Asm" : "Masm-Code",
13 ".ASM" : "Masm-Code",
0963b13d
LG
14 ".asm16" : "Masm16-Code", #RealAsm16 Link Code
15 ".Asm16" : "Masm16-Code",
16 ".ASM16" : "Masm16-Code",
589d5eaa 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",
7b2b99a3 28 ".TXT" : "MicorCode-Text",
52de52ae 29 ".txt" : "MicorCode-Text",
589d5eaa 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",
804c081d 47 ".aslc" : "Acpi-Table-Source",
589d5eaa 48 ".obj" : "Object",
49 ".o" : "Object",
50 ".lib" : "Static-Library",
51 ".a" : "Static-Library",
52 ".dll" : "Dynamic-Library",
53 ".so" : "Dynamic-Library",
54}
55
804c081d 56ObjectFileMapping = {
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",
0963b13d 66 "Dynamic-Library" : ".efi",
804c081d 67 "Dependency-Expression" : ".depex",
0963b13d
LG
68 "Acpi-Source-Language" : ".aml",
69 "Acpi-Table-Source" : ".acpi",
70 "Masm16-Code" : ".com",
7b2b99a3 71 "MicorCode-Text" : ".bin",
804c081d 72}
73
0963b13d 74DefaultToolCode = ["CC", "ASM", "SLINK", "DLINK", "PCH", "PP", "ASL", "ASMLINK"]
589d5eaa 75
76ToolCodeMapping = {
b1f7ad66 77 "C-Code" : ["CC"],
ca451dba 78# "C-Header" : ["PCH"],
b1f7ad66 79 "Masm-Code" : ["PP", "ASM"],
80 "Iasm-Code" : ["PP", "ASM"], # IPF assembly code
0963b13d 81 "Gasm-Code" : ["ASM"], # GNU assembly code
b1f7ad66 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"],
0963b13d
LG
88 "Acpi-Source-Language" : ["PP", "ASL"],
89 "Acpi-Table-Source" : ["CC", "DLINK"],
90 "Masm16-Code" : ["ASM", "ASMLINK"],
52de52ae 91 "MicorCode-Text" : ["CC"],
589d5eaa 92}
93
94ToolChainFamilyMapping = {
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"],
0963b13d
LG
109 "Acpi-Table-Source" : ["MSFT", "INTEL"],
110 "Masm16-Code" : ["MSFT"],
7b2b99a3 111 "MicorCode-Text" : ["MSFT", "INTEL"],
589d5eaa 112}
113
114## Build rules for makefile
115# Placeholders for string substitution
a9c9a31d 116# ${fpath} File path relative to $(WORKSPACE)
0963b13d
LG
117# ${fdir} File relative directory within a module
118# ${fname} File full name without path
119# ${fbase} File name without extension and path
a9c9a31d 120# ${fext} File extension
121# ${fdep} File dependencies
ca451dba 122# ${_sep_} Directory separator
123# ${_of_} Output flag
124# ${_if_} Include flag
589d5eaa 125#
126Makefile = {
d8dab390 127# MSFT tool chain family
0963b13d 128"MSFT" : {
589d5eaa 129"C-Code" : '''\
ca451dba 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}
589d5eaa 133''',
134
135"Masm-Code" : '''\
ca451dba 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
56919d25 139\tTrim -s -c $(@D)${_sep_}${fbase}.i
ca451dba 140\t"$(ASM)" /Fo$@ $(ASM_FLAGS) $(INC) $(@D)${_sep_}${fbase}.iii
589d5eaa 141''',
142
143"Iasm-Code" : '''\
ca451dba 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
589d5eaa 148''',
149
8cc72408 150"Visual-Form-Representation" : '''\
ca451dba 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
56919d25 154\tTrim -v $(@D)${_sep_}${fbase}.i
ca451dba 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
8cc72408 158''',
804c081d 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
0963b13d
LG
165\t"$(ASL)" -p $@ $(@D)${_sep_}${fbase}.i
166\t-copy $(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.aml $(OUTPUT_DIR)${_sep_}${fbase}.aml /Y
804c081d 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}
0963b13d 174\t"$(DLINK)" $(@D)${_sep_}${fbase}.obj /out:$(@D)${_sep_}${fbase}.dll $(DLINK_FLAGS) $(DLINK_SPATH) $(LIBS)
804c081d 175\tGenFw -o $@ -c $(@D)${_sep_}${fbase}.dll
0963b13d
LG
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)
7b2b99a3
LG
181${BEGIN}$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.com : $(WORKSPACE)${_sep_}${fdep}
182${END}\tpushd .
0963b13d
LG
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
804c081d 186''',
7b2b99a3
LG
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''',
589d5eaa 193},
194
d8dab390 195#
196# INTEL tool chain family
197#
0963b13d 198"INTEL" : {
d8dab390 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
56919d25 209\tTrim -s -c $(@D)${_sep_}${fbase}.i
d8dab390 210\t"$(ASM)" /Fo$@ $(ASM_FLAGS) $(INC) $(@D)${_sep_}${fbase}.iii
211''',
ca451dba 212
d8dab390 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
56919d25 224\tTrim -v $(@D)${_sep_}${fbase}.i
d8dab390 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''',
0963b13d
LG
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''',
d8dab390 248},
249
250#
251# GCC tool chain family
252#
ca451dba 253"GCC" : {
254
589d5eaa 255"C-Code" :
ca451dba 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''',
589d5eaa 261
ca451dba 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''',
589d5eaa 268
269"Visual-Form-Representation" :
ca451dba 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
56919d25 274\tTrim -v $(@D)${_sep_}${fbase}.i
ca451dba 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''',
589d5eaa 279}
280}
281
282# This acts like the main() function for the script, unless it is 'import'ed into another
283# script.
284if __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