]> 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 ed6d0a2f183364970d6440a046f6b8d2bbdaddb3..50345c8a6854b7f970e207b2975f5daf8fdceaf8 100644 (file)
@@ -44,6 +44,8 @@ import org.tianocore.PPIsDocument;
 import org.tianocore.PackageNameDocument;\r
 import org.tianocore.ProtocolsDocument;\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