]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java
New tool.
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / global / SurfaceAreaQuery.java
index 5eb14d4a4521d1c701c05b4efb515b03b0084671..956033993d523ad95abc7978508404b28166efae 100644 (file)
@@ -27,6 +27,7 @@ import org.apache.xmlbeans.XmlNormalizedString;
 import org.apache.xmlbeans.XmlObject;\r
 import org.apache.xmlbeans.XmlString;\r
 import org.tianocore.BuildOptionsDocument;\r
+import org.tianocore.CNameType;\r
 import org.tianocore.DataIdDocument;\r
 import org.tianocore.ExternsDocument;\r
 import org.tianocore.FileNameConvention;\r
@@ -48,9 +49,11 @@ import org.tianocore.OptionDocument;
 import org.tianocore.PPIsDocument;\r
 import org.tianocore.PackageDependenciesDocument;\r
 import org.tianocore.PackageHeadersDocument;\r
+import org.tianocore.PcdCodedDocument;\r
 import org.tianocore.PlatformDefinitionsDocument;\r
 import org.tianocore.PpiDeclarationsDocument;\r
 import org.tianocore.ProtocolDeclarationsDocument;\r
+import org.tianocore.Sentence;\r
 import org.tianocore.SpdHeaderDocument;\r
 import org.tianocore.SupportedArchitectures;\r
 import org.tianocore.FilenameDocument.Filename;\r
@@ -63,6 +66,7 @@ import org.tianocore.build.id.ModuleIdentification;
 import org.tianocore.build.id.PackageIdentification;\r
 import org.tianocore.build.id.PlatformIdentification;\r
 import org.tianocore.build.toolchain.ToolChainInfo;\r
+import org.tianocore.logger.EdkLog;\r
 \r
 /**\r
  * SurfaceAreaQuery class is used to query Surface Area information from msa,\r
@@ -624,8 +628,7 @@ public class SurfaceAreaQuery {
             String[] entryPoints = new String[returns.length];\r
 \r
             for (int i = 0; i < returns.length; ++i) {\r
-                entryPoints[i] = ((XmlNormalizedString) returns[i])\r
-                        .getStringValue();\r
+                entryPoints[i] = ((CNameType) returns[i]).getStringValue();\r
             }\r
 \r
             return entryPoints;\r
@@ -689,7 +692,7 @@ public class SurfaceAreaQuery {
         if (arch == null || arch.equals("")) {\r
             return new String[0];\r
         } else {\r
-            xPath = new String[] { "/Protocol[@SupArchList='" + arch + "']" };\r
+            xPath = new String[] { "/Protocol" };\r
         }\r
 \r
         Object[] returns = get("Protocols", xPath);\r
@@ -700,7 +703,10 @@ public class SurfaceAreaQuery {
 \r
         String[] protocolArray = new String[returns.length];\r
         for (int i = 0; i < returns.length; i++) {\r
-            protocolArray[i] = protocolList[i].getProtocolCName();\r
+            List<String> archList = protocolList[i].getSupArchList();\r
+            if (archList == null || archList.contains(arch)){\r
+                protocolArray[i] = protocolList[i].getProtocolCName(); \r
+            }\r
         }\r
         return protocolArray;\r
     }\r
@@ -720,8 +726,7 @@ public class SurfaceAreaQuery {
         if (arch == null || arch.equals("")) {\r
             return new String[0];\r
         } else {\r
-            xPath = new String[] { "/ProtocolNotify[@SupArchList='" + arch\r
-                    + "']" };\r
+            xPath = new String[] { "/ProtocolNotify" };\r
         }\r
 \r
         Object[] returns = get("Protocols", xPath);\r
@@ -731,7 +736,11 @@ public class SurfaceAreaQuery {
 \r
         String[] protocolNotifyList = new String[returns.length];\r
         for (int i = 0; i < returns.length; i++) {\r
-            protocolNotifyList[i] = ((ProtocolNotify) returns[i]).getProtocolNotifyCName();\r
+            List<String> archList = ((ProtocolNotify) returns[i]).getSupArchList();\r
+            if (archList == null || archList.contains(arch)){\r
+                protocolNotifyList[i] = ((ProtocolNotify) returns[i]).getProtocolNotifyCName();\r
+            }\r
+            \r
         }\r
 \r
         return protocolNotifyList;\r
@@ -790,7 +799,7 @@ public class SurfaceAreaQuery {
         Object[] returns = get("Externs", xPath);\r
         if (returns != null && returns.length > 0) {\r
             String[] stringArray = new String[returns.length];\r
-            XmlNormalizedString[] doc = (XmlNormalizedString[]) returns;\r
+            CNameType[] doc = (CNameType[]) returns;\r
 \r
             for (int i = 0; i < returns.length; ++i) {\r
                 stringArray[i] = doc[i].getStringValue();\r
@@ -834,7 +843,7 @@ public class SurfaceAreaQuery {
         if (arch == null || arch.equals("")) {\r
             return new String[0];\r
         } else {\r
-            xPath = new String[] { "/PpiNotify[@SupArchList='" + arch + "']" };\r
+            xPath = new String[] { "/PpiNotify" };\r
         }\r
 \r
         Object[] returns = get("PPIs", xPath);\r
@@ -844,7 +853,11 @@ public class SurfaceAreaQuery {
 \r
         String[] ppiNotifyList = new String[returns.length];\r
         for (int i = 0; i < returns.length; i++) {\r
-            ppiNotifyList[i] = ((PPIsDocument.PPIs.PpiNotify) returns[i]).getPpiNotifyCName();\r
+            List<String> archList = ((PPIsDocument.PPIs.PpiNotify) returns[i]).getSupArchList();\r
+            if (archList == null || archList.contains(arch)){\r
+                ppiNotifyList[i] = ((PPIsDocument.PPIs.PpiNotify) returns[i]).getPpiNotifyCName();    \r
+            }\r
+            \r
         }\r
 \r
         return ppiNotifyList;\r
@@ -869,7 +882,7 @@ public class SurfaceAreaQuery {
         if (arch == null || arch.equals("")) {\r
             return new String[0];\r
         } else {\r
-            archXpath = "/PpiNotify[@SupArchList='" + arch + "']";\r
+            archXpath = "/PpiNotify";\r
             if (usage != null && !usage.equals("")) {\r
                 usageXpath = "/PpiNotify[@Usage='" + arch + "']";\r
                 xPath = new String[] { archXpath, usageXpath };\r
@@ -906,7 +919,7 @@ public class SurfaceAreaQuery {
         if (arch == null || arch.equals("")) {\r
             return new String[0];\r
         } else {\r
-            xPath = new String[] { "/Ppi[@SupArchList='" + arch + "']" };\r
+            xPath = new String[] { "/Ppi" };\r
         }\r
 \r
         Object[] returns = get("PPIs", xPath);\r
@@ -916,7 +929,11 @@ public class SurfaceAreaQuery {
 \r
         String[] ppiList = new String[returns.length];\r
         for (int i = 0; i < returns.length; i++) {\r
-            ppiList[i] = ((PPIsDocument.PPIs.Ppi) returns[i]).getPpiCName();\r
+            List<String> archList = ((PPIsDocument.PPIs.Ppi) returns[i]).getSupArchList();\r
+            if (archList == null || archList.contains(arch)){\r
+                ppiList[i] = ((PPIsDocument.PPIs.Ppi) returns[i]).getPpiCName();    \r
+            }\r
+            \r
         }\r
         return ppiList;\r
     }\r
@@ -940,7 +957,7 @@ public class SurfaceAreaQuery {
         if (arch == null || arch.equals("")) {\r
             return new String[0];\r
         } else {\r
-            archXpath = "/Ppi[@SupArchList='" + arch + "']";\r
+            archXpath = "/Ppi";\r
             if (usage != null && !usage.equals("")) {\r
                 usageXpath = "/Ppi[@Usage='" + arch + "']";\r
                 xPath = new String[] { archXpath, usageXpath };\r
@@ -975,9 +992,9 @@ public class SurfaceAreaQuery {
         String[] xPath;\r
 \r
         if (arch == null || arch.equals("")) {\r
-            xPath = new String[] { "/GuidName" };\r
+            xPath = new String[] { "/GuidCNames" };\r
         } else {\r
-            xPath = new String[] { "/GuidName[@SupArchList='" + arch + "']" };\r
+            xPath = new String[] { "/GuidCNames" };\r
         }\r
 \r
         Object[] returns = get("Guids", xPath);\r
@@ -986,7 +1003,11 @@ public class SurfaceAreaQuery {
         }\r
         String[] guidList = new String[returns.length];\r
         for (int i = 0; i < returns.length; i++) {\r
-            guidList[i] = ((GuidsDocument.Guids.GuidCNames) returns[i]).getGuidCName();\r
+            List<String> archList = ((GuidsDocument.Guids.GuidCNames) returns[i]).getSupArchList();\r
+            if (archList == null || archList.contains(arch)){\r
+                guidList[i] = ((GuidsDocument.Guids.GuidCNames) returns[i]).getGuidCName();    \r
+            }\r
+            \r
         }\r
         return guidList;\r
 \r
@@ -1009,7 +1030,7 @@ public class SurfaceAreaQuery {
         if (arch == null || arch.equals("")) {\r
             return new String[0];\r
         } else {\r
-            archXpath = "/GuidEntry[@SupArchList='" + arch + "']";\r
+            archXpath = "/GuidEntry";\r
             if (usage != null && !usage.equals("")) {\r
                 usageXpath = "/GuidEntry[@Usage='" + arch + "']";\r
                 xPath = new String[] { archXpath, usageXpath };\r
@@ -1096,7 +1117,7 @@ public class SurfaceAreaQuery {
         String[] strings = new String[returns.length];\r
         for (int i = 0; i < returns.length; ++i) {\r
             // TBD\r
-            // strings[i] = ((CName) returns[i]).getStringValue();\r
+             strings[i] = ((CNameType) returns[i]).getStringValue();\r
         }\r
 \r
         return strings;\r
@@ -1113,8 +1134,8 @@ public class SurfaceAreaQuery {
 \r
         Object[] returns = get("Externs", xPath);\r
         if (returns != null && returns.length > 0) {\r
-            // CName constructor = (CName) returns[0];\r
-            // return constructor.getStringValue();\r
+            CNameType constructor = ((CNameType) returns[0]);\r
+            return constructor.getStringValue();\r
         }\r
 \r
         return null;\r
@@ -1131,8 +1152,11 @@ public class SurfaceAreaQuery {
 \r
         Object[] returns = get("Externs", xPath);\r
         if (returns != null && returns.length > 0) {\r
-            // CName destructor = (CName) returns[0];\r
-            // return destructor.getStringValue();\r
+            //\r
+            // Only support one Destructor function.\r
+            //\r
+             CNameType destructor = (CNameType) returns[0];\r
+             return destructor.getStringValue();\r
         }\r
 \r
         return null;\r
@@ -1646,9 +1670,8 @@ public class SurfaceAreaQuery {
 \r
         String[] specificationList = new String[queryResult.length];\r
         for (int i = 0; i < queryResult.length; i++) {\r
-            // specificationList[i] = ((SpecificationDocument.Specification)\r
-            // queryResult[i])\r
-            // .getStringValue();\r
+             specificationList[i] = ((Sentence)queryResult[i])\r
+             .getStringValue();\r
         }\r
         return specificationList;\r
     }\r
@@ -1765,6 +1788,9 @@ public class SurfaceAreaQuery {
             guidPair[0] = entry.getCName();\r
             guidPair[1] = entry.getGuidValue();\r
             guidDeclMap.put(entry.getName(), guidPair);\r
+            EdkLog.log(EdkLog.EDK_VERBOSE, entry.getName());\r
+            EdkLog.log(EdkLog.EDK_VERBOSE, guidPair[0]);\r
+            EdkLog.log(EdkLog.EDK_VERBOSE, guidPair[1]);\r
         }\r
         return guidDeclMap;\r
     }\r
@@ -1793,6 +1819,9 @@ public class SurfaceAreaQuery {
             protocolPair[0] = entry.getCName();\r
             protocolPair[1] = entry.getGuidValue();\r
             protoclMap.put(entry.getName(), protocolPair);\r
+            EdkLog.log(EdkLog.EDK_VERBOSE, entry.getName());\r
+            EdkLog.log(EdkLog.EDK_VERBOSE, protocolPair[0]);\r
+            EdkLog.log(EdkLog.EDK_VERBOSE, protocolPair[1]);\r
         }\r
         return protoclMap;\r
     }\r
@@ -1885,4 +1914,29 @@ public class SurfaceAreaQuery {
         return new ModuleSADocument.ModuleSA[0];\r
 \r
     }\r
+    /**\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
+     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