]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java
added the support for new schema and old schema at the same time
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / global / SurfaceAreaQuery.java
index 03c8d4328d6e8a4fef1f33b90bee6039a3c16074..50345c8a6854b7f970e207b2975f5daf8fdceaf8 100644 (file)
@@ -43,7 +43,9 @@ import org.tianocore.OutputDirectoryDocument;
 import org.tianocore.PPIsDocument;\r
 import org.tianocore.PackageNameDocument;\r
 import org.tianocore.ProtocolsDocument;\r
-import org.tianocore.PCDsDocument.PCDs;\r
+import org.tianocore.PcdCodedDocument.PcdCoded;\r
+import org.tianocore.MsaHeaderDocument;\r
+import org.tianocore.MsaHeaderDocument.MsaHeader;\r
 \r
 /**\r
   SurfaceAreaQuery class is used to query Surface Area information from msa, mbd,\r
@@ -233,7 +235,8 @@ public class SurfaceAreaQuery {
                 };\r
         } else {\r
             xPath = new String[] {\r
-                "/Filename[not(@ArchType) or @ArchType='ALL' or @ArchType='" + arch + "']",\r
+                "/Filename[not(@SupArchList) and not(@ArchType) or @SupArchList='ALL' or @SupArchList='" + arch + "' or @ArchType='ALL' or @ArchType='" + arch + "']",\r
+                "/Filename[not(@SupArchList) and not(@ArchType) or @ArchType='ALL' or @ArchType='" + arch + "']",\r
                 "/Arch[@ArchType='ALL' or @ArchType='" + arch + "']/Filename"\r
                 };\r
         }\r
@@ -300,6 +303,7 @@ public class SurfaceAreaQuery {
         } else {\r
             xPath = new String[] {\r
                 "/Option",\r
+                "/Option[@SupArchList='ALL' or @SupArchList='" + arch + "']",\r
                 "/Arch[@ArchType='ALL' or @ArchType='" + arch + "']/Option"\r
                 };\r
         }\r
@@ -341,6 +345,17 @@ public class SurfaceAreaQuery {
         return result;\r
     }\r
     \r
+    public static String getModuleName() {\r
+        String[] xPath = new String[] { "/ModuleName", "/BaseName" };\r
+\r
+        XmlObject[] returns = get(xPath);\r
+        if (returns != null && returns.length > 0) {\r
+            return returns[0].toString();\r
+        }\r
+\r
+        return null;\r
+    }\r
+\r
     /**\r
      Retrieve <xxxHeader>/ModuleType\r
 \r
@@ -396,13 +411,18 @@ public class SurfaceAreaQuery {
         } else {\r
             xPath = new String[] {\r
                 "/PackageName",\r
+                "/PackageName[@SupArchList='ALL' or @SupArchList='" + arch + "']",\r
+                "/PackageName[@Arch='ALL' or @Arch='" + arch + "']",\r
                 "/Arch[@ArchType='ALL' or @ArchType='" + arch + "']/PackageName"\r
                 };\r
         }\r
         \r
         XmlObject[] returns = get("Includes", xPath);\r
         if (returns == null || returns.length == 0) {\r
-            return null;\r
+            returns = get("PackageDependencies", xPath);\r
+            if (returns == null || returns.length == 0) {\r
+                return null;\r
+            }\r
         }\r
 \r
         List<String> packageNames = new ArrayList<String>();\r
@@ -471,12 +491,34 @@ public class SurfaceAreaQuery {
      @returns   null                    if nothing is there\r
      **/\r
     public static String getModuleGuid() {\r
-        String[] xPath = new String[] { "/Guid" };\r
+        String[] xPath = new String[] { "" };\r
 \r
-        XmlObject[] returns = get(xPath);\r
+        XmlObject[] returns = get("MsaHeader", xPath);\r
         if (returns != null && returns.length > 0) {\r
-            GuidDocument.Guid guid = (GuidDocument.Guid) returns[0];\r
-            return guid.getStringValue();\r
+            MsaHeaderDocument.MsaHeader moduleHeader = (MsaHeaderDocument.MsaHeader) returns[0];\r
+            if (moduleHeader.isSetGuid()) {\r
+                return moduleHeader.getGuid().getStringValue();\r
+            } else if (moduleHeader.isSetGuidValue()) {\r
+                return moduleHeader.getGuidValue();\r
+            }\r
+        }\r
+\r
+        return null;\r
+    }\r
+\r
+    /**\r
+     Retrieve module Guid string\r
\r
+     @returns   GUILD string            if elements are found at the known xpath\r
+     @returns   null                    if nothing is there\r
+     **/\r
+    public static String getModuleGuidValue() {\r
+        String[] xPath = new String[] { "" };\r
+\r
+        XmlObject[] returns = get("MsaHeader", xPath);\r
+        if (returns != null && returns.length > 0) {            \r
+            MsaHeaderDocument.MsaHeader moduleHeader = (MsaHeaderDocument.MsaHeader) returns[0];\r
+            return moduleHeader.getGuidValue();\r
         }\r
 \r
         return null;\r
@@ -676,7 +718,8 @@ public class SurfaceAreaQuery {
         }\r
         \r
         xPath = new String[] {\r
-                "/Library" + usageAttribute,\r
+                "/Library" + archAttribute, //usageAttribute,\r
+                "/Library[not(@SupArchList) or @SupArchList='" + arch + "']",\r
                 "/Arch" + archAttribute + "/Library" + usageAttribute\r
                 };\r
 \r
@@ -832,6 +875,11 @@ public class SurfaceAreaQuery {
 \r
         XmlObject[] result = get("FrameworkPlatformDescription", xPath);\r
         if (result == null) {\r
+            xPath = new String[] { "/FrameworkModules/*/ModuleSA" };\r
+            result = get("FrameworkPlatformDescription", xPath);\r
+            if (result != null) {\r
+                return (ModuleSADocument.ModuleSA[]) result;\r
+            }\r
             return new ModuleSADocument.ModuleSA[0];\r
         }\r
 \r
@@ -1029,81 +1077,27 @@ public class SurfaceAreaQuery {
     }\r
     \r
     /**\r
-     Retrieve PCD tokens\r
-\r
-     @returns   CName/ItemType pairs list   if elements are found at the known xpath\r
-     @returns   null                        if nothing is there\r
-     **/\r
-    public static String[][] getPcdTokenArray() {\r
-        String[] xPath = new String[] {"/PcdData"};\r
-        \r
-        XmlObject[] returns = get("PCDs", xPath);\r
-        if (returns == null || returns.length == 0) {\r
+       Get name array of PCD in a module. In one module, token space\r
+       is same, and token name should not be conflicted.\r
+       \r
+       @return String[]\r
+    **/\r
+    public static String[] getModulePcdEntryNameArray() {\r
+        PcdCoded.PcdEntry[] pcdEntries  = null;\r
+        String[]            results;\r
+        int                 index;\r
+        String[]            xPath       = new String[] {"/PcdEntry"};\r
+        XmlObject[]         returns     = get ("PcdCoded", xPath);\r
+        if (returns == null) {\r
             return null;\r
         }\r
-        \r
-        PCDs.PcdData[] pcds = (PCDs.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 result;\r
-    }\r
 \r
-    /**\r
-     Get the PcdToken array from module's surface area document.\r
-     The array should contains following data:\r
-     <p>-------------------------------------------------------------------</p>\r
-     <p>CName | ItemType | TokenspaceName | DefaultValue | Usage | HelpText</p>\r
-     <p>-------------------------------------------------------------------</p>\r
-     <p>Note: Until new schema applying, now we can only get CName, ItemType,</p>\r
-     \r
-     @return  2-array table contains all information of PCD token retrieved from MSA.\r
-     **/\r
-    public static Object[][] getModulePCDTokenArray () {\r
-      int             index;\r
-      Object[][]      result;\r
-      PCDs.PcdData[]  pcds;\r
-      String[]        xPath   = new String[] {"/PcdData"};\r
-      XmlObject[]     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, 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
+        pcdEntries = (PcdCoded.PcdEntry[])returns;\r
+        results    = new String[pcdEntries.length];\r
         \r
-        //\r
-        // BUGBUG: following field can *not* be got from current MSA until 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
+        for (index = 0; index < pcdEntries.length; index ++) {\r
+            results[index] = pcdEntries[index].getCName();\r
+        }\r
+        return results;\r
     }\r
 }\r