audk/BaseTools/Conf/build_rule.template

296 lines
12 KiB
Plaintext
Raw Normal View History

# 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",
".inc" : "Masm-Header",
".asm" : "Masm-Code",
".Asm" : "Masm-Code",
".ASM" : "Masm-Code",
".asm16" : "Masm16-Code", #RealAsm16 Link Code
".Asm16" : "Masm16-Code",
".ASM16" : "Masm16-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",
".TXT" : "MicorCode-Text",
".txt" : "MicorCode-Text",
".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",
".aslc" : "Acpi-Table-Source",
".obj" : "Object",
".o" : "Object",
".lib" : "Static-Library",
".a" : "Static-Library",
".dll" : "Dynamic-Library",
".so" : "Dynamic-Library",
}
ObjectFileMapping = {
"C-Code" : ".obj",
# "C-Header" : ".gch",
"Masm-Code" : ".obj",
"Iasm-Code" : ".obj", # IPF assembly code
"Gasm-Code" : ".obj", # GNU assembly code
"Visual-Form-Representation" : ".obj",
"Preprocessed-Code" : ".obj",
"Object" : ".dll",
"Static-Library" : ".dll",
"Dynamic-Library" : ".efi",
"Dependency-Expression" : ".depex",
"Acpi-Source-Language" : ".aml",
"Acpi-Table-Source" : ".acpi",
"Masm16-Code" : ".com",
"MicorCode-Text" : ".bin",
}
DefaultToolCode = ["CC", "ASM", "SLINK", "DLINK", "PCH", "PP", "ASL", "ASMLINK"]
ToolCodeMapping = {
"C-Code" : ["CC"],
# "C-Header" : ["PCH"],
"Masm-Code" : ["PP", "ASM"],
"Iasm-Code" : ["PP", "ASM"], # IPF assembly code
"Gasm-Code" : ["ASM"], # GNU assembly code
"Visual-Form-Representation" : ["PP", "CC"],
"Preprocessed-Code" : ["CC"],
"Acpi-Source-Language" : ["ASL"],
"Object" : ["SLINK"],
"Static-Library" : ["DLINK"],
"Dependency-Expression" : ["PP"],
"Acpi-Source-Language" : ["PP", "ASL"],
"Acpi-Table-Source" : ["CC", "DLINK"],
"Masm16-Code" : ["ASM", "ASMLINK"],
"MicorCode-Text" : ["CC"],
}
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"],
"Acpi-Table-Source" : ["MSFT", "INTEL"],
"Masm16-Code" : ["MSFT"],
"MicorCode-Text" : ["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
# ${_of_} Output flag
# ${_if_} Include flag
#
Makefile = {
# MSFT tool chain family
"MSFT" : {
"C-Code" : '''\
$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.obj : $(COMMON_DEPS)
${BEGIN}$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.obj : $(WORKSPACE)${_sep_}${fdep}
${END}\t"$(CC)" /Fo$@ $(CC_FLAGS) $(INC) $(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}\t"$(PP)" $(PP_FLAGS) $(INC) $(WORKSPACE)${_sep_}${fpath} > $(@D)${_sep_}${fbase}.i
\tTrim -s -c $(@D)${_sep_}${fbase}.i
\t"$(ASM)" /Fo$@ $(ASM_FLAGS) $(INC) $(@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}\t"$(APP)" $(APP_FLAGS) $(INC) $(WORKSPACE)${_sep_}${fpath} > $(@D)${_sep_}${fbase}.i
\t"$(ASM)" -o $@ $(ASM_FLAGS) $(@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"$(PP)" $(VFRPP_FLAGS) $(INC) $(WORKSPACE)${_sep_}${fpath} > $(@D)${_sep_}${fbase}.i
\tTrim -v $(@D)${_sep_}${fbase}.i
\t-mkdir $(DEBUG_DIR)${_sep_}${fdir} > NUL 2>&1
\tVfrCompile -od $(DEBUG_DIR)${_sep_}${fdir} $(@D)${_sep_}${fbase}.iii
\t"$(CC)" /Fo$@ $(CC_FLAGS) $(INC) $(DEBUG_DIR)${_sep_}${fdir}${_sep_}${fbase}.c
''',
"Acpi-Source-Language" :
'''
$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.aml : $(COMMON_DEPS)
${BEGIN}$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.aml : $(WORKSPACE)${_sep_}${fdep}
${END}\t"$(PP)" $(APP_FLAGS) $(INC) $(WORKSPACE)${_sep_}${fpath} > $(@D)${_sep_}${fbase}.i
\t"$(ASL)" -p $@ $(@D)${_sep_}${fbase}.i
\t-copy $(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.aml $(OUTPUT_DIR)${_sep_}${fbase}.aml /Y
''',
"Acpi-Table-Source" :
'''
$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.acpi : $(COMMON_DEPS)
${BEGIN}$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.acpi : $(WORKSPACE)${_sep_}${fdep}
${END}\t"$(CC)" /Fo$(@D)${_sep_}${fbase}.obj $(CC_FLAGS) $(INC) $(WORKSPACE)${_sep_}${fpath}
\t"$(DLINK)" $(@D)${_sep_}${fbase}.obj /out:$(@D)${_sep_}${fbase}.dll $(DLINK_FLAGS) $(DLINK_SPATH) $(LIBS)
\tGenFw -o $@ -c $(@D)${_sep_}${fbase}.dll
\t-copy $(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.acpi $(OUTPUT_DIR)${_sep_}${fbase}.acpi /Y
''',
"Masm16-Code" : '''\
$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.com : $(COMMON_DEPS)
${BEGIN}$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.com : $(WORKSPACE)${_sep_}${fdep}
${END}\tpushd .
\tcd $(OUTPUT_DIR)${_sep_}${fdir}
\t"$(ASM)" /nologo /omf $(WORKSPACE)${_sep_}${fpath} /Bl"$(ASMLINK)" $(ASMLINK_FLAGS)
\t-copy ${fbase}.com $(OUTPUT_DIR)${_sep_}${fbase}.com /Y & popd
''',
"MicorCode-Text" : '''\
$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.bin : $(COMMON_DEPS)
${BEGIN}$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.bin : $(WORKSPACE)${_sep_}${fdep}
${END}\tGenFw -o $@ -m $(WORKSPACE)${_sep_}${fpath}
''',
},
#
# INTEL tool chain family
#
"INTEL" : {
"C-Code" : '''\
$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.obj : $(COMMON_DEPS)
${BEGIN}$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.obj : $(WORKSPACE)${_sep_}${fdep}
${END}\t"$(CC)" /Fo$@ $(CC_FLAGS) $(INC) $(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}\t"$(PP)" $(PP_FLAGS) $(INC) $(WORKSPACE)${_sep_}${fpath} > $(@D)${_sep_}${fbase}.i
\tTrim -s -c $(@D)${_sep_}${fbase}.i
\t"$(ASM)" /Fo$@ $(ASM_FLAGS) $(INC) $(@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}\t"$(APP)" $(APP_FLAGS) $(INC) $(WORKSPACE)${_sep_}${fpath} > $(@D)${_sep_}${fbase}.i
\t"$(ASM)" -o $@ $(ASM_FLAGS) $(@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"$(PP)" $(VFRPP_FLAGS) $(INC) $(WORKSPACE)${_sep_}${fpath} > $(@D)${_sep_}${fbase}.i
\tTrim -v $(@D)${_sep_}${fbase}.i
\t-mkdir $(DEBUG_DIR)${_sep_}${fdir} > NUL 2>&1
\tVfrCompile -od $(DEBUG_DIR)${_sep_}${fdir} $(@D)${_sep_}${fbase}.iii
\t"$(CC)" /Fo$@ $(CC_FLAGS) $(INC) $(DEBUG_DIR)${_sep_}${fdir}${_sep_}${fbase}.c
''',
"Acpi-Source-Language" :
'''
$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.aml : $(COMMON_DEPS)
${BEGIN}$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.aml : $(WORKSPACE)${_sep_}${fdep}
${END}\t"$(PP)" $(APP_FLAGS) $(INC) $(WORKSPACE)${_sep_}${fpath} > $(@D)${_sep_}${fbase}.i
\t"$(ASL)" -p $@ $(@D)${_sep_}${fbase}.i
\t-copy $(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.aml $(OUTPUT_DIR)${_sep_}${fbase}.aml /Y
''',
"Acpi-Table-Source" :
'''
$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.acpi : $(COMMON_DEPS)
${BEGIN}$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.acpi : $(WORKSPACE)${_sep_}${fdep}
${END}\t"$(CC)" /Fo$(@D)${_sep_}${fbase}.obj $(CC_FLAGS) $(INC) $(WORKSPACE)${_sep_}${fpath}
\t"$(DLINK)" $(@D)${_sep_}${fbase}.obj /out:$(@D)${_sep_}${fbase}.dll $(DLINK_FLAGS) $(DLINK_SPATH) $(LIBS)
\tGenFw -o $@ -c $(@D)${_sep_}${fbase}.dll
\t-copy $(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.acpi $(OUTPUT_DIR)${_sep_}${fbase}.acpi /Y
''',
},
#
# GCC tool chain family
#
"GCC" : {
"C-Code" :
'''
$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.obj : $(COMMON_DEPS)
${BEGIN}$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.obj : $(WORKSPACE)${_sep_}${fdep}
${END}\t"$(CC)" -o $@ $(CC_FLAGS) $(INC) $(WORKSPACE)${_sep_}${fpath}
''',
"Gasm-Code" :
'''
$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.obj : $(COMMON_DEPS)
${BEGIN}$(OUTPUT_DIR)${_sep_}${fdir}${_sep_}${fbase}.obj : $(WORKSPACE)${_sep_}${fdep}
${END}\t"$(ASM)" -o $@ $(ASM_FLAGS) $(INC) $(WORKSPACE)${_sep_}${fpath}
''',
"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"$(PP)" $(VFRPP_FLAGS) $(INC) $(WORKSPACE)${_sep_}${fpath} -o $(@D)${_sep_}${fbase}.i
\tTrim -v $(@D)${_sep_}${fbase}.i
\t-mkdir $(DEBUG_DIR)${_sep_}${fdir} > NUL 2>&1
\tVfrCompile -od $(DEBUG_DIR)${_sep_}${fdir} $(@D)${_sep_}${fbase}.iii
\t"$(CC)" -o $@ $(CC_FLAGS) $(INC) $(DEBUG_DIR)${_sep_}${fdir}${_sep_}${fbase}.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