diff options
author | wuyizhong <wuyizhong@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-11-14 07:15:01 +0000 |
---|---|---|
committer | wuyizhong <wuyizhong@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-11-14 07:15:01 +0000 |
commit | 380191dd245730b79c399728b4e476d08df0e62f (patch) | |
tree | 38034765accab4f91a353d86fea6eadaa99679f3 /Tools/Java | |
parent | ed7aa83f2e64b8e6be0600b06e93fd3987a62fa6 (diff) | |
download | edk2-platforms-380191dd245730b79c399728b4e476d08df0e62f.tar.xz |
Supporting Apriori File from build tool.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1949 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Tools/Java')
4 files changed, 195 insertions, 6 deletions
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/fpd/FpdParserForThread.java b/Tools/Java/Source/GenBuild/org/tianocore/build/fpd/FpdParserForThread.java index 286933f8ca..ac930f1257 100644 --- a/Tools/Java/Source/GenBuild/org/tianocore/build/fpd/FpdParserForThread.java +++ b/Tools/Java/Source/GenBuild/org/tianocore/build/fpd/FpdParserForThread.java @@ -121,7 +121,7 @@ public class FpdParserForThread extends FpdParserTask { // Gen build.xml
//
String platformBuildFile = buildDir + File.separatorChar + platformId.getName() + "_build.xml";
- PlatformBuildFileGenerator fileGenerator = new PlatformBuildFileGenerator(getProject(), outfiles, fvs, isUnified, saq, platformBuildFile);
+ PlatformBuildFileGenerator fileGenerator = new PlatformBuildFileGenerator(getProject(), outfiles, fvs, isUnified, saq, platformBuildFile, aprioriType);
fileGenerator.genBuildFile();
//
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java b/Tools/Java/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java index 9a4d93a89b..76185f05bb 100644 --- a/Tools/Java/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java +++ b/Tools/Java/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java @@ -92,14 +92,23 @@ public class FpdParserTask extends Task { Map<String, Set<FpdModuleIdentification>> fvs = new HashMap<String, Set<FpdModuleIdentification>>();
///
+ /// Mapping from FV apriori file to its type (PEI or DXE)
+ ///
+ Map<String, String> aprioriType = new HashMap<String, String>();
+
+ ///
/// FpdParserTask can specify some ANT properties.
///
private Vector<Property> properties = new Vector<Property>();
SurfaceAreaQuery saq = null;
-
- boolean isUnified = true;
+ boolean isUnified = true;
+
+ public static String PEI_APRIORI_GUID = "00000000-0000-0000-0000-000000000000";
+
+ public static String DXE_APRIORI_GUID = "fc510ee7-ffdc-11d4-bd41-0080c73c8881";
+
/**
Public construct method. It is necessary for ANT task.
**/
@@ -163,7 +172,7 @@ public class FpdParserTask extends Task { // Gen build.xml
//
String platformBuildFile = buildDir + File.separatorChar + platformId.getName() + "_build.xml";
- PlatformBuildFileGenerator fileGenerator = new PlatformBuildFileGenerator(getProject(), outfiles, fvs, isUnified, saq, platformBuildFile);
+ PlatformBuildFileGenerator fileGenerator = new PlatformBuildFileGenerator(getProject(), outfiles, fvs, isUnified, saq, platformBuildFile, aprioriType);
fileGenerator.genBuildFile();
//
@@ -318,6 +327,33 @@ public class FpdParserTask extends Task { if (files != null) {
bw.write("[files]");
bw.newLine();
+
+ Set<FpdModuleIdentification> modules = null;
+
+ if ( (modules = getPeiApriori(validFv[i])) != null) {
+ //
+ // Special GUID - validFv[i].FFS
+ //
+ String str = ffsCommonDir + File.separatorChar + "FV" + File.separatorChar + PEI_APRIORI_GUID + "-" + validFv[i] + ".FFS";
+ bw.write(getProject().replaceProperties("EFI_FILE_NAME = " + str));
+ bw.newLine();
+
+ File aprioriFile = new File(getProject().getProperty("FV_DIR") + File.separatorChar + validFv[i] + ".apr");
+ aprioriType.put(validFv[i], PEI_APRIORI_GUID);
+ genAprioriFile(modules, aprioriFile);
+ } else if((modules = getDxeApriori(validFv[i])) != null) {
+ //
+ // Special GUID - validFv[i].FFS
+ //
+ String str = ffsCommonDir + File.separatorChar + "FV" + File.separatorChar + DXE_APRIORI_GUID + "-" + validFv[i] + ".FFS";
+ bw.write(getProject().replaceProperties("EFI_FILE_NAME = " + str));
+ bw.newLine();
+
+ File aprioriFile = new File(getProject().getProperty("FV_DIR") + File.separatorChar + validFv[i] + ".apr");
+ aprioriType.put(validFv[i], DXE_APRIORI_GUID);
+ genAprioriFile(modules, aprioriFile);
+ }
+
for (int j = 0; j < files.length; j++) {
String str = ffsCommonDir + File.separatorChar + outfiles.get(files[j]);
bw.write(getProject().replaceProperties("EFI_FILE_NAME = " + str));
@@ -375,7 +411,7 @@ public class FpdParserTask extends Task { }
String platformBuildFile = buildDir + File.separatorChar + platformId.getName() + "_build.xml";
- PlatformBuildFileGenerator fileGenerator = new PlatformBuildFileGenerator(getProject(), outfiles, fvs, isUnified, saq, platformBuildFile);
+ PlatformBuildFileGenerator fileGenerator = new PlatformBuildFileGenerator(getProject(), outfiles, fvs, isUnified, saq, platformBuildFile, aprioriType);
fileGenerator.genBuildFile();
Ant ant = new Ant();
@@ -688,6 +724,97 @@ public class FpdParserTask extends Task { return archs;
}
+ private void genAprioriFile(Set<FpdModuleIdentification> modules, File file) {
+ try {
+ FileWriter fw = new FileWriter(file);
+ BufferedWriter bw = new BufferedWriter(fw);
+
+ Iterator<FpdModuleIdentification> iter = modules.iterator();
+ while(iter.hasNext()) {
+ bw.write(iter.next().getModule().getGuid());
+ bw.newLine();
+ }
+
+ bw.flush();
+ bw.close();
+ fw.close();
+ } catch (IOException ex) {
+ BuildException buildException = new BuildException("Generation of the Apriori file [" + file.getPath() + "] failed!\n" + ex.getMessage());
+ buildException.setStackTrace(ex.getStackTrace());
+ throw buildException;
+ }
+ }
+
+ private Set<FpdModuleIdentification> getPeiApriori(String fvName) throws EdkException {
+ Node node = saq.getPeiApriori(fvName);
+ Set<FpdModuleIdentification> result = new LinkedHashSet<FpdModuleIdentification>();
+ if (node == null) {
+ return null;
+ }
+
+ NodeList childNodes = node.getChildNodes();
+ for (int i = 0; i < childNodes.getLength(); i++) {
+ Node childItem = childNodes.item(i);
+ if (childItem.getNodeType() == Node.ELEMENT_NODE) {
+ //
+ // Find child elements "IncludeModules"
+ //
+ if (childItem.getNodeName().compareTo("IncludeModules") == 0) {
+ //
+ // result will be updated
+ //
+ processNodes(childItem, result);
+ } else if (childItem.getNodeName().compareTo("FvName") == 0) {
+
+ } else if (childItem.getNodeName().compareTo("InfFileName") == 0) {
+
+ } else {
+ //
+ // Report Warning
+ //
+ EdkLog.log(this, EdkLog.EDK_WARNING, "Unrecognised element " + childItem.getNodeName() + " under FPD.BuildOptions.UserExtensions[UserID='APRIORI' Identifier='0']");
+ }
+ }
+ }
+
+ return result;
+ }
+
+ private Set<FpdModuleIdentification> getDxeApriori(String fvName) throws EdkException {
+ Node node = saq.getDxeApriori(fvName);
+ Set<FpdModuleIdentification> result = new LinkedHashSet<FpdModuleIdentification>();
+ if (node == null) {
+ return null;
+ }
+
+ NodeList childNodes = node.getChildNodes();
+ for (int i = 0; i < childNodes.getLength(); i++) {
+ Node childItem = childNodes.item(i);
+ if (childItem.getNodeType() == Node.ELEMENT_NODE) {
+ //
+ // Find child elements "IncludeModules"
+ //
+ if (childItem.getNodeName().compareTo("IncludeModules") == 0) {
+ //
+ // result will be updated
+ //
+ processNodes(childItem, result);
+ } else if (childItem.getNodeName().compareTo("FvName") == 0) {
+
+ } else if (childItem.getNodeName().compareTo("InfFileName") == 0) {
+
+ } else {
+ //
+ // Report Warning
+ //
+ EdkLog.log(this, EdkLog.EDK_WARNING, "Unrecognised element " + childItem.getNodeName() + " under FPD.BuildOptions.UserExtensions[UserID='APRIORI' Identifier='1']");
+ }
+ }
+ }
+
+ return result;
+ }
+
private Set<FpdModuleIdentification> getModuleSequenceForFv(String fvName) throws EdkException {
Node node = saq.getFpdModuleSequence(fvName);
Set<FpdModuleIdentification> result = new LinkedHashSet<FpdModuleIdentification>();
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/fpd/PlatformBuildFileGenerator.java b/Tools/Java/Source/GenBuild/org/tianocore/build/fpd/PlatformBuildFileGenerator.java index d4b4622c60..1e5c7744b5 100644 --- a/Tools/Java/Source/GenBuild/org/tianocore/build/fpd/PlatformBuildFileGenerator.java +++ b/Tools/Java/Source/GenBuild/org/tianocore/build/fpd/PlatformBuildFileGenerator.java @@ -64,6 +64,8 @@ public class PlatformBuildFileGenerator { private File platformBuildFile = null;
+ private Map<String, String> aprioriType = null;
+
private Project project;
private String info = "DO NOT EDIT \n"
@@ -72,13 +74,14 @@ public class PlatformBuildFileGenerator { + "Abstract:\n"
+ "Auto-generated ANT build file for building EFI Modules and Platforms\n";
- public PlatformBuildFileGenerator(Project project, Map<FpdModuleIdentification, String> outfiles, Map<String, Set<FpdModuleIdentification>> fvs, boolean isUnified, SurfaceAreaQuery saq, String platformBuildFile){
+ public PlatformBuildFileGenerator(Project project, Map<FpdModuleIdentification, String> outfiles, Map<String, Set<FpdModuleIdentification>> fvs, boolean isUnified, SurfaceAreaQuery saq, String platformBuildFile, Map<String, String> aprioriType){
this.project = project;
this.outfiles = outfiles;
this.isUnified = isUnified;
this.fvs = fvs;
this.saq = saq;
this.platformBuildFile = new File(platformBuildFile);
+ this.aprioriType = aprioriType;
}
/**
@@ -194,6 +197,39 @@ public class PlatformBuildFileGenerator { ele.setAttribute("name", "modules");
//
+ // Try to build apriori if necessary
+ //
+ //
+ // For every Target and ToolChain
+ //
+ String[] targetList = GlobalData.getToolChainInfo().getTargets();
+ for (int i = 0; i < targetList.length; i++){
+ String[] toolchainList = GlobalData.getToolChainInfo().getTagnames();
+ for(int j = 0; j < toolchainList.length; j++){
+ //
+ // Prepare FV_DIR
+ //
+ String ffsCommonDir = project.getProperty("BUILD_DIR") + File.separatorChar
+ + targetList[i] + "_"
+ + toolchainList[j];
+ File fvDir = new File(ffsCommonDir + File.separatorChar + "FV");
+ Element fvEle = document.createElement("var");
+ fvEle.setAttribute("name", "FV_DIR");
+ fvEle.setAttribute("value", fvDir.getPath().replaceAll("(\\\\)", "/"));
+ ele.appendChild(fvEle);
+
+ Iterator<String> aprIter = aprioriType.keySet().iterator();
+ while (aprIter.hasNext()) {
+ String fvName = aprIter.next();
+ Element moduleEle = document.createElement("Build_Apriori");
+ moduleEle.setAttribute("FILENAME", fvName);
+ moduleEle.setAttribute("GUID", aprioriType.get(fvName));
+ ele.appendChild(moduleEle);
+ }
+ }
+ }
+
+ //
// Get all valid FV name
//
String[] validFv = saq.getFpdValidImageNames();
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java b/Tools/Java/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java index cf31873a98..9e4c445508 100644 --- a/Tools/Java/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java +++ b/Tools/Java/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java @@ -2011,6 +2011,32 @@ public class SurfaceAreaQuery { }
}
+ public Node getPeiApriori(String fvName) {
+ String[] xPath = new String[] { "/BuildOptions/UserExtensions[@UserID='APRIORI' and @Identifier='0' and ./FvName='" + fvName + "']" };
+ Object[] result = get("PlatformSurfaceArea", xPath);
+
+ if (result == null || result.length == 0) {
+ return null;
+ }
+
+ UserExtensionsDocument.UserExtensions a = (UserExtensionsDocument.UserExtensions)result[0];
+
+ return a.getDomNode();
+ }
+
+ public Node getDxeApriori(String fvName) {
+ String[] xPath = new String[] { "/BuildOptions/UserExtensions[@UserID='APRIORI' and @Identifier='1' and ./FvName='" + fvName + "']" };
+ Object[] result = get("PlatformSurfaceArea", xPath);
+
+ if (result == null || result.length == 0) {
+ return null;
+ }
+
+ UserExtensionsDocument.UserExtensions a = (UserExtensionsDocument.UserExtensions)result[0];
+
+ return a.getDomNode();
+ }
+
public Node getFpdModuleSequence(String fvName) {
String[] xPath = new String[] { "/BuildOptions/UserExtensions[@UserID='IMAGES' and @Identifier='1' and ./FvName='" + fvName + "']" };
Object[] result = get("PlatformSurfaceArea", xPath);
|