]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Conf/build_rule.template
Improved the file type filter
[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 ".asm" : "Masm-Code",
11 ".Asm" : "Masm-Code",
12 ".ASM" : "Masm-Code",
13 ".s" : "Iasm-Code", # IPF assembly code
14 ".S" : "Gasm-Code", # GNU assembly code
15 ".uni" : "Unicode-Text",
16 ".Uni" : "Unicode-Text",
17 ".UNI" : "Unicode-Text",
18 ".vfr" : "Visual-Form-Representation",
19 ".Vfr" : "Visual-Form-Representation",
20 ".VFR" : "Visual-Form-Representation",
21 ".dxs" : "Dependency-Expression",
22 ".Dxs" : "Dependency-Expression",
23 ".DXS" : "Dependency-Expression",
24 ".fv" : "FirmwareVolume",
25 ".Fv" : "FirmwareVolume",
26 ".FV" : "FirmwareVolume",
27 ".efi" : "Efi-Image",
28 ".Efi" : "Efi-Image",
29 ".EFI" : "Efi-Image",
30 ".SEC" : "Firmware-File-System",
31 ".PEI" : "Firmware-File-System",
32 ".DXE" : "Firmware-File-System",
33 ".APP" : "Firmware-File-System",
34 ".FYI" : "Firmware-File-System",
35 ".FFS" : "Firmware-File-System",
36 ".bmp" : "Bmp-Image",
37 ".i" : "Preprocessed-Code",
38 ".asl" : "Acpi-Source-Language",
39 ".Asl" : "Acpi-Source-Language",
40 ".ASL" : "Acpi-Source-Language",
41 ".obj" : "Object",
42 ".o" : "Object",
43 ".lib" : "Static-Library",
44 ".a" : "Static-Library",
45 ".dll" : "Dynamic-Library",
46 ".so" : "Dynamic-Library",
47 }
48
49 DefaultToolCode = ["CC", "ASM", "SLINK", "DLINK", "PCH", "PP", "ASL"]
50
51 ToolCodeMapping = {
52 "C-Code" : ["CC"],
53 "C-Header" : ["PCH"],
54 "Masm-Code" : ["PP", "ASM"],
55 "Iasm-Code" : ["PP", "ASM"], # IPF assembly code
56 "Gasm-Code" : ["ASM"], # GNU assembly code
57 "Visual-Form-Representation" : ["PP", "CC"],
58 "Preprocessed-Code" : ["CC"],
59 "Acpi-Source-Language" : ["ASL"],
60 "Object" : ["SLINK"],
61 "Static-Library" : ["DLINK"],
62 "Dependency-Expression" : ["PP"],
63 }
64
65 ToolChainFamilyMapping = {
66 "C-Code" : ["MSFT", "INTEL", "GCC"],
67 "C-Header" : ["MSFT", "INTEL", "GCC"],
68 "Masm-Code" : ["MSFT", "INTEL"],
69 "Iasm-Code" : ["MSFT", "INTEL"], # IPF assembly code
70 "Gasm-Code" : ["GCC"], # GNU assembly code
71 "Unicode-Text" : ["MSFT", "INTEL", "GCC"],
72 "Visual-Form-Representation" : ["MSFT", "INTEL", "GCC"],
73 "Dependency-Expression" : ["MSFT", "INTEL", "GCC"],
74 "FirmwareVolume" : ["MSFT", "INTEL", "GCC"],
75 "Efi-Image" : ["MSFT", "INTEL", "GCC"],
76 "Firmware-File-System" : ["MSFT", "INTEL", "GCC"],
77 "Bmp-Image" : ["MSFT", "INTEL", "GCC"],
78 "Preprocessed-Code" : ["MSFT", "INTEL"],
79 "Acpi-Source-Language" : ["MSFT", "INTEL"],
80 }
81
82 ## Build rules for makefile
83 # Placeholders for string substitution
84 # ${fpath} File path relative to $(WORKSPACE)
85 # ${fdir} File relative directory within a module
86 # ${fname} File full name without path
87 # ${fbase} File name without extension and path
88 # ${fext} File extension
89 # ${fdep} File dependencies
90 # ${sep} Directory separator
91 #
92 Makefile = {
93 "nmake" : {
94 "C-Code" : '''\
95 $(OUTPUT_DIR)${sep}${fdir}${sep}${fbase}.obj : $(COMMON_DEPS)
96 ${BEGIN}$(OUTPUT_DIR)${sep}${fdir}${sep}${fbase}.obj : $(WORKSPACE)${sep}${fdep}
97 ${END} "$(CC)" /Fo$@ $(CC_FLAGS) $(INC) $(WORKSPACE)${sep}${fpath}
98 ''',
99
100 "Masm-Code" : '''\
101 $(OUTPUT_DIR)${sep}${fdir}${sep}${fbase}.obj : $(COMMON_DEPS)
102 ${BEGIN}$(OUTPUT_DIR)${sep}${fdir}${sep}${fbase}.obj : $(WORKSPACE)${sep}${fdep}
103 ${END} "$(PP)" $(PP_FLAGS) $(INC) $(WORKSPACE)${sep}${fpath} > $(@D)${sep}${fbase}.i
104 Trim -CONVERT $(@D)${sep}${fbase}.i
105 "$(ASM)" /Fo$@ $(ASM_FLAGS) $(INC) $(@D)${sep}${fbase}.iii
106 ''',
107
108 "Iasm-Code" : '''\
109 $(OUTPUT_DIR)${sep}${fdir}${sep}${fbase}.obj : $(COMMON_DEPS)
110 ${BEGIN}$(OUTPUT_DIR)${sep}${fdir}${sep}${fbase}.obj : $(WORKSPACE)${sep}${fdep}
111 ${END} "$(APP)" $(APP_FLAGS) $(INC) $(WORKSPACE)${sep}${fpath} > $(@D)${sep}${fbase}.i
112 "$(ASM)" -o$@ $(ASM_FLAGS) $(@D)${sep}${fbase}.i
113 ''',
114
115 "Visual-Form-Representation" : '''\
116 $(OUTPUT_DIR)${sep}${fdir}${sep}${fbase}.obj : $(COMMON_DEPS)
117 ${BEGIN}$(OUTPUT_DIR)${sep}${fdir}${sep}${fbase}.obj : $(WORKSPACE)${sep}${fdep}
118 ${END}\t"$(PP)" $(VFRPP_FLAGS) $(INC) $(WORKSPACE)${sep}${fpath} > $(@D)${sep}${fbase}.i
119 \tTrim -VFR $(@D)${sep}${fbase}.i
120 \t-mkdir $(DEBUG_DIR)${sep}${fdir} > NUL 2>&1
121 \tVfrCompile -od $(DEBUG_DIR)${sep}${fdir} $(@D)${sep}${fbase}.iii
122 \t"$(CC)" /Fo$@ $(CC_FLAGS) $(INC) $(DEBUG_DIR)${sep}${fdir}${sep}${fbase}.c
123 ''',
124 },
125
126 "gmake" : {
127 "C-Code" :
128 '''$(OUTPUT_DIR)/%(fdir)s/%(fbase)s.obj : $(MODULE_DIR)/%(fdir)s/%(fname)s $(DEP_FILES)
129 \t"$(CC)" $(CC_FLAGS) $(INC) $(CC_OUTPUT)$@ $<''',
130
131 "Masm-Code" :
132 '''$(OUTPUT_DIR)/%(fdir)s/%(fbase)s.obj : $(MODULE_DIR)/%(fdir)s/%(fname)s $(DEP_FILES)
133 \t"$(PP)" $(PP_FLAGS) $(INC) $? $(PP_OUTPUT)$(@D)/%(fbase)s.i
134 \tTrim -CONVERT $(@D)/%(fbase)s.i
135 \t"$(ASM)" $(ASM_FLAGS) $(ASM_OUTPUT)$@ $(@D)/%(fbase)s.iii''',
136
137 "Gasm-Code" :
138 '''$(OUTPUT_DIR)/%(fdir)s/%(fbase)s.obj : $(MODULE_DIR)/%(fdir)s/%(fname)s $(DEP_FILES)
139 \t"$(ASM)" $(ASM_FLAGS) $(INC) $(ASM_OUTPUT)$@ $<''',
140
141 "Iasm-Code" :
142 '''$(OUTPUT_DIR)/%(fdir)s/%(fbase)s.obj : $(MODULE_DIR)/%(fdir)s/%(fname)s $(DEP_FILES)
143 \t"$(APP)" $(APP_FLAGS) $(INC) $< $(PP_OUTPUT)$(@D)/%(fbase)s.i
144 \t"$(ASM)" $(ASM_FLAGS) $(ASM_OUTPUT)$@ $(@D)/%(fbase)s.i''',
145
146 "Visual-Form-Representation" :
147 '''$(OUTPUT_DIR)/%(fdir)s/%(fbase)s.obj : $(MODULE_DIR)/%(fdir)s/%(fname)s $(DEP_FILES)
148 \t"$(PP)" $(PP_FLAGS) $(INC) $< $(PP_OUTPUT)$(@D)/%(fbase)s.i
149 \t"$(VFRC)" $(VFRC_FLAGS) $(INC) $(VFRC_OUTPUT)$(DEBUG_DIR)/%(fdir)s/%(fbase)s.c $(@D)/%(fbase)s.i
150 \t"$(CC)" $(CC_FLAGS) $(INC) $(CC_OUTPUT)$@ $(DEBUG_DIR)/%(fdir)s/%(fbase)s.c''',
151 }
152 }
153
154 # This acts like the main() function for the script, unless it is 'import'ed into another
155 # script.
156 if __name__ == '__main__':
157 for ext in FileTypeMapping:
158 print ext,":",FileTypeMapping[ext]
159
160 for type in Makefile["nmake"]:
161 print "[",type,"]\n",Makefile["nmake"][type]
162 print
163
164 for type in Makefile["gmake"]:
165 print "[",type,"]\n",Makefile["gmake"][type]
166 print
167