X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FSource%2FGenBuild%2Forg%2Ftianocore%2Fbuild%2FModuleBuildFileGenerator.java;h=df1af186bf8960b4b4748e1d4b14c7db40d33a93;hp=7d8bf8b59e11d64d8df5937d70c2c0969666a71e;hb=391dbbb1c00daefe78e7e44499d048943ca866ae;hpb=de4bb9f6edc1db82e0616b24e6685b27d2b66061 diff --git a/Tools/Source/GenBuild/org/tianocore/build/ModuleBuildFileGenerator.java b/Tools/Source/GenBuild/org/tianocore/build/ModuleBuildFileGenerator.java index 7d8bf8b59e..df1af186bf 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/ModuleBuildFileGenerator.java +++ b/Tools/Source/GenBuild/org/tianocore/build/ModuleBuildFileGenerator.java @@ -16,6 +16,8 @@ import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; +import java.io.FileOutputStream; +import java.io.OutputStreamWriter; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -52,10 +54,10 @@ public class ModuleBuildFileGenerator { /// The information at the header of build.xml. /// private String info = "DO NOT EDIT \n" - + "File auto-generated by build utility\n" + + "This file is auto-generated by the build utility\n" + "\n" + "Abstract:\n" - + "Auto-generated ANT build file for building of EFI Modules/Platforms\n"; + + "Auto-generated ANT build file for build EFI Modules and Platforms\n"; private FpdModuleIdentification fpdModuleId; @@ -211,7 +213,8 @@ public class ModuleBuildFileGenerator { // generate all directory path // (new File(file.getParent())).mkdirs(); - Result result = new StreamResult(file); + FileOutputStream outputStream = new FileOutputStream(file); + Result result = new StreamResult(new OutputStreamWriter(outputStream)); // // Write the DOM document to the file @@ -221,8 +224,7 @@ public class ModuleBuildFileGenerator { xformer.setOutputProperty(OutputKeys.INDENT, "yes"); xformer.transform(source, result); } catch (Exception ex) { - ex.printStackTrace(); - throw new BuildException("Module [" + fpdModuleId.getModule().getName() + "] generating build file failed.\n" + ex.getMessage()); + throw new BuildException("Generating the module [" + fpdModuleId.getModule().getName() + "] build.xml file failed!.\n" + ex.getMessage()); } } @@ -233,41 +235,6 @@ public class ModuleBuildFileGenerator { @param root Root element for current **/ private void applyCleanElement(Document document, Node root) { - ModuleIdentification[] libinstances = SurfaceAreaQuery.getLibraryInstance(fpdModuleId.getArch()); - for (int i = 0; i < libinstances.length; i++) { - // - // Put package file path to module identification - // - PackageIdentification packageId = libinstances[i].getPackage(); - - // - // Generate ANT script to clean - // - Element ele = document.createElement("GenBuild"); - ele.setAttribute("type", "clean"); - - // - // Prepare pass down information - // - Map passDownMap = new LinkedHashMap(); - for (int j = 0; j < inheritProperties.length; j ++){ - passDownMap.put(inheritProperties[j], "${" + inheritProperties[j] + "}"); - } - passDownMap.put("MODULE_GUID", libinstances[i].getGuid()); - passDownMap.put("MODULE_VERSION", libinstances[i].getVersion()); - - passDownMap.put("PACKAGE_GUID", packageId.getGuid()); - passDownMap.put("PACKAGE_VERSION", packageId.getVersion()); - - for (int j = 0; j < inheritProperties.length; j ++){ - Element property = document.createElement("property"); - property.setAttribute("name", inheritProperties[j]); - property.setAttribute("value", passDownMap.get(inheritProperties[j])); - ele.appendChild(property); - } - - root.appendChild(ele); - } // // // @@ -290,42 +257,6 @@ public class ModuleBuildFileGenerator { @param root Root element for current **/ private void applyDeepcleanElement(Document document, Node root) { - ModuleIdentification[] libinstances = SurfaceAreaQuery.getLibraryInstance(fpdModuleId.getArch()); - for (int i = 0; i < libinstances.length; i++) { - // - // Put package file path to module identification - // - PackageIdentification packageId = libinstances[i].getPackage(); - - // - // Generate ANT script to clean - // - Element ele = document.createElement("GenBuild"); - ele.setAttribute("type", "cleanall"); - - // - // Prepare pass down information - // - Map passDownMap = new LinkedHashMap(); - for (int j = 0; j < inheritProperties.length; j ++){ - passDownMap.put(inheritProperties[j], "${" + inheritProperties[j] + "}"); - } - - passDownMap.put("MODULE_GUID", libinstances[i].getGuid()); - passDownMap.put("MODULE_VERSION", libinstances[i].getVersion()); - - passDownMap.put("PACKAGE_GUID", packageId.getGuid()); - passDownMap.put("PACKAGE_VERSION", packageId.getVersion()); - - for (int j = 0; j < inheritProperties.length; j ++){ - Element property = document.createElement("property"); - property.setAttribute("name", inheritProperties[j]); - property.setAttribute("value", passDownMap.get(inheritProperties[j])); - ele.appendChild(property); - } - - root.appendChild(ele); - } // // // @@ -362,7 +293,6 @@ public class ModuleBuildFileGenerator { **/ private void applyLibraryInstance(Document document, Node root) { ModuleIdentification[] libinstances = SurfaceAreaQuery.getLibraryInstance(fpdModuleId.getArch()); -// String propertyLibs = ""; for (int i = 0; i < libinstances.length; i++) { // // Put package file path to module identification @@ -374,7 +304,6 @@ public class ModuleBuildFileGenerator { // Element ele = document.createElement("GenBuild"); ele.setAttribute("type", "build"); -// ele.setAttribute("inheritAll", "false"); // // Prepare pass down information @@ -398,11 +327,23 @@ public class ModuleBuildFileGenerator { } root.appendChild(ele); -// propertyLibs += " " + project.getProperty("BIN_DIR") + File.separatorChar + libinstances[i].getName() + ".lib"; } -// project.setProperty("LIBS", propertyLibs.replaceAll("(\\\\)", "/")); } + /** + Return the name of the directory that corresponds to the architecture. + This is a translation from the XML Schema tag to a directory that + corresponds to our directory name coding convention. + + **/ + private String archDir(String arch) { + return arch.replaceFirst("X64", "x64") + .replaceFirst("IPF", "Ipf") + .replaceFirst("IA32", "Ia32") + .replaceFirst("ARM", "Arm") + .replaceFirst("EBC", "Ebc"); + } + /** Generate the build source files elements for BaseName_build.xml. @@ -414,17 +355,18 @@ public class ModuleBuildFileGenerator { // Prepare the includes: PackageDependencies and Output debug direactory // Set includes = new LinkedHashSet(); + String arch = project.getProperty("ARCH"); // // WORKSPACE // - includes.add("${WORKSPACE_DIR}"); + includes.add("${WORKSPACE_DIR}" + File.separatorChar); // // Module iteself // includes.add("${MODULE_DIR}"); - includes.add("${MODULE_DIR}" + File.separatorChar + "${ARCH}"); + includes.add("${MODULE_DIR}" + File.separatorChar + archDir(arch)); // // Packages in PackageDenpendencies @@ -434,7 +376,7 @@ public class ModuleBuildFileGenerator { GlobalData.refreshPackageIdentification(packageDependencies[i]); File packageFile = packageDependencies[i].getSpdFile(); includes.add(packageFile.getParent() + File.separatorChar + "Include"); - includes.add(packageFile.getParent() + File.separatorChar + "Include" + File.separatorChar + "${ARCH}"); + includes.add(packageFile.getParent() + File.separatorChar + "Include" + File.separatorChar + archDir(arch)); } // @@ -448,7 +390,7 @@ public class ModuleBuildFileGenerator { GlobalData.refreshPackageIdentification(libraryPackageDependencies[j]); File packageFile = libraryPackageDependencies[j].getSpdFile(); includes.add(packageFile.getParent() + File.separatorChar + "Include"); - includes.add(packageFile.getParent() + File.separatorChar + "Include" + File.separatorChar + "${ARCH}"); + includes.add(packageFile.getParent() + File.separatorChar + "Include" + File.separatorChar + archDir(arch)); } SurfaceAreaQuery.pop(); } @@ -458,7 +400,7 @@ public class ModuleBuildFileGenerator { // The package which the module belongs to // TBD includes.add(fpdModuleId.getModule().getPackage().getPackageDir() + File.separatorChar + "Include"); - includes.add(fpdModuleId.getModule().getPackage().getPackageDir() + File.separatorChar + "Include" + File.separatorChar + "${ARCH}"); + includes.add(fpdModuleId.getModule().getPackage().getPackageDir() + File.separatorChar + "Include" + File.separatorChar + archDir(arch)); // // Debug files output directory @@ -472,6 +414,12 @@ public class ModuleBuildFileGenerator { FileProcess fileProcess = new FileProcess(); fileProcess.init(project, includes, document); + + // + // Initialize some properties by user + // + Element initEle = document.createElement("Build_Init"); + root.appendChild(initEle); String moduleDir = project.getProperty("MODULE_DIR"); // @@ -550,7 +498,7 @@ public class ModuleBuildFileGenerator { return ; } if (fp.initSections(ffsKeyword, project, fpdModuleId)) { - String targetFilename = fpdModuleId.getModule().getGuid() + "-" + fpdModuleId.getModule().getName() + FpdParserTask.getSuffix(fpdModuleId.getModule().getModuleType()); + String targetFilename = fpdModuleId.getModule().getGuid() + "-" + "${BASE_NAME}" + FpdParserTask.getSuffix(fpdModuleId.getModule().getModuleType()); String[] list = fp.getGenSectionElements(document, "${BASE_NAME}", fpdModuleId.getModule().getGuid(), targetFilename); for (int i = 0; i < list.length; i++) {