import java.io.File;\r
import java.util.Set;\r
\r
+import org.apache.tools.ant.BuildException;\r
import org.apache.tools.ant.Project;\r
import org.w3c.dom.Document;\r
import org.w3c.dom.Element;\r
by its extension. Following is the current supported extensions. </p>\r
\r
<pre> \r
- .c | C_Code\r
- .asm | Assembly\r
- .s | IPF_Assembly_Code\r
- .h | Header\r
- .lib | Static_Library\r
- .i | IPF_PP_Code\r
- .vfr | Vfr\r
- .uni | Unicode\r
- .dxs | Dependency_File\r
- .bmp | Graphics\r
- .efi | EFI\r
+ Source File Suffix File Type Description\r
+ .h CHeader C header file\r
+ .c CCode C source file\r
+ .inc ASMHeader Assembly header file\r
+ .asm ASM Assembly source file, usually for IA32 and X64 Arch and MSFT tool chain\r
+ .S ASM Assembly source file, usually for IPF Arch\r
+ .s ASM Assembly source file, usually for IA32 and X64 Arch and GCC tool chain\r
+ .uni UNI Unicode file\r
+ .vfr VFR Visual Forms Representation File\r
+ .fv FV Firmware Volume\r
+ .SEC FFS Firmware File System file\r
+ .PEI FFS Firmware File System file\r
+ .DXE FFS Firmware File System file\r
+ .APP FFS Firmware File System file\r
+ .FVI FFS Firmware File System file\r
+ .FFS FFS Firmware File System file\r
+ .bmp BMP Graphic File\r
+ .i PPCode IPF PreProcessor Code\r
</pre>\r
\r
@since GenBuild 1.0\r
///\r
/// The mapping information about source suffix, result suffix, file type.\r
///\r
- public final String[][] fileTypes = { { ".c", ".obj", "C_Code" }, { ".asm", ".obj", "Assembly" },\r
- { ".s", ".obj", "IPF_Assembly_Code" }, { ".h", "", "Header" },\r
- { ".lib", "", "Static_Library" }, { ".src", ".c", "" },\r
- { ".i", ".obj", "IPF_PP_Code" }, { ".vfr", ".obj", "Vfr" },\r
- { ".uni", "", "Unicode" }, { ".dxs", "", "Dependency_File" },\r
- { ".bmp", "", "Graphics" }, { ".efi", "", "EFI" } };\r
-\r
+ public final String[][] fileTypes = { {".h", "", "CHeader" }, \r
+ {".c", "", "CCode" },\r
+ {".inc", "", "ASMHeader" },\r
+ {".asm", "", "ASM" }, \r
+ {".S", "", "ASM" },\r
+ {".s", "", "ASM" },\r
+ {".uni", "", "UNI" },\r
+ {".vfr", "", "VFR" },\r
+ {".dxs", "", "DPX"},\r
+ {".fv", "", "FV" },\r
+ {".efi", "", "EFI" },\r
+ {".SEC", "", "FFS" },\r
+ {".PEI", "", "FFS" },\r
+ {".DXE", "", "FFS" },\r
+ {".APP", "", "FFS" },\r
+ {".FYI", "", "FFS" },\r
+ {".FFS", "", "FFS" },\r
+ {".bmp", "", "BMP" },\r
+ {".i", "", "PPCode"}};\r
///\r
/// Current ANT context. \r
///\r
/// Current module's include pathes\r
///\r
private Set<String> includes;\r
-\r
- ///\r
- /// Current source files. \r
- ///\r
- private Set<String> sourceFiles;\r
\r
///\r
/// Xml Document.\r
@param sourceFiles Modules source files\r
@param document XML document\r
**/\r
- public void init(Project project, Set<String> includes, Set<String> sourceFiles, Document document) {\r
+ public void init(Project project, Set<String> includes, Document document) {\r
this.document = document;\r
this.includes = includes;\r
this.project = project;\r
- this.sourceFiles = sourceFiles;\r
}\r
\r
/**\r
@param filename Source file name\r
@param root Root node\r
**/\r
- public synchronized void parseFile(String filename, Node root) {\r
+ public synchronized void parseFile(String filename, Node root) throws BuildException {\r
boolean flag = false;\r
for (int i = 0; i < fileTypes.length; i++) {\r
- if (filename.toLowerCase().endsWith(fileTypes[i][0])) {\r
+ if (filename.endsWith(fileTypes[i][0])) {\r
flag = true;\r
parseFile(filename, fileTypes[i][2], root);\r
}\r
}\r
if (!flag) {\r
- System.out.println("Warning: File " + filename + " is not known from its suffix.");\r
+ throw new BuildException("File [" + filename + "] is not known from its suffix.");\r
}\r
}\r
\r
**/\r
public synchronized void parseFile(String filename, String filetype, Node root) {\r
if (unicodeFirst) {\r
- if ( ! filetype.equalsIgnoreCase("Unicode")){\r
+ if ( ! filetype.equalsIgnoreCase("UNI")){\r
return ;\r
}\r
unicodeExist= true;\r
} else {\r
- if (filetype.equalsIgnoreCase("Unicode")){\r
+ if (filetype.equalsIgnoreCase("UNI")){\r
return ;\r
}\r
}\r
- sourceFiles.add(filename);\r
- if (filetype.equalsIgnoreCase("Header")) {\r
+ \r
+ //\r
+ // If file is C or ASM header file, skip it\r
+ //\r
+ if (filetype.equalsIgnoreCase("CHeader") || filetype.equalsIgnoreCase("ASMHeader")) {\r
return;\r
}\r
- if (filetype.equalsIgnoreCase("IPF_PP_Code")) {\r
+ \r
+ //\r
+ // If file is pre-processor file, skip it\r
+ // \r
+ if (filetype.equalsIgnoreCase("PPCode")) {\r
return;\r
}\r
+ \r
+ //\r
+ // If define CC_EXT in tools_def.txt file, the source file with \r
+ // different suffix is skipped\r
+ //\r
+ String toolsDefExtName = project.getProperty(filetype + "_EXT");\r
+ if (toolsDefExtName != null) {\r
+ String[] exts = toolsDefExtName.split(" ");\r
+ for (int i = 0; i < exts.length; i++) {\r
+ if ( ! filename.endsWith(exts[i])) {\r
+ return ;\r
+ }\r
+ }\r
+ }\r
+ \r
String module_path = project.getProperty("MODULE_DIR");\r
File moduleFile = new File(module_path);\r
File sourceFile = new File(filename);\r
+ \r
+ //\r
// If source file is AutoGen.c, then Filepath is .\r
- String sourceFilepath;\r
- String sourceFilename;\r
+ //\r
+ String sourceFilepath = "";\r
+ String sourceFilename = "";\r
+ String sourceFileext = "";\r
if (sourceFile.getPath().endsWith("AutoGen.c")) {\r
sourceFilepath = ".";\r
sourceFilename = "AutoGen";\r
+ sourceFileext = ".c";\r
filetype = "AUTOGEN";\r
} else {\r
// sourceFile.\r
index = str.lastIndexOf('.');\r
if (index > 0) {\r
sourceFilename = str.substring(0, index);\r
+ sourceFileext = str.substring(index);\r
}\r
}\r
// <Build_filetype FILEPATH="" FILENAME="" />\r
Element ele = document.createElement("Build_" + filetype);\r
ele.setAttribute("FILEPATH", sourceFilepath);\r
ele.setAttribute("FILENAME", sourceFilename);\r
+ ele.setAttribute("FILEEXT", sourceFileext.substring(1));\r
String[] includePaths = includes.toArray(new String[includes.size()]);\r
Element includesEle = document.createElement("EXTRA.INC");\r
for (int i = 0; i < includePaths.length; i++) {\r