X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FSource%2FGenBuild%2Forg%2Ftianocore%2Fbuild%2Fglobal%2FSurfaceAreaQuery.java;h=149b30dd173e88fb7946e4b21eeb629bc55a7e25;hp=0b16e30df3bbb2953c34c499728dcc12447792a2;hb=8cf5da75ce5bf66f1ef5a495a41fdcc0a51f7138;hpb=80785fd5be587d420174dc35d6af4ada06ed2f0f diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java b/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java index 0b16e30df3..149b30dd17 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java +++ b/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java @@ -23,7 +23,6 @@ import java.util.Stack; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.xmlbeans.XmlCursor; import org.apache.xmlbeans.XmlObject; import org.apache.xmlbeans.XmlString; import org.tianocore.BuildOptionsDocument; @@ -278,9 +277,8 @@ public class SurfaceAreaQuery { Filename[] sourceFileNames = (Filename[]) returns; List outputList = new ArrayList(); for (int i = 0; i < sourceFileNames.length; i++) { - @SuppressWarnings("unchecked") - List archList = sourceFileNames[i].getSupArchList(); - if (arch == null || arch.equalsIgnoreCase("") || archList == null || archList.contains(arch)) { + List archList = sourceFileNames[i].getSupArchList(); + if (arch == null || arch.equalsIgnoreCase("") || archList == null || contains(archList, arch)) { outputList.add(new String[] {sourceFileNames[i].getToolCode(),sourceFileNames[i].getStringValue()}); } } @@ -399,7 +397,6 @@ public class SurfaceAreaQuery { String toolchainFamily = null; List archList = null; String cmd = null; - String targetName = null; String optionName = null; Object[] returns = get(from, xPath); @@ -444,20 +441,16 @@ public class SurfaceAreaQuery { } archList = new ArrayList(); - @SuppressWarnings("unchecked") - List archEnumList = option.getSupArchList(); + List archEnumList = option.getSupArchList(); if (archEnumList == null) { archList.add(null); } else { - archList.addAll(archEnumList); - /* + //archList.addAll(archEnumList); Iterator it = archEnumList.iterator(); while (it.hasNext()) { - System.out.println(it.next().getClass().getName()); - SupportedArchitectures.Enum archType = it.next(); - archList.add(archType.toString()); + String archType = (String)it.next(); + archList.add(archType); } - */ } cmd = option.getToolCode(); @@ -568,19 +561,30 @@ public class SurfaceAreaQuery { if (returns == null) { return new PackageIdentification[0]; } - PackageIdentification[] packageIdList = new PackageIdentification[returns.length]; + + // + // Get packageIdentification + // + List packageIdList = new ArrayList(); for (int i = 0; i < returns.length; i++) { PackageDependenciesDocument.PackageDependencies.Package item = (PackageDependenciesDocument.PackageDependencies.Package) returns[i]; - @SuppressWarnings("unchecked") - List archList = item.getSupArchList(); - if (arch == null || archList == null || archList.contains(arch)) { + List archList = item.getSupArchList(); + if (arch == null || archList == null || contains(archList, arch)) { packageGuid = item.getPackageGuid(); packageVersion = item.getPackageVersion(); - packageIdList[i] = (new PackageIdentification(null, packageGuid, + packageIdList.add(new PackageIdentification(null, packageGuid, packageVersion)); } } - return packageIdList; + + // + // transfer packageIdentification list to array. + // + PackageIdentification[] packageIdArray = new PackageIdentification[packageIdList.size()]; + for (int i = 0; i < packageIdList.size(); i++) { + packageIdArray[i] = new PackageIdentification(null, packageIdList.get(i).getGuid(),packageIdList.get(i).getVersion()); + } + return packageIdArray; } /** @@ -593,9 +597,8 @@ public class SurfaceAreaQuery { * xpath * @returns null if nothing is there */ - public static String[] getLibraryClasses(String usage) { + public static String[] getLibraryClasses(String usage, String arch) { String[] xPath; - if (usage == null || usage.equals("")) { xPath = new String[] { "/LibraryClass" }; } else { @@ -608,11 +611,19 @@ public class SurfaceAreaQuery { } LibraryClassDocument.LibraryClass[] libraryClassList = (LibraryClassDocument.LibraryClass[]) returns; - String[] libraryClassName = new String[libraryClassList.length]; + List libraryClassName = new ArrayList(); for (int i = 0; i < libraryClassList.length; i++) { - libraryClassName[i] = libraryClassList[i].getKeyword(); + List archList = libraryClassList[i].getSupArchList(); + + if (arch == null || contains(archList, arch)) { + libraryClassName.add(libraryClassList[i].getKeyword()); + } } - return libraryClassName; + String[] libraryArray = new String[libraryClassName.size()]; + for (int i = 0; i < libraryClassName.size(); i++) { + libraryArray[i] = libraryClassName.get(i); + } + return libraryArray; } /** @@ -707,9 +718,8 @@ public class SurfaceAreaQuery { List protocolList = new ArrayList(); for (int i = 0; i < returns.length; i++) { - @SuppressWarnings("unchecked") - List archList = returnlList[i].getSupArchList(); - if (archList == null || archList.contains(arch)){ + List archList = returnlList[i].getSupArchList(); + if (archList == null || contains(archList, arch)){ protocolList.add(returnlList[i].getProtocolCName()); } } @@ -746,9 +756,8 @@ public class SurfaceAreaQuery { List protocolNotifyList = new ArrayList(); for (int i = 0; i < returns.length; i++) { - @SuppressWarnings("unchecked") - List archList = ((ProtocolNotify) returns[i]).getSupArchList(); - if (archList == null || archList.contains(arch)){ + List archList = ((ProtocolNotify) returns[i]).getSupArchList(); + if (archList == null || contains(archList, arch)){ protocolNotifyList.add(((ProtocolNotify) returns[i]).getProtocolNotifyCName()); } @@ -868,9 +877,8 @@ public class SurfaceAreaQuery { List ppiNotifyList = new ArrayList(); for (int i = 0; i < returns.length; i++) { - @SuppressWarnings("unchecked") - List archList = ((PPIsDocument.PPIs.PpiNotify) returns[i]).getSupArchList(); - if (archList == null || archList.contains(arch)){ + List archList = ((PPIsDocument.PPIs.PpiNotify) returns[i]).getSupArchList(); + if (archList == null || contains(archList, arch)){ ppiNotifyList.add(((PPIsDocument.PPIs.PpiNotify) returns[i]).getPpiNotifyCName()); } @@ -949,9 +957,8 @@ public class SurfaceAreaQuery { List ppiList = new ArrayList(); for (int i = 0; i < returns.length; i++) { - @SuppressWarnings("unchecked") - List archList = ((PPIsDocument.PPIs.Ppi) returns[i]).getSupArchList(); - if (archList == null || archList.contains(arch)){ + List archList = ((PPIsDocument.PPIs.Ppi) returns[i]).getSupArchList(); + if (archList == null || contains(archList, arch)){ ppiList.add(((PPIsDocument.PPIs.Ppi) returns[i]).getPpiCName()); } @@ -1029,9 +1036,8 @@ public class SurfaceAreaQuery { List guidList = new ArrayList(); for (int i = 0; i < returns.length; i++) { - @SuppressWarnings("unchecked") - List archList = ((GuidsDocument.Guids.GuidCNames) returns[i]).getSupArchList(); - if (archList == null || archList.contains(arch)){ + List archList = ((GuidsDocument.Guids.GuidCNames) returns[i]).getSupArchList(); + if (archList == null || contains(archList, arch)){ guidList.add(((GuidsDocument.Guids.GuidCNames) returns[i]).getGuidCName()); } @@ -1378,8 +1384,20 @@ public class SurfaceAreaQuery { return result; } - public static Node getFpdUserExtension() { - String[] xPath = new String[] { "/UserExtensions" }; + public static Node getFpdUserExtensionPreBuild() { + String[] xPath = new String[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='0']" }; + + Object[] queryResult = get("PlatformSurfaceArea", xPath); + if (queryResult == null || queryResult.length == 0) { + return null; + } + UserExtensionsDocument.UserExtensions a = (UserExtensionsDocument.UserExtensions)queryResult[0]; + + return a.getDomNode(); + } + + public static Node getFpdUserExtensionPostBuild() { + String[] xPath = new String[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='1']" }; Object[] queryResult = get("PlatformSurfaceArea", xPath); if (queryResult == null || queryResult.length == 0) { @@ -1579,81 +1597,7 @@ public class SurfaceAreaQuery { return null; } - // PcdCoded.PcdData[] pcds = (PcdCoded.PcdData[]) returns; - // String[][] result = new String[pcds.length][2]; - // for (int i = 0; i < returns.length; ++i) { - // if (pcds[i].getItemType() != null) { - // result[i][1] = pcds[i].getItemType().toString(); - // } else { - // result[i][1] = null; - // } - // result[i][0] = pcds[i].getCName(); - // } - - return null; - } - - /** - * Get the PcdToken array from module's surface area document. The array - * should contains following data: - *

- * ------------------------------------------------------------------- - *

- *

- * CName | ItemType | TokenspaceName | DefaultValue | Usage | HelpText - *

- *

- * ------------------------------------------------------------------- - *

- *

- * Note: Until new schema applying, now we can only get CName, ItemType, - *

- * - * @return 2-array table contains all information of PCD token retrieved - * from MSA. - */ - public static Object[][] etModulePCDTokenArray() { return null; - // int index; - // Object[][] result; - // PCDs.PcdData[] pcds; - // String[] xPath = new String[] { "/PcdData" }; - // Object[] returns = get("PCDs", xPath); - // - // if ((returns == null) || (returns.length == 0)) { - // return null; - // } - // - // pcds = (PCDs.PcdData[]) returns; - // result = new Object[pcds.length][6]; - // for (index = 0; index < pcds.length; index++) { - // // - // // Get CName - // // - // result[index][0] = pcds[index].getCName(); - // // - // // Get ItemType: FEATURE_FLAG, FIXED_AT_BUILD, PATCHABLE_IN_MODLE, - // // DYNAMIC, DYNAMIC_EX - // // - // if (pcds[index].getItemType() != null) { - // result[index][1] = pcds[index].getItemType().toString(); - // } else { - // result[index][1] = null; - // } - // - // // - // // BUGBUG: following field can *not* be got from current MSA until - // // schema changed. - // // - // // result [index][2] = pcds[index].getTokenSpaceName(); - // result[index][2] = null; - // result[index][3] = pcds[index].getDefaultValue(); - // // result [index][4] = pcds[index].getUsage (); - // result[index][4] = null; - // // result [index][5] = pcds[index].getHelpText (); - // result[index][5] = null; - // } - // return result; } /** @@ -1775,7 +1719,7 @@ public class SurfaceAreaQuery { if (returns == null) { return packageIncludeMap; } -// GlobalData.log.info("" + returns[0].getClass().getName()); + for (int i = 0; i < returns.length; i++) { PackageHeadersDocument.PackageHeaders.IncludePkgHeader includeHeader = (PackageHeadersDocument.PackageHeaders.IncludePkgHeader) returns[i]; packageIncludeMap.put(includeHeader.getModuleType().toString(), @@ -1896,31 +1840,6 @@ public class SurfaceAreaQuery { return ppiMap; } - /** - * getToolChainFamily - * - * This function is to retrieve ToolChainFamily attribute of FPD - * - * - * @param - * @return toolChainFamily If find toolChainFamily attribute in - * Null If don't have toolChainFamily in - * . - */ - public String getToolChainFamily() { - String toolChainFamily; - String[] xPath = new String[] { "/BuildOptions" }; - - Object[] result = get("PlatformSurfaceArea", xPath); - if (result == null) { - return null; - } - // toolChainFamily = - // ((BuildOptionsDocument.BuildOptions)result[0]).getToolChainFamilies(); - // return toolChainFamily; - return null; - } - /** * Retrieve module Guid string * @@ -1957,24 +1876,44 @@ public class SurfaceAreaQuery { is same, and token name should not be conflicted. @return String[] - **/ - public static String[] getModulePcdEntryNameArray() { - PcdCodedDocument.PcdCoded.PcdEntry[] pcdEntries = null; - String[] results; - int index; - String[] xPath = new String[] {"/PcdEntry"}; - Object[] returns = get ("PcdCoded", xPath); - - if (returns == null) { - return new String[0]; - } - - pcdEntries = (PcdCodedDocument.PcdCoded.PcdEntry[])returns; - results = new String[pcdEntries.length]; - - for (index = 0; index < pcdEntries.length; index ++) { - results[index] = pcdEntries[index].getCName(); - } - return results; - } + **/ + public static String[] getModulePcdEntryNameArray() { + PcdCodedDocument.PcdCoded.PcdEntry[] pcdEntries = null; + String[] results; + int index; + String[] xPath = new String[] {"/PcdEntry"}; + Object[] returns = get ("PcdCoded", xPath); + + if (returns == null) { + return new String[0]; + } + + pcdEntries = (PcdCodedDocument.PcdCoded.PcdEntry[])returns; + results = new String[pcdEntries.length]; + + for (index = 0; index < pcdEntries.length; index ++) { + results[index] = pcdEntries[index].getCName(); + } + return results; + } + + /** + Search in a List for a given string + + @return boolean + **/ + public static boolean contains(List list, String str) { + if (list == null || list.size()== 0) { + return true; + } + Iterator it = list.iterator(); + while (it.hasNext()) { + String s = (String)it.next(); + if (s.equalsIgnoreCase(str)) { + return true; + } + } + + return false; + } }