]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Java/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java
If "SupArchList" is defined for a PCD in MSA, should check current arch is in the...
[mirror_edk2.git] / Tools / Java / Source / GenBuild / org / tianocore / build / global / SurfaceAreaQuery.java
index 0140e8b704614bee058546f39c659935760ae256..17f7541e093594c61d767d03efd4f976f7e7e925 100644 (file)
@@ -38,7 +38,6 @@ import org.tianocore.build.id.PackageIdentification;
 import org.tianocore.build.id.PlatformIdentification;\r
 import org.tianocore.build.toolchain.ToolChainInfo;\r
 import org.tianocore.common.exception.EdkException;\r
-import org.tianocore.common.logger.EdkLog;\r
 import org.w3c.dom.Node;\r
 \r
 /**\r
@@ -77,8 +76,7 @@ public class SurfaceAreaQuery {
     //\r
     // keep the namep declaration for xmlbeans Xpath query\r
     //\r
-    private String queryDeclaration = null;\r
-\r
+    private String queryDeclaration = null;    \r
     private StringBuffer normQueryString = new StringBuffer(4096);\r
     private Pattern xPathPattern = Pattern.compile("([^/]*)(/|//)([^/]+)");\r
 \r
@@ -249,22 +247,32 @@ public class SurfaceAreaQuery {
         returns = get("SourceFiles", xPath);\r
 \r
         if (returns == null || returns.length == 0) {\r
-            return new String[0][0];\r
+            return new String[0][3];\r
         }\r
 \r
         Filename[] sourceFileNames = (Filename[]) returns;\r
         List<String[]> outputList = new ArrayList<String[]>();\r
         for (int i = 0; i < sourceFileNames.length; i++) {\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
+            if (arch == null || arch.trim().equalsIgnoreCase("") || archList == null || contains(archList, arch)) {\r
+                outputList.add(new String[] {sourceFileNames[i].getToolCode(), sourceFileNames[i].getStringValue(), sourceFileNames[i].getToolChainFamily()});\r
             }\r
         }\r
 \r
-        String[][] outputString = new String[outputList.size()][2];\r
+        String[][] outputString = new String[outputList.size()][3];\r
         for (int index = 0; index < outputList.size(); index++) {\r
+            //\r
+            // ToolCode (FileType)\r
+            //\r
             outputString[index][0] = outputList.get(index)[0];\r
+            //\r
+            // File name (relative to MODULE_DIR)\r
+            //\r
             outputString[index][1] = outputList.get(index)[1];\r
+            //\r
+            // Tool chain family\r
+            //\r
+            outputString[index][2] = outputList.get(index)[2];\r
         }\r
         return outputString;\r
     }\r
@@ -483,6 +491,22 @@ public class SurfaceAreaQuery {
 \r
         return getOptions("PlatformSurfaceArea", xPath, toolChainFamilyFlag);\r
     }\r
+    \r
+    public String[][] getMsaBuildOptions(boolean toolChainFamilyFlag) {\r
+        String[] xPath;\r
+        \r
+        if (toolChainFamilyFlag == true) {\r
+            xPath = new String[] {\r
+                    "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",\r
+                    "/Options/Option[@ToolChainFamily]", };\r
+        } else {\r
+            xPath = new String[] {\r
+                    "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",\r
+                    "/Options/Option[@TagName]", };\r
+        }\r
+\r
+        return getOptions("ModuleBuildOptions", xPath, toolChainFamilyFlag);\r
+    }\r
 \r
     public ToolChainInfo getFpdToolChainInfo() {\r
         String[] xPath = new String[] { "/PlatformDefinitions" };\r
@@ -1828,9 +1852,6 @@ public class SurfaceAreaQuery {
             guidPair[0] = entry.getCName();\r
             guidPair[1] = entry.getGuidValue();\r
             guidDeclMap.put(entry.getCName(), 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
@@ -1859,9 +1880,6 @@ public class SurfaceAreaQuery {
             protocolPair[0] = entry.getCName();\r
             protocolPair[1] = entry.getGuidValue();\r
             protoclMap.put(entry.getCName(), 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
@@ -1929,30 +1947,56 @@ public class SurfaceAreaQuery {
         return new ModuleSADocument.ModuleSA[0];\r
 \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
+       Get name array who contains all PCDs in a module according to specified arch.\r
+       \r
+       @param arch          The specified architecture type.\r
+       \r
+       @return String[]     return all PCDs name into array, if no any PCD used by\r
+                            this module, a String[0] array is returned.\r
     **/\r
-    public String[] getModulePcdEntryNameArray() {\r
+    public String[] getModulePcdEntryNameArray(String arch) {\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
+        java.util.List                       archList    = null;\r
+        java.util.List<String>               results     = new java.util.ArrayList<String> ();\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
+        pcdEntries  = (PcdCodedDocument.PcdCoded.PcdEntry[])returns;\r
 \r
         for (index = 0; index < pcdEntries.length; index ++) {\r
-            results[index] = pcdEntries[index].getCName();\r
+            archList        = pcdEntries[index].getSupArchList();\r
+            //\r
+            // If the ArchList is specified in MSA for this PCD, need check\r
+            // current arch whether can support by this PCD.\r
+            // \r
+            if (archList != null) {\r
+                if (archList.contains(arch)) {\r
+                    results.add(new String(pcdEntries[index].getCName()));\r
+                }\r
+            } else {\r
+                //\r
+                // If no ArchList is specificied in MSA for this PCD, that means\r
+                // this PCD support all architectures.\r
+                // \r
+                results.add(new String(pcdEntries[index].getCName()));\r
+            }\r
+        }\r
+\r
+        if (results.size() == 0) {\r
+            return new String[0];\r
         }\r
-        return results;\r
+\r
+        String[]    retArray = new String[results.size()];\r
+        results.toArray(retArray);\r
+\r
+        return retArray;        \r
     }\r
 \r
     /**\r
@@ -1992,6 +2036,32 @@ public class SurfaceAreaQuery {
                }\r
        }\r
     \r
+    public Node getPeiApriori(String fvName) {\r
+        String[] xPath = new String[] { "/BuildOptions/UserExtensions[@UserID='APRIORI' and @Identifier='0' and ./FvName='" + fvName + "']" };\r
+        Object[] result = get("PlatformSurfaceArea", xPath);\r
+        \r
+        if (result == null || result.length == 0) {\r
+            return null;\r
+        }\r
+        \r
+        UserExtensionsDocument.UserExtensions a =  (UserExtensionsDocument.UserExtensions)result[0];\r
+        \r
+        return a.getDomNode();\r
+    }\r
+    \r
+    public Node getDxeApriori(String fvName) {\r
+        String[] xPath = new String[] { "/BuildOptions/UserExtensions[@UserID='APRIORI' and @Identifier='1' and ./FvName='" + fvName + "']" };\r
+        Object[] result = get("PlatformSurfaceArea", xPath);\r
+        \r
+        if (result == null || result.length == 0) {\r
+            return null;\r
+        }\r
+        \r
+        UserExtensionsDocument.UserExtensions a =  (UserExtensionsDocument.UserExtensions)result[0];\r
+        \r
+        return a.getDomNode();\r
+    }\r
+    \r
     public Node getFpdModuleSequence(String fvName) {\r
         String[] xPath = new String[] { "/BuildOptions/UserExtensions[@UserID='IMAGES' and @Identifier='1' and ./FvName='" + fvName + "']" };\r
         Object[] result = get("PlatformSurfaceArea", xPath);\r
@@ -2004,4 +2074,25 @@ public class SurfaceAreaQuery {
         \r
         return a.getDomNode();\r
     }\r
+\r
+    /**\r
+     Get the value of PCD by PCD cName\r
+\r
+     @return PcdValue         String of PcdComponentName\r
+                null         If don't find ComponentName Pcd\r
+    **/\r
+    public String getPcdValueBycName(String cName){\r
+        String[] xPath = new String[] { "/PcdData" };\r
+        Object[] returns = get("PcdBuildDefinition", xPath);\r
+       if (returns == null || returns.length == 0) {\r
+           return  null;\r
+       } \r
+       for (int i = 0; i < returns.length; i++) {\r
+            PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)returns[i];\r
+           if (pcdData.getCName().equalsIgnoreCase(cName)){\r
+               return pcdData.getValue();\r
+            }\r
+        }\r
+        return null;\r
+    }\r
 }\r