]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java
Support prebuild and postbuild for UserExtension for Platform build. If UserExtension...
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / global / SurfaceAreaQuery.java
index 0b16e30df3bbb2953c34c499728dcc12447792a2..149b30dd173e88fb7946e4b21eeb629bc55a7e25 100644 (file)
@@ -23,7 +23,6 @@ import java.util.Stack;
 import java.util.regex.Matcher;\r
 import java.util.regex.Pattern;\r
 \r
-import org.apache.xmlbeans.XmlCursor;\r
 import org.apache.xmlbeans.XmlObject;\r
 import org.apache.xmlbeans.XmlString;\r
 import org.tianocore.BuildOptionsDocument;\r
@@ -278,9 +277,8 @@ public class SurfaceAreaQuery {
         Filename[] sourceFileNames = (Filename[]) returns;\r
         List<String[]> outputList = new ArrayList<String[]>();\r
         for (int i = 0; i < sourceFileNames.length; i++) {\r
-            @SuppressWarnings("unchecked")\r
-            List<String> archList = sourceFileNames[i].getSupArchList();\r
-            if (arch == null || arch.equalsIgnoreCase("") || archList == null || archList.contains(arch)) {\r
+            List archList = sourceFileNames[i].getSupArchList();\r
+            if (arch == null || arch.equalsIgnoreCase("") || archList == null || contains(archList, arch)) {\r
                 outputList.add(new String[] {sourceFileNames[i].getToolCode(),sourceFileNames[i].getStringValue()});\r
             }\r
         }\r
@@ -399,7 +397,6 @@ public class SurfaceAreaQuery {
         String toolchainFamily = null;\r
         List<String> archList = null;\r
         String cmd = null;\r
-        String targetName = null;\r
         String optionName = null;\r
 \r
         Object[] returns = get(from, xPath);\r
@@ -444,20 +441,16 @@ public class SurfaceAreaQuery {
             }\r
 \r
             archList = new ArrayList<String>();\r
-            @SuppressWarnings("unchecked")\r
-            List<String> archEnumList = option.getSupArchList();            \r
+            List archEnumList = option.getSupArchList();            \r
             if (archEnumList == null) {\r
                 archList.add(null);\r
             } else {\r
-                archList.addAll(archEnumList);\r
-                /*\r
+                //archList.addAll(archEnumList);\r
                 Iterator it = archEnumList.iterator();\r
                 while (it.hasNext()) {\r
-                    System.out.println(it.next().getClass().getName());\r
-                    SupportedArchitectures.Enum archType = it.next();\r
-                    archList.add(archType.toString());\r
+                    String archType = (String)it.next();\r
+                    archList.add(archType);\r
                 }\r
-                */\r
             }\r
 \r
             cmd = option.getToolCode();\r
@@ -568,19 +561,30 @@ public class SurfaceAreaQuery {
         if (returns == null) {\r
             return new PackageIdentification[0];\r
         }\r
-        PackageIdentification[] packageIdList = new PackageIdentification[returns.length];\r
+\r
+        //\r
+        //  Get packageIdentification \r
+        // \r
+        List<PackageIdentification> packageIdList = new ArrayList<PackageIdentification>();\r
         for (int i = 0; i < returns.length; i++) {\r
             PackageDependenciesDocument.PackageDependencies.Package item = (PackageDependenciesDocument.PackageDependencies.Package) returns[i];\r
-            @SuppressWarnings("unchecked")\r
-            List<String> archList = item.getSupArchList();\r
-            if (arch == null || archList == null || archList.contains(arch)) {\r
+            List archList = item.getSupArchList();\r
+            if (arch == null || archList == null || contains(archList, arch)) {\r
                 packageGuid = item.getPackageGuid();\r
                 packageVersion = item.getPackageVersion();\r
-                packageIdList[i] = (new PackageIdentification(null, packageGuid,\r
+                packageIdList.add(new PackageIdentification(null, packageGuid,\r
                     packageVersion));\r
             }\r
         }\r
-        return packageIdList;\r
+\r
+        //\r
+        //  transfer packageIdentification list to array.\r
+        // \r
+        PackageIdentification[] packageIdArray = new PackageIdentification[packageIdList.size()];\r
+        for (int i = 0; i < packageIdList.size(); i++) {\r
+            packageIdArray[i] = new PackageIdentification(null, packageIdList.get(i).getGuid(),packageIdList.get(i).getVersion());\r
+        }\r
+        return packageIdArray;\r
     }\r
 \r
     /**\r
@@ -593,9 +597,8 @@ public class SurfaceAreaQuery {
      *          xpath\r
      * @returns null if nothing is there\r
      */\r
-    public static String[] getLibraryClasses(String usage) {\r
+    public static String[] getLibraryClasses(String usage, String arch) {\r
         String[] xPath;\r
-\r
         if (usage == null || usage.equals("")) {\r
             xPath = new String[] { "/LibraryClass" };\r
         } else {\r
@@ -608,11 +611,19 @@ public class SurfaceAreaQuery {
         }\r
 \r
         LibraryClassDocument.LibraryClass[] libraryClassList = (LibraryClassDocument.LibraryClass[]) returns;\r
-        String[] libraryClassName = new String[libraryClassList.length];\r
+        List<String> libraryClassName = new ArrayList<String>();\r
         for (int i = 0; i < libraryClassList.length; i++) {\r
-            libraryClassName[i] = libraryClassList[i].getKeyword();\r
+                       List archList = libraryClassList[i].getSupArchList();\r
+                       \r
+                       if (arch == null || contains(archList, arch)) {\r
+                libraryClassName.add(libraryClassList[i].getKeyword());\r
+                       }\r
         }\r
-        return libraryClassName;\r
+               String[] libraryArray = new String[libraryClassName.size()];\r
+               for (int i = 0; i < libraryClassName.size(); i++) {\r
+                       libraryArray[i] = libraryClassName.get(i);\r
+               }\r
+        return libraryArray;\r
     }\r
 \r
     /**\r
@@ -707,9 +718,8 @@ public class SurfaceAreaQuery {
         List<String> protocolList = new ArrayList<String>();\r
         \r
         for (int i = 0; i < returns.length; i++) {\r
-            @SuppressWarnings("unchecked")\r
-            List<String> archList = returnlList[i].getSupArchList();\r
-            if (archList == null || archList.contains(arch)){\r
+            List archList = returnlList[i].getSupArchList();\r
+            if (archList == null || contains(archList, arch)){\r
                 protocolList.add(returnlList[i].getProtocolCName());\r
             }\r
         }\r
@@ -746,9 +756,8 @@ public class SurfaceAreaQuery {
         List<String> protocolNotifyList = new ArrayList<String>();\r
         \r
         for (int i = 0; i < returns.length; i++) {\r
-            @SuppressWarnings("unchecked")\r
-            List<String> archList = ((ProtocolNotify) returns[i]).getSupArchList();\r
-            if (archList == null || archList.contains(arch)){\r
+            List archList = ((ProtocolNotify) returns[i]).getSupArchList();\r
+            if (archList == null || contains(archList, arch)){\r
                 protocolNotifyList.add(((ProtocolNotify) returns[i]).getProtocolNotifyCName());\r
             }\r
             \r
@@ -868,9 +877,8 @@ public class SurfaceAreaQuery {
         \r
         List<String> ppiNotifyList = new ArrayList<String>();\r
         for (int i = 0; i < returns.length; i++) {\r
-            @SuppressWarnings("unchecked")\r
-            List<String> archList = ((PPIsDocument.PPIs.PpiNotify) returns[i]).getSupArchList();\r
-            if (archList == null || archList.contains(arch)){\r
+            List archList = ((PPIsDocument.PPIs.PpiNotify) returns[i]).getSupArchList();\r
+            if (archList == null || contains(archList, arch)){\r
                 ppiNotifyList.add(((PPIsDocument.PPIs.PpiNotify) returns[i]).getPpiNotifyCName()); \r
             }\r
             \r
@@ -949,9 +957,8 @@ public class SurfaceAreaQuery {
 \r
         List<String> ppiList = new ArrayList<String>();\r
         for (int i = 0; i < returns.length; i++) {\r
-            @SuppressWarnings("unchecked")\r
-            List<String> archList = ((PPIsDocument.PPIs.Ppi) returns[i]).getSupArchList();\r
-            if (archList == null || archList.contains(arch)){\r
+            List archList = ((PPIsDocument.PPIs.Ppi) returns[i]).getSupArchList();\r
+            if (archList == null || contains(archList, arch)){\r
                 ppiList.add(((PPIsDocument.PPIs.Ppi) returns[i]).getPpiCName());    \r
             }\r
             \r
@@ -1029,9 +1036,8 @@ public class SurfaceAreaQuery {
 \r
         List<String> guidList = new ArrayList<String>();\r
         for (int i = 0; i < returns.length; i++) {\r
-            @SuppressWarnings("unchecked")\r
-            List<String> archList = ((GuidsDocument.Guids.GuidCNames) returns[i]).getSupArchList();\r
-            if (archList == null || archList.contains(arch)){\r
+            List archList = ((GuidsDocument.Guids.GuidCNames) returns[i]).getSupArchList();\r
+            if (archList == null || contains(archList, arch)){\r
                 guidList.add(((GuidsDocument.Guids.GuidCNames) returns[i]).getGuidCName());    \r
             }\r
             \r
@@ -1378,8 +1384,20 @@ public class SurfaceAreaQuery {
         return result;\r
     }\r
     \r
-    public static Node getFpdUserExtension() {\r
-        String[] xPath = new String[] { "/UserExtensions" };\r
+    public static Node getFpdUserExtensionPreBuild() {\r
+        String[] xPath = new String[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='0']" }; \r
+\r
+        Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
+        if (queryResult == null || queryResult.length == 0) {\r
+            return null;\r
+        }\r
+        UserExtensionsDocument.UserExtensions a =  (UserExtensionsDocument.UserExtensions)queryResult[0];\r
+        \r
+        return a.getDomNode();\r
+    }\r
+    \r
+    public static Node getFpdUserExtensionPostBuild() {\r
+        String[] xPath = new String[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='1']" }; \r
 \r
         Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
         if (queryResult == null || queryResult.length == 0) {\r
@@ -1579,81 +1597,7 @@ public class SurfaceAreaQuery {
             return null;\r
         }\r
 \r
-        // PcdCoded.PcdData[] pcds = (PcdCoded.PcdData[]) returns;\r
-        // String[][] result = new String[pcds.length][2];\r
-        // for (int i = 0; i < returns.length; ++i) {\r
-        // if (pcds[i].getItemType() != null) {\r
-        // result[i][1] = pcds[i].getItemType().toString();\r
-        // } else {\r
-        // result[i][1] = null;\r
-        // }\r
-        // result[i][0] = pcds[i].getCName();\r
-        // }\r
-\r
-        return null;\r
-    }\r
-\r
-    /**\r
-     * Get the PcdToken array from module's surface area document. The array\r
-     * should contains following data:\r
-     * <p>\r
-     * -------------------------------------------------------------------\r
-     * </p>\r
-     * <p>\r
-     * CName | ItemType | TokenspaceName | DefaultValue | Usage | HelpText\r
-     * </p>\r
-     * <p>\r
-     * -------------------------------------------------------------------\r
-     * </p>\r
-     * <p>\r
-     * Note: Until new schema applying, now we can only get CName, ItemType,\r
-     * </p>\r
-     * \r
-     * @return 2-array table contains all information of PCD token retrieved\r
-     *         from MSA.\r
-     */\r
-    public static Object[][] etModulePCDTokenArray() {\r
         return null;\r
-        // int index;\r
-        // Object[][] result;\r
-        // PCDs.PcdData[] pcds;\r
-        // String[] xPath = new String[] { "/PcdData" };\r
-        // Object[] returns = get("PCDs", xPath);\r
-        //\r
-        // if ((returns == null) || (returns.length == 0)) {\r
-        // return null;\r
-        // }\r
-        //\r
-        // pcds = (PCDs.PcdData[]) returns;\r
-        // result = new Object[pcds.length][6];\r
-        // for (index = 0; index < pcds.length; index++) {\r
-        // //\r
-        // // Get CName\r
-        // //\r
-        // result[index][0] = pcds[index].getCName();\r
-        // //\r
-        // // Get ItemType: FEATURE_FLAG, FIXED_AT_BUILD, PATCHABLE_IN_MODLE,\r
-        // // DYNAMIC, DYNAMIC_EX\r
-        // //\r
-        // if (pcds[index].getItemType() != null) {\r
-        // result[index][1] = pcds[index].getItemType().toString();\r
-        // } else {\r
-        // result[index][1] = null;\r
-        // }\r
-        //\r
-        // //\r
-        // // BUGBUG: following field can *not* be got from current MSA until\r
-        // // schema changed.\r
-        // //\r
-        // // result [index][2] = pcds[index].getTokenSpaceName();\r
-        // result[index][2] = null;\r
-        // result[index][3] = pcds[index].getDefaultValue();\r
-        // // result [index][4] = pcds[index].getUsage ();\r
-        // result[index][4] = null;\r
-        // // result [index][5] = pcds[index].getHelpText ();\r
-        // result[index][5] = null;\r
-        // }\r
-        // return result;\r
     }\r
 \r
     /**\r
@@ -1775,7 +1719,7 @@ public class SurfaceAreaQuery {
         if (returns == null) {\r
             return packageIncludeMap;\r
         }\r
-//        GlobalData.log.info("" + returns[0].getClass().getName());\r
+\r
         for (int i = 0; i < returns.length; i++) {\r
             PackageHeadersDocument.PackageHeaders.IncludePkgHeader includeHeader = (PackageHeadersDocument.PackageHeaders.IncludePkgHeader) returns[i];\r
             packageIncludeMap.put(includeHeader.getModuleType().toString(),\r
@@ -1896,31 +1840,6 @@ public class SurfaceAreaQuery {
         return ppiMap;\r
     }\r
 \r
-    /**\r
-     * getToolChainFamily\r
-     * \r
-     * This function is to retrieve ToolChainFamily attribute of FPD\r
-     * <BuildOptions>\r
-     * \r
-     * @param\r
-     * @return toolChainFamily If find toolChainFamily attribute in\r
-     *         <BuildOptions> Null If don't have toolChainFamily in\r
-     *         <BuildOptions>.\r
-     */\r
-    public String getToolChainFamily() {\r
-        String toolChainFamily;\r
-        String[] xPath = new String[] { "/BuildOptions" };\r
-\r
-        Object[] result = get("PlatformSurfaceArea", xPath);\r
-        if (result == null) {\r
-            return null;\r
-        }\r
-        // toolChainFamily =\r
-        // ((BuildOptionsDocument.BuildOptions)result[0]).getToolChainFamilies();\r
-        // return toolChainFamily;\r
-        return null;\r
-    }\r
-\r
     /**\r
      * Retrieve module Guid string\r
      * \r
@@ -1957,24 +1876,44 @@ public class SurfaceAreaQuery {
     is same, and token name should not be conflicted.\r
     \r
     @return String[]\r
- **/\r
- public static String[] getModulePcdEntryNameArray() {\r
-     PcdCodedDocument.PcdCoded.PcdEntry[] pcdEntries  = null;\r
-     String[]            results;\r
-     int                 index;\r
-     String[]            xPath       = new String[] {"/PcdEntry"};\r
-     Object[]         returns     = get ("PcdCoded", xPath);\r
-     \r
-     if (returns == null) {\r
-         return new String[0];\r
-     }\r
-     \r
-     pcdEntries = (PcdCodedDocument.PcdCoded.PcdEntry[])returns;\r
-     results    = new String[pcdEntries.length];\r
-     \r
-     for (index = 0; index < pcdEntries.length; index ++) {\r
-         results[index] = pcdEntries[index].getCName();\r
-     }\r
-     return results;\r
- }\r
+    **/\r
+    public static String[] getModulePcdEntryNameArray() {\r
+        PcdCodedDocument.PcdCoded.PcdEntry[] pcdEntries  = null;\r
+        String[]            results;\r
+        int                 index;\r
+        String[]            xPath       = new String[] {"/PcdEntry"};\r
+        Object[]         returns     = get ("PcdCoded", xPath);\r
+\r
+        if (returns == null) {\r
+            return new String[0];\r
+        }\r
+\r
+        pcdEntries = (PcdCodedDocument.PcdCoded.PcdEntry[])returns;\r
+        results    = new String[pcdEntries.length];\r
+\r
+        for (index = 0; index < pcdEntries.length; index ++) {\r
+            results[index] = pcdEntries[index].getCName();\r
+        }\r
+        return results;\r
+    }\r
+\r
+    /**\r
+     Search in a List for a given string\r
+\r
+     @return boolean\r
+     **/\r
+    public static boolean contains(List list, String str) {\r
+               if (list == null || list.size()== 0) {\r
+                       return true;\r
+               }\r
+        Iterator it = list.iterator();\r
+        while (it.hasNext()) {\r
+            String s = (String)it.next();\r
+            if (s.equalsIgnoreCase(str)) {\r
+                return true;\r
+            }\r
+        }\r
+\r
+        return false;\r
+    }\r
 }\r