]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java
For one library class, list all library instances from all packages in workspace.
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / FpdFileContents.java
index 9ca0509d3cf0441cd0783b921087e8ef5bbda1a9..b54715b877b59818e794350476983db9db1bc764 100644 (file)
@@ -91,6 +91,11 @@ public class FpdFileContents {
     \r
     private HashMap<String, String> defaultPcdValue = new HashMap<String, String>();\r
     \r
+    private String itemType (String pcdInfo) {\r
+        \r
+        return pcdInfo.substring(pcdInfo.lastIndexOf(" ") + 1);\r
+    }\r
+    \r
     /**\r
      * look through all pcd data in all ModuleSA, create pcd -> ModuleSA mappings.\r
      */\r
@@ -251,12 +256,22 @@ public class FpdFileContents {
     }\r
     \r
     public ModuleSADocument.ModuleSA getModuleSA(String key) {\r
-        String[] s = key.split(" ");\r
+        \r
         if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0) {\r
             removeElement(getfpdFrameworkModules());\r
             fpdFrameworkModules = null;\r
             return null;\r
         }\r
+        String[] s = key.split(" ");\r
+        String archsInKey = "";\r
+        if (s.length > 4) {\r
+            for (int i = 4; i < s.length; ++i) {\r
+                archsInKey += s[i];\r
+                archsInKey += " ";\r
+            }\r
+            archsInKey = archsInKey.trim();\r
+        }\r
+        \r
         ListIterator li = getfpdFrameworkModules().getModuleSAList().listIterator();\r
         while(li.hasNext()) {\r
             ModuleSADocument.ModuleSA moduleSa = (ModuleSADocument.ModuleSA)li.next();\r
@@ -271,13 +286,17 @@ public class FpdFileContents {
                         continue;\r
                     }\r
                 }\r
-                //ToDo add arch check for s[4]\r
+                //ToDo add arch check .\r
                 if (moduleSa.getSupArchList() != null) {\r
-                    if (!listToString(moduleSa.getSupArchList()).equals(s[4])) {\r
-                        continue;\r
+                    if (listToString(moduleSa.getSupArchList()).equals(archsInKey)) {\r
+                        return moduleSa;\r
+                    }\r
+                }\r
+                else {\r
+                    if (archsInKey.length() == 0) {\r
+                        return moduleSa;\r
                     }\r
                 }\r
-                return moduleSa;\r
             }\r
         }\r
         return null;\r
@@ -543,6 +562,9 @@ public class FpdFileContents {
             do {\r
                 PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)cursor.getObject();\r
                 if (pcdData.getCName().equals(cName) && pcdData.getTokenSpaceGuidCName().equals(tsGuid)) {\r
+                    //\r
+                    // change item type while not updating dynPcdData????\r
+                    //\r
                     pcdData.setItemType(PcdItemTypes.Enum.forString(itemType));\r
                     if(pcdData.getDatumType().equals("VOID*")) {\r
                         pcdData.setMaxDatumSize(new Integer(maxSize));\r
@@ -1179,8 +1201,8 @@ public class FpdFileContents {
         // Using existing Pcd type, if this pcd already exists in other ModuleSA\r
         //\r
         if (pcdConsumer.size() > 0) {\r
-            String[] valPart = pcdConsumer.get(0).split(" ");\r
-            itemType = valPart[5];\r
+            \r
+            itemType = itemType (pcdConsumer.get(0));\r
         }\r
         String listValue = moduleSa.getModuleGuid() + " " + moduleSa.getModuleVersion() \r
         + " " + moduleSa.getPackageGuid() + " " + moduleSa.getPackageVersion() + " " + listToString(moduleSa.getSupArchList())\r
@@ -2608,7 +2630,7 @@ public class FpdFileContents {
         }\r
     }\r
     \r
-    public void AddFvImageFvImageNames (String[] fvNames) {\r
+    public void addFvImageFvImageNames (String[] fvNames) {\r
         FvImagesDocument.FvImages fis = getfpdFlash().getFvImages();\r
         if (fis == null || fis.getFvImageList() == null) {\r
             genFvImagesFvImage (fvNames, "ImageName", null);\r
@@ -2619,14 +2641,35 @@ public class FpdFileContents {
         while (li.hasNext()) {\r
             FvImagesDocument.FvImages.FvImage fi = li.next();\r
             if (fi.getType().toString().equals("ImageName")) {\r
-                for (int i = 0; i < fvNames.length; ++i) {\r
-                    fi.addFvImageNames(fvNames[i]);\r
-                }\r
+                addFvImageNamesInFvImage (fi, fvNames);\r
                 return;\r
             }\r
         }\r
-        genFvImagesFvImage (fvNames, "ImageName", null);\r
+        genFvImagesFvImage (fvNames, "ImageName", null);    \r
+    }\r
+    \r
+    public void addFvImageNamesInFvImage (FvImagesDocument.FvImages.FvImage fi, String[] fvNames) {\r
         \r
+        for (int i = 0; i < fvNames.length; ++i) {\r
+            fi.addFvImageNames(fvNames[i]);\r
+        }\r
+    }\r
+    \r
+    public void addFvImageNamesInFvImage (int i, String[] fvNames) {\r
+        XmlObject o = getfpdFlash().getFvImages();\r
+        if (o == null) {\r
+            return;\r
+        }\r
+        XmlCursor cursor = o.newCursor();\r
+        QName qFvImage = new QName(xmlNs, "FvImage");\r
+        if (cursor.toChild(qFvImage)) {\r
+            for (int j = 0; j < i; ++j) {\r
+                cursor.toNextSibling(qFvImage);\r
+            }\r
+            FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();\r
+            addFvImageNamesInFvImage(fi, fvNames);\r
+        }\r
+        cursor.dispose();\r
     }\r
     \r
     public void genFvImagesFvImage(String[] names, String types, Map<String, String> options) {\r
@@ -2706,6 +2749,22 @@ public class FpdFileContents {
         }\r
     }\r
     \r
+    public void updateFvImageNamesInFvImage (int i, String oldFvName, String newFvName) {\r
+        XmlObject o = getfpdFlash().getFvImages();\r
+        if (o == null) {\r
+            return;\r
+        }\r
+        XmlCursor cursor = o.newCursor();\r
+        QName qFvImage = new QName(xmlNs, "FvImage");\r
+        if (cursor.toChild(qFvImage)) {\r
+            for (int j = 0; j < i; ++j) {\r
+                cursor.toNextSibling(qFvImage);\r
+            }\r
+            FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();\r
+            updateFvImageNamesInFvImage (fi, oldFvName, newFvName);\r
+        }\r
+        cursor.dispose();\r
+    }\r
     /**\r
      * @param fi\r
      * @param oldFvName The FV Name to be replaced.\r
@@ -2723,7 +2782,7 @@ public class FpdFileContents {
                         cursor.setTextValue(newFvName);\r
                     }\r
                     else {\r
-                            cursor.removeXml();\r
+                        cursor.removeXml();\r
                     }\r
                 }\r
             }while (cursor.toNextSibling(qFvImageNames));\r
@@ -2870,6 +2929,22 @@ public class FpdFileContents {
         }\r
     }\r
     \r
+    public void removeFvImageNameValue (int i, String attributeName) {\r
+        XmlObject o = getfpdFlash().getFvImages();\r
+        if (o == null) {\r
+            return;\r
+        }\r
+        XmlCursor cursor = o.newCursor();\r
+        QName qFvImage = new QName(xmlNs, "FvImage");\r
+        if (cursor.toChild(qFvImage)) {\r
+            for (int j = 0; j < i; ++j) {\r
+                cursor.toNextSibling(qFvImage);\r
+            }\r
+            FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();\r
+            removeFvImageNameValue (fi, attributeName);\r
+        }\r
+        cursor.dispose();\r
+    }\r
     /**Remove from fi the attribute pair with attributeName in FvImageOptions.\r
      * @param fi\r
      * @param attributeName\r
@@ -2953,6 +3028,23 @@ public class FpdFileContents {
         \r
     }\r
     \r
+    public void setFvImagesFvImageNameValue (int i, String name, String value) {\r
+        XmlObject o = getfpdFlash().getFvImages();\r
+        if (o == null) {\r
+            return;\r
+        }\r
+        XmlCursor cursor = o.newCursor();\r
+        QName qFvImage = new QName(xmlNs, "FvImage");\r
+        if (cursor.toChild(qFvImage)) {\r
+            for (int j = 0; j < i; ++j) {\r
+                cursor.toNextSibling(qFvImage);\r
+            }\r
+            FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();\r
+            setFvImagesFvImageNameValue (fi, name, value, null);\r
+        }\r
+        cursor.dispose();\r
+    }\r
+    \r
     /**Add to FvImage the name-value pair, or replace old name with newName, or generate new name-value pair if not exists before.\r
      * @param fi\r
      * @param name\r
@@ -2961,6 +3053,12 @@ public class FpdFileContents {
      */\r
     public void setFvImagesFvImageNameValue (FvImagesDocument.FvImages.FvImage fi, String name, String value, String newName) {\r
         if (fi.getFvImageOptions() == null || fi.getFvImageOptions().getNameValueList() == null) {\r
+            FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = fi.addNewFvImageOptions().addNewNameValue();\r
+            nv.setName(name);\r
+            nv.setValue(value);\r
+            if (newName != null) {\r
+                nv.setName(newName);\r
+            }\r
             return;\r
         }\r
         \r
@@ -3013,7 +3111,7 @@ public class FpdFileContents {
         }\r
         \r
         int pos = -1;\r
-        String[] fvNameArray = fvNameList.split(" ");\r
+        String[] fvNameArray = fvNameList.trim().split(" ");\r
         Vector<String> vFvNames = new Vector<String>();\r
         \r
         \r