X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FJava%2FSource%2FGenBuild%2Forg%2Ftianocore%2Fbuild%2Ffpd%2FFpdParserTask.java;h=e28ac19eca828986a16440a12ab11ccd82d81b4a;hp=7d86c64a2d82d84512252a6f33b8d503f6204c2c;hb=e799f87fe63b25127e0991b7c054f0b49dc80f6b;hpb=05b52e966543caf1ef30ed0513c8b62173db0fa4 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 7d86c64a2d..e28ac19eca 100644 --- a/Tools/Java/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java +++ b/Tools/Java/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java @@ -91,15 +91,24 @@ public class FpdParserTask extends Task { /// Map> fvs = new HashMap>(); + /// + /// Mapping from FV apriori file to its type (PEI or DXE) + /// + Map aprioriType = new HashMap(); + /// /// FpdParserTask can specify some ANT properties. /// private Vector properties = new Vector(); SurfaceAreaQuery saq = null; - - boolean isUnified = true; + boolean isUnified = true; + + public static String PEI_APRIORI_GUID = "1b45cc0a-156a-428a-af62-49864da0e6e6"; + + 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 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(); @@ -529,6 +565,14 @@ public class FpdParserTask extends Task { GlobalData.addMsaBuildOption(moduleId, parseMsaBuildOptions(false)); GlobalData.addMsaFamilyBuildOption(moduleId, parseMsaBuildOptions(true)); + ModuleIdentification[] libraryInstances = saq.getLibraryInstance(null); + for (int i = 0; i < libraryInstances.length; i++) { + saq.push(GlobalData.getDoc(libraryInstances[i], fpdModuleId.getArch())); + GlobalData.addMsaBuildOption(libraryInstances[i], parseMsaBuildOptions(false)); + GlobalData.addMsaFamilyBuildOption(libraryInstances[i], parseMsaBuildOptions(true)); + saq.pop(); + } + saq.pop(); } } @@ -680,6 +724,97 @@ public class FpdParserTask extends Task { return archs; } + private void genAprioriFile(Set modules, File file) { + try { + FileWriter fw = new FileWriter(file); + BufferedWriter bw = new BufferedWriter(fw); + + Iterator 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 getPeiApriori(String fvName) throws EdkException { + Node node = saq.getPeiApriori(fvName); + Set result = new LinkedHashSet(); + 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 getDxeApriori(String fvName) throws EdkException { + Node node = saq.getDxeApriori(fvName); + Set result = new LinkedHashSet(); + 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 getModuleSequenceForFv(String fvName) throws EdkException { Node node = saq.getFpdModuleSequence(fvName); Set result = new LinkedHashSet(); @@ -780,19 +915,26 @@ public class FpdParserTask extends Task { ToolChainInfo toolChainInfo = GlobalData.getToolChainInfo(); if (toolChainInfo.getTargets().length == 0) { - throw new EdkException("No valid target specified! Please check your TARGET definition in Tools/Conf/target.txt."); + throw new EdkException("No valid target found! "+ + "Please check the TARGET definition in Tools/Conf/target.txt, "+ + "or the , in the FPD file."); } if (toolChainInfo.getTagnames().length == 0) { - throw new EdkException("No valid tool chain specified! Please check your TOOL_CHAIN_TAG definition in Tools/Conf/target.txt."); + throw new EdkException("No valid tool chain found! "+ + "Please check the TOOL_CHAIN_TAG definition in Tools/Conf/target.txt, "+ + "or the in the FPD file."); } if (toolChainInfo.getArchs().length == 0) { - throw new EdkException("No valid ARCH specified! Please check your TARGET_ARCH definition in Tools/Conf/target.txt."); + throw new EdkException("No valid architecture found! "+ + "Please check the TARGET_ARCH definition in Tools/Conf/target.txt, "+ + "or the , in the FPD file."); } if (toolChainInfo.getCommands().length == 0) { - throw new EdkException("No valid COMMAND specified! Please check your TARGET definition in Tools/Conf/tools_def.txt."); + throw new EdkException("No valid COMMAND found! Please check the tool chain definitions "+ + "in Tools/Conf/tools_def.txt."); } } }