]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java
draft UI implementation of module orders in FV.
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / FpdFileContents.java
index 6d9f84d6896fb28e817b3f8a5b99999fc2ee19f1..e60426446fbe826b66cf251432da64e9b5db78e4 100644 (file)
@@ -60,8 +60,8 @@ import org.tianocore.UserDefinedAntTasksDocument;
 import org.tianocore.UserExtensionsDocument;\r
 import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile;\r
 import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery;\r
-import org.tianocore.frameworkwizard.platform.ui.id.ModuleIdentification;\r
-import org.tianocore.frameworkwizard.platform.ui.id.PackageIdentification;\r
+import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r
+import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
 \r
 /**\r
  This class processes fpd file contents such as add remove xml elements. \r
@@ -184,6 +184,32 @@ public class FpdFileContents {
         return fpdFrameworkModules;\r
     }\r
     \r
+    public void getFrameworkModuleGuid (String fvName, Vector<String> vGuid) {\r
+        if (getFrameworkModulesCount() == 0){\r
+            return;\r
+        }\r
+        \r
+        ListIterator li = getfpdFrameworkModules().getModuleSAList().listIterator();\r
+        while(li.hasNext()) {\r
+            ModuleSADocument.ModuleSA moduleSa = (ModuleSADocument.ModuleSA)li.next();\r
+            if (moduleSa.getModuleSaBuildOptions() == null) {\r
+                continue;\r
+            }\r
+            String fvBinding = moduleSa.getModuleSaBuildOptions().getFvBinding();\r
+            if (fvBinding == null) {\r
+                continue;\r
+            }\r
+            \r
+            String[] fvNames = fvBinding.split(" ");\r
+            for (int i = 0; i < fvNames.length; ++i) {\r
+                if (fvNames[i].equals(fvName) || fvNames[i].replaceAll("_", "").equals(fvName)) {\r
+                    vGuid.add(moduleSa.getModuleGuid());\r
+                    break;\r
+                }\r
+            }\r
+        }\r
+    }\r
+    \r
     public int getFrameworkModulesCount() {\r
         if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){\r
             removeElement(getfpdFrameworkModules());\r
@@ -201,13 +227,13 @@ public class FpdFileContents {
         ListIterator li = getfpdFrameworkModules().getModuleSAList().listIterator();\r
         int i = 0;\r
         while(li.hasNext()) {\r
-            ModuleSADocument.ModuleSA msa = (ModuleSADocument.ModuleSA)li.next();\r
-            saa[i][0] = msa.getModuleGuid();\r
-            saa[i][1] = msa.getModuleVersion();\r
+            ModuleSADocument.ModuleSA moduleSa = (ModuleSADocument.ModuleSA)li.next();\r
+            saa[i][0] = moduleSa.getModuleGuid();\r
+            saa[i][1] = moduleSa.getModuleVersion();\r
             \r
-            saa[i][2] = msa.getPackageGuid();\r
-            saa[i][3] = msa.getPackageVersion();\r
-            saa[i][4] = listToString(msa.getSupArchList());\r
+            saa[i][2] = moduleSa.getPackageGuid();\r
+            saa[i][3] = moduleSa.getPackageVersion();\r
+            saa[i][4] = listToString(moduleSa.getSupArchList());\r
             ++i;\r
         }\r
     }\r
@@ -702,14 +728,14 @@ public class FpdFileContents {
         String mn = libMi.getName();\r
         String mg = libMi.getGuid();\r
         String mv = libMi.getVersion();\r
-        String pn = libMi.getPackage().getName();\r
-        String pg = libMi.getPackage().getGuid();\r
-        String pv = libMi.getPackage().getVersion();\r
+        String pn = libMi.getPackageId().getName();\r
+        String pg = libMi.getPackageId().getGuid();\r
+        String pv = libMi.getPackageId().getVersion();\r
         LibrariesDocument.Libraries.Instance instance = libs.addNewInstance();\r
         XmlCursor cursor = instance.newCursor();\r
         try{\r
             String comment = "Pkg: " + pn + " Mod: " + mn \r
-                + " Path: " + WorkspaceProfile.getMsaFile(libMi).getPath().substring(System.getenv("WORKSPACE").length() + 1);\r
+                + " Path: " + libMi.getPath().substring(System.getenv("WORKSPACE").length() + 1);\r
             cursor.insertComment(comment);\r
         }\r
         catch (Exception e){\r
@@ -739,11 +765,18 @@ public class FpdFileContents {
         if (msa == null ) {\r
             return;\r
         }\r
-        if(msa.getModuleSaBuildOptions() == null){\r
-            msa.addNewModuleSaBuildOptions().setFvBinding(fvBinding);\r
-            return;\r
+        if (fvBinding == null || fvBinding.length() == 0) {\r
+            if(msa.getModuleSaBuildOptions() != null){\r
+                msa.getModuleSaBuildOptions().unsetFvBinding();\r
+            }\r
+        }\r
+        else {\r
+            if(msa.getModuleSaBuildOptions() == null){\r
+                msa.addNewModuleSaBuildOptions().setFvBinding(fvBinding);\r
+                return;\r
+            }\r
+            msa.getModuleSaBuildOptions().setFvBinding(fvBinding);\r
         }\r
-        msa.getModuleSaBuildOptions().setFvBinding(fvBinding);\r
     }\r
     \r
     public String getFfsFileNameGuid(String moduleKey){\r
@@ -947,12 +980,10 @@ public class FpdFileContents {
     \r
     private PcdDeclarationsDocument.PcdDeclarations.PcdEntry LookupPcdDeclaration (PcdCodedDocument.PcdCoded.PcdEntry msaPcd, PackageIdentification[] depPkgs) {\r
         \r
-        Map<String, XmlObject> m = new HashMap<String, XmlObject>();\r
         PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = null;\r
         for (int i = 0; i < depPkgs.length; ++i) {\r
-            m.put("PackageSurfaceArea", WorkspaceProfile.getPackageXmlObject(depPkgs[i]));\r
-            SurfaceAreaQuery.setDoc(m);\r
-            XmlObject[] xo = SurfaceAreaQuery.getSpdPcdDeclarations();\r
+\r
+            XmlObject[] xo = SurfaceAreaQuery.getSpdPcdDeclarations(depPkgs[i]);\r
             if (xo == null) {\r
                 continue;\r
             }\r
@@ -980,8 +1011,8 @@ public class FpdFileContents {
         ModuleSADocument.ModuleSA msa = getfpdFrameworkModules().addNewModuleSA();\r
         XmlCursor cursor = msa.newCursor();\r
         try{\r
-            String comment = "Mod: " + mi.getName() + " Type: " + mi.getModuleType() + " Path: "\r
-                            + WorkspaceProfile.getMsaFile(mi).getPath().substring(System.getenv("WORKSPACE").length() + 1);\r
+            String comment = "Mod: " + mi.getName() + " Type: " + SurfaceAreaQuery.getModuleType(mi) + " Path: "\r
+                            + mi.getPath().substring(System.getenv("WORKSPACE").length() + 1);\r
             cursor.insertComment(comment);\r
         }\r
         catch(Exception e){\r
@@ -1145,7 +1176,7 @@ public class FpdFileContents {
                 \r
                 if (value > 0xFF) {\r
 //                   "[FPD file error] The datum type of PCD %s in %s is VOID*, "+\r
-//                   "it is byte array in fact. But the element of %s exceed the byte range",\r
+//                   "it must be a byte array. But the element of %s exceed the byte range",\r
                     throw new PcdValueMalFormed (datum);                               \r
                 }\r
             }\r
@@ -1498,7 +1529,7 @@ public class FpdFileContents {
         return fpdBuildOpts;\r
     }\r
     \r
-    public void genBuildOptionsUserExtensions(String fvName, String infName, String outputFileName, String[][] includeModules) {\r
+    public void genBuildOptionsUserExtensions(String fvName, String outputFileName, String[][] includeModules) {\r
         UserExtensionsDocument.UserExtensions userExts = getfpdBuildOpts().addNewUserExtensions();\r
         userExts.setUserID("IMAGES");\r
         userExts.setIdentifier(new BigInteger("1"));\r
@@ -1510,7 +1541,7 @@ public class FpdFileContents {
         cursor.toNextToken();\r
         \r
         cursor.beginElement("InfFileName");\r
-        cursor.insertChars(infName);\r
+        cursor.insertChars(fvName + ".inf");\r
         cursor.toNextToken();\r
         \r
         cursor.beginElement("IncludeModules");\r
@@ -1584,6 +1615,32 @@ public class FpdFileContents {
         \r
     }\r
     \r
+    public void removeBuildOptionsUserExtensions (String fvName) {\r
+        if (getfpdBuildOpts().getUserExtensionsList() == null) {\r
+            return;\r
+        }\r
+        \r
+        ListIterator<UserExtensionsDocument.UserExtensions> li = getfpdBuildOpts().getUserExtensionsList().listIterator();\r
+        while (li.hasNext()) {\r
+            UserExtensionsDocument.UserExtensions ues = li.next();\r
+            if (!ues.getUserID().equals("IMAGES")) {\r
+                continue;\r
+            }\r
+            XmlCursor cursor = ues.newCursor();\r
+            cursor.toFirstChild();\r
+            String elementName = cursor.getTextValue();\r
+            if (elementName.equals(fvName)) {\r
+                cursor.toParent();\r
+                cursor.removeXml();\r
+                cursor.dispose();\r
+                return;\r
+            }\r
+            cursor.dispose();\r
+        }\r
+        \r
+    }\r
+    \r
+    \r
     public void genBuildOptionsUserDefAntTask (String id, String fileName, String execOrder) {\r
         UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();\r
         if (udats == null) {\r
@@ -2693,7 +2750,7 @@ class PcdItemTypeConflictException extends Exception {
     \r
     PcdItemTypeConflictException(String pcdName, String info){\r
         ModuleIdentification mi = WorkspaceProfile.getModuleId(info);\r
-        details = pcdName + " ItemType Conflicts with " + mi.getName() + " in Pkg " + mi.getPackage().getName();\r
+        details = pcdName + " ItemType Conflicts with " + mi.getName() + " in Pkg " + mi.getPackageId().getName();\r
     }\r
     \r
     public String getMessage() {\r