-# 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
-
+#\r
+# Copyright (c) 2007, Intel Corporation\r
+#\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+# Filename: build_rule.template\r
+#\r
+\r
+## Syntax\r
+#\r
+# "*" is used to indicate that the source files will be processed at the same time.\r
+# "?" is used to indicate that the source files will be processed one by one.\r
+#\r
+# "[" Build.<File-Type>[.<version>][, Build.<File-Type>[.<version>]] "]" <EOL>\r
+# <InputFile[.<ToolChainFamily>]> <EOL>\r
+# [File-Type =] (?|*).<File-Extension> [(\n|,|;) (?|*).<File-Extension>]\r
+#\r
+# <OutputFile[.<ToolChainFamily>]> <EOL>\r
+# <FileFullPath>\r
+#\r
+# <Command[.<ToolChainFamily>]> <EOL>\r
+# <Command1>\r
+# [<Command2>]\r
+#\r
+\r
+## Placeholders for string substitution\r
+#\r
+# ${src} Source file(s) to be built (full path)\r
+# ${s_path} Source file directory (absolute path)\r
+# ${s_dir} Source file relative directory within a module\r
+# (Note: ${s_dir} is always equals to "." if source file is given in absolute path.)\r
+# ${s_name} Source file name without path\r
+# ${s_base} Source file name without extension and path\r
+# ${s_ext} Source file extension\r
+#\r
+# ${dst} Destination file(s) built from ${src} (full path)\r
+# ${d_path} Destination file directory (absolute path)\r
+# ${d_name} Destination file name without path\r
+# ${d_base} Destination file name without extension and path\r
+# ${d_ext} Destination file extension\r
+#\r
+# (+) Directory separator\r
+#\r
+\r
+## Macro\r
+# $(WORKSPACE) Workspace directory\r
+# $(OUTPUT_DIR) Directory for intermediate files for building a module\r
+# $(DEBUG_DIR) Directory for files used to debug a module\r
+# $(BUILD_DIR) All files for building a platform will be put in this directory\r
+# $(BIN_DIR) Common directory for executable files\r
+# $(FV_DIR) Directory to store flash image files\r
+# $(INC) Search path of current module\r
+# $(LIBS) Static library files of current module\r
+# $(<tool>_FLAGS) Tools flags of current module\r
+# $(MODULE_NAME) Current module name\r
+# $(MODULE_TYPE) Current module type\r
+# $(ARCH) Architecture of current module\r
+# $(TOOLCHAIN) Toolchain used to build current module\r
+# $(TARGET) Target of current module (DEBUG/RELEASE)\r
+# $(<tool>) Path of tool\r
+# $(EDK_TOOLS_PATH) Path of build tools\r
+# $(<FILE_TYPE_LIST>) File list of each file type\r
+# (Note: The macro name is derived from file type name. For example,\r
+# C-Code-File will have C_CODE_FILE_LIST macro.)\r
+#\r
+# $(CP) copy command\r
+# $(MV) move command\r
+# $(RM) delete command\r
+# $(MD) create dir command\r
+# $(RD) remove dir command\r
+#\r
+\r
+## Reserved File-Type\r
+#\r
+# Dont't change following names of file types and their associated files,\r
+# which are also used in tools' code\r
+#\r
+# C-Code-File\r
+# C-Header-File\r
+# Dynamic-Library-File\r
+# Static-Library-File\r
+# Visual-Form-Representation-File\r
+# Unicode-Text-File\r
+#\r
+\r
+[Build.C-Code-File]\r
+ <InputFile>\r
+ ?.c\r
+ ?.C\r
+ ?.cc\r
+ ?.CC\r
+ ?.cpp\r
+ ?.Cpp\r
+ ?.CPP\r
+\r
+ <OutputFile>\r
+ $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj\r
+\r
+ <Command.MSFT, Command.INTEL>\r
+ "$(CC)" /Fo${dst} $(CC_FLAGS) $(INC) ${src}\r
+\r
+ <Command.GCC>\r
+ "$(CC)" -o ${dst} $(CC_FLAGS) $(INC) ${src}\r
+\r
+[Build.C-Header-File]\r
+ <InputFile>\r
+ *.h, *.H\r
+\r
+ <OutputFile>\r
+ $(OUTPUT_DIR)(+)$(MODULE_NAME).gch\r
+ $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj\r
+\r
+ <Command>\r
+\r
+\r
+[Build.Assembly-Code-File]\r
+ <InputFile.MSFT, InputFile.INTEL>\r
+ Assembly-Code-File = ?.asm, ?.Asm, ?.ASM\r
+\r
+ <InputFile.GCC>\r
+ ?.S\r
+\r
+ <OutputFile>\r
+ $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj\r
+\r
+ <Command.MSFT, Command.INTEL>\r
+ "$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i\r
+ Trim --source-code --convert-hex -o ${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.i\r
+ "$(ASM)" /Fo${dst} $(ASM_FLAGS) $(INC) ${d_path}(+)${s_base}.iii\r
+\r
+ <Command.GCC>\r
+ "$(ASM)" -o ${dst} $(ASM_FLAGS) $(INC) ${src}\r
+\r
+[Build.Iasm-Code-File]\r
+ <InputFile>\r
+ ?.s\r
+\r
+ <OutputFile>\r
+ $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj\r
+\r
+ <Command.MSFT, Command.INTEL>\r
+ "$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i\r
+ Trim --source-code -o ${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.i\r
+ "$(ASM)" -o ${dst} $(ASM_FLAGS) ${d_path}(+)${s_base}.iii\r
+\r
+[Build.Visual-Form-Representation-File]\r
+ <InputFile>\r
+ ?.vfr\r
+ ?.Vfr\r
+ ?.VFR\r
+\r
+ <OutputFile>\r
+ $(DEBUG_DIR)(+)${s_dir}(+)${s_base}.c\r
+\r
+ <Command>\r
+ "$(PP)" $(VFRPP_FLAGS) $(INC) ${src} > $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i\r
+ Trim --vfr-file -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i\r
+ -mkdir ${d_path} > NUL 2>&1\r
+ VfrCompile -od ${d_path} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii\r
+\r
+[Build.Object-File]\r
+ <InputFile>\r
+ *.obj\r
+ *.o\r
+\r
+ <OutputFile>\r
+ $(OUTPUT_DIR)(+)$(MODULE_NAME).lib\r
+\r
+ <Command.MSFT, Command.INTEL>\r
+ "$(SLINK)" $(SLINK_FLAGS) /OUT:${dst} ${src}\r
+\r
+ <Command.GCC>\r
+ "$(SLINK)" -cr ${dst} $(SLINK_FLAGS) ${src}\r
+\r
+#[Build.Object-File, Build.Static-Library-File]\r
+#BUILD_VERSION = 0x00010000\r
+#\r
+# <InputFile>\r
+# Object-File = *.obj\r
+# Static-Library-File = *.lib, *.a\r
+#\r
+# <OutputFile>\r
+# $(OUTPUT_DIR)(+)$(MODULE_NAME).lib\r
+#\r
+# <Command.MSFT>\r
+# "$(SLINK)" /OUT:${dst} $(SLINK_FLAGS) ${src}\r
+#\r
+# <Command.GCC>\r
+# "$(SLINK)" -cr ${dst} $(SLINK_FLAGS) ${src1} -( ${src2} -)\r
+#\r
+[Build.Static-Library-File]\r
+ <InputFile>\r
+ ?.lib\r
+ $(LIBS)\r
+\r
+ <OutputFile>\r
+ $(DEBUG_DIR)(+)$(MODULE_NAME).dll\r
+\r
+ <Command.MSFT, Command.INTEL>\r
+ "$(DLINK)" /OUT:${dst} $(DLINK_FLAGS) $(DLINK_SPATH) $(LIBS) ${src}\r
+\r
+ <Command.GCC>\r
+ "$(DLINK)" -o ${dst} $(DLINK_FLAGS) -( $(DLINK_SPATH) $(LIBS) ${src} -)\r
+\r
+[Build.Dynamic-Library-File]\r
+ <InputFile>\r
+ ?.dll\r
+\r
+ <OutputFile>\r
+ $(DEBUG_DIR)(+)$(MODULE_NAME).efi\r
+\r
+ <Command>\r
+ GenFw -e $(MODULE_TYPE) -o ${dst} ${src}\r
+ $(CP) ${dst} $(OUTPUT_DIR)\r
+ $(CP) ${dst} $(BIN_DIR)\r
+ -$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)\r
+\r
+[Build.Dependency-Expression-File]\r
+ <InputFile>\r
+ ?.dxs, ?.Dxs, ?.DXS\r
+\r
+ <OutputFile>\r
+ $(OUTPUT_DIR)(+)$(MODULE_NAME).depex\r
+\r
+ <Command>\r
+# GenDepex -o ${dst} ${src}\r
+\r
+[Build.Acpi-Source-Language-File]\r
+ <InputFile>\r
+ ?.asl, ?.Asl, ?.ASL\r
+\r
+ <OutputFile>\r
+ $(OUTPUT_DIR)(+)${s_base}.aml\r
+\r
+ <Command.MSFT, Command.INTEL>\r
+ "$(PP)" $(APP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i\r
+ "$(ASL)" -p ${dst} ${d_path}(+)${s_base}.i\r
+\r
+[Build.Acpi-Table-Code-File]\r
+ <InputFile>\r
+ ?.aslc\r
+\r
+ <OutputFile>\r
+ $(OUTPUT_DIR)(+)${s_base}.acpi\r
+\r
+ <Command.MSFT, Command.INTEL>\r
+ "$(CC)" /Fo$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(CC_FLAGS) $(INC) ${src}\r
+ "$(DLINK)" /OUT:$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(SLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj\r
+ GenFw -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll\r
+\r
+[Build.Masm16-Code-File]\r
+ <InputFile>\r
+ ?.asm16, ?.Asm16, ?.ASM16\r
+\r
+ <OutputFile>\r
+ $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.com\r
+\r
+ <Command.MSFT, Command.INTEL>\r
+ pushd .\r
+ cd $(OUTPUT_DIR)(+)${s_dir}\r
+ "$(ASM)" /nologo /omf ${src} /Bl"$(ASMLINK)" $(ASMLINK_FLAGS)\r
+ -$(CP) ${dst} $(OUTPUT_DIR) & popd\r
+\r
+[Build.Microcode-File]\r
+ <InputFile>\r
+ ?.txt, ?.TXT, ?.Txt\r
+\r
+ <OutputFile>\r
+ $(OUTPUT_DIR)(+)${s_base}.mcb\r
+\r
+ <Command>\r
+ GenFw -o ${dst} -m ${src}\r
+\r
+[Build.Microcode-Binary-File]\r
+ <InputFile>\r
+ *.mcb\r
+\r
+ <OutputFile>\r
+ $(OUTPUT_DIR)(+)$(MODULE_NAME).bin\r
+\r
+ <Command>\r
+ GenFw -o ${dst} -j ${src}\r
+\r
+[Build.Unicode-Text-File]\r
+ <InputFile>\r
+ *.uni, *.Uni, *.UNI\r
+\r
+ <OutputFile>\r
+ $(DEBUG_DIR)(+)AutoGen.c\r
+ $(DEBUG_DIR)(+)AutoGen.h\r
+\r
+ <Command>\r
+\r