]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java
Fixed the Indentifier type issue.
[mirror_edk2.git] / Tools / Java / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / FpdFileContents.java
index 130b625e753a22606fc21ee5a8ac67395be600d6..d8dfb279ba59f2228a4fce57ceb13b79fb57ad91 100644 (file)
@@ -62,6 +62,7 @@ import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile;
 import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery;\r
 import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r
 import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
+import org.tianocore.frameworkwizard.workspace.Workspace;\r
 \r
 /**\r
  This class processes fpd file contents such as add remove xml elements. \r
@@ -383,7 +384,7 @@ public class FpdFileContents {
         cursor.dispose();\r
     }\r
     \r
-    public boolean adjustPcd (int seqModuleSa) throws Exception {\r
+    public boolean adjustPcd (int seqModuleSa, Vector<String> vExceptions) throws Exception {\r
         boolean dataModified = false;\r
         ModuleSADocument.ModuleSA moduleSa = getModuleSA(seqModuleSa);\r
         int pcdCount = getPcdDataCount(seqModuleSa);\r
@@ -403,6 +404,7 @@ public class FpdFileContents {
         getLibraryInstances(moduleKey, saaLib);\r
         ModuleIdentification mi = WorkspaceProfile.getModuleId(moduleKey);\r
         if (mi == null) {\r
+            vExceptions.add("Module " + mg + " does NOT exist in workspace.");\r
             throw new Exception ("Module does NOT exist in workspace.");\r
         }\r
         Vector<ModuleIdentification> vMi = new Vector<ModuleIdentification>();\r
@@ -413,7 +415,9 @@ public class FpdFileContents {
         for (int j = 0; j < saaLib.length; ++j) {\r
             String libKey = saaLib[j][1] + " " + saaLib[j][2] + " " + saaLib[j][3] + " " + saaLib[j][4];\r
             ModuleIdentification libMi = WorkspaceProfile.getModuleId(libKey);\r
-            vMi.add(libMi);\r
+            if (libMi != null) {\r
+                vMi.add(libMi);\r
+            }\r
         }\r
         \r
     nextPcd:for (int i = 0; i < saaModuleSaPcd.length; ++i) {\r
@@ -423,7 +427,7 @@ public class FpdFileContents {
                     if (nextMi == null) {\r
                         continue;\r
                     }\r
-                    if (WorkspaceProfile.pcdInMsa(saaModuleSaPcd[i][0], saaModuleSaPcd[i][1], nextMi)) {\r
+                    if (WorkspaceProfile.pcdInMsa(saaModuleSaPcd[i][0], saaModuleSaPcd[i][1], arch, nextMi)) {\r
                         continue nextPcd;\r
                     }\r
                 }\r
@@ -451,6 +455,13 @@ public class FpdFileContents {
                             }\r
                         }\r
                     }\r
+                    // Check sup arch conformance for the new PCD\r
+                    if (msaPcd.getSupArchList() != null) {\r
+                       String newPcdArch = msaPcd.getSupArchList().toString();\r
+                       if (!newPcdArch.toLowerCase().contains(arch.toLowerCase())) {\r
+                               continue;\r
+                       }\r
+                    }\r
                     \r
                     PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null, vMi.get(i));\r
                     PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs);\r
@@ -458,8 +469,13 @@ public class FpdFileContents {
                         //\r
                         // ToDo Error \r
                         //\r
-                        throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd.getCName() + " in Module "\r
-                                                  + mi.getName());\r
+                        String errorMessage = "No Declaration for PCD Entry " + msaPcd.getCName() + " in Module "\r
+                        + mi.getName();\r
+                        if (i != 0) {\r
+                            errorMessage += " Library Instance " + vMi.get(i).getName(); \r
+                        }\r
+                        vExceptions.add(errorMessage);\r
+                        throw new PcdDeclNotFound(errorMessage);\r
                     }\r
                     //\r
                     // AddItem to ModuleSA PcdBuildDefinitions\r
@@ -677,7 +693,7 @@ public class FpdFileContents {
         \r
         int pcdSourceCount = 0;\r
         for (int i = 0; i < vMi.size(); ++i) {\r
-            if (WorkspaceProfile.pcdInMsa(cName, tsGuidCName, vMi.get(i))) {\r
+            if (WorkspaceProfile.pcdInMsa(cName, tsGuidCName, null, vMi.get(i))) {\r
                 pcdSourceCount++;\r
             }\r
         }\r
@@ -821,7 +837,7 @@ public class FpdFileContents {
         XmlCursor cursor = instance.newCursor();\r
         try{\r
             String comment = "Pkg: " + pn + " Mod: " + mn \r
-                + " Path: " + libMi.getPath().substring(System.getenv("WORKSPACE").length() + 1);\r
+                + " Path: " + libMi.getPath().substring(Workspace.getCurrentWorkspace().length() + 1);\r
             cursor.insertComment(comment);\r
         }\r
         catch (Exception e){\r
@@ -1170,13 +1186,18 @@ public class FpdFileContents {
         ListIterator li = l.listIterator();\r
         while (li.hasNext()) {\r
             PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry) li.next();\r
+            if (msaPcd.getSupArchList() != null) {\r
+               if (!msaPcd.getSupArchList().toString().toLowerCase().contains(arch.toLowerCase())) {\r
+                       continue;\r
+               }\r
+            }\r
             PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs);\r
             if (spdPcd == null) {\r
                 //\r
                 // ToDo Error \r
                 //\r
-                throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd.getCName() + " in Module "\r
-                                          + mi.getName());\r
+                throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd.getCName() + "\n used by Module "\r
+                                          + mi.getName() + " or its Library Instances.");\r
             }\r
             //\r
             // AddItem to ModuleSA PcdBuildDefinitions\r
@@ -1224,7 +1245,7 @@ public class FpdFileContents {
         XmlCursor cursor = msa.newCursor();\r
         try{\r
             String comment = "Mod: " + mi.getName() + " Type: " + SurfaceAreaQuery.getModuleType(mi) + " Path: "\r
-                            + mi.getPath().substring(System.getenv("WORKSPACE").length() + 1);\r
+                            + mi.getPath().substring(Workspace.getCurrentWorkspace().length() + 1);\r
             cursor.insertComment(comment);\r
         }\r
         catch(Exception e){\r
@@ -1337,7 +1358,7 @@ public class FpdFileContents {
         fpdPcd.setDatumType(PcdDataTypes.Enum.forString(dataType));\r
         fpdPcd.setItemType(PcdItemTypes.Enum.forString(itemType));\r
         \r
-        if (defaultVal != null){\r
+        if (defaultVal != null && defaultVal.length() > 0){\r
             fpdPcd.setValue(defaultVal);\r
         }\r
         else {\r
@@ -1348,7 +1369,7 @@ public class FpdFileContents {
                 fpdPcd.setValue("FALSE");\r
             }\r
             if (dataType.equals("VOID*")) {\r
-                fpdPcd.setValue("");\r
+                fpdPcd.setValue("L\"\"");\r
             }\r
         }\r
         //\r
@@ -1499,7 +1520,7 @@ public class FpdFileContents {
             saa[i][1] = dynPcd.getToken().toString();\r
             saa[i][2] = dynPcd.getTokenSpaceGuidCName();\r
             saa[i][3] = dynPcd.getMaxDatumSize()+"";\r
-            saa[i][4] = dynPcd.getDatumType().toString();\r
+            saa[i][4] = dynPcd.getDatumType()+"";\r
             \r
             ++i;\r
         }\r
@@ -1724,9 +1745,10 @@ public class FpdFileContents {
                 return;\r
             }\r
             else {\r
-                QName qSkuInfo = new QName(xmlNs, "SkuInfo");\r
-                cursor.toChild(qSkuInfo);\r
-                cursor.removeXml();\r
+               pcdData.getSkuInfoList().clear();\r
+//                QName qSkuInfo = new QName(xmlNs, "SkuInfo");\r
+//                cursor.toChild(qSkuInfo);\r
+//                cursor.removeXml();\r
             }\r
         }\r
         cursor.dispose();\r
@@ -1814,7 +1836,7 @@ public class FpdFileContents {
         \r
         UserExtensionsDocument.UserExtensions userExts = getfpdBuildOpts().addNewUserExtensions();\r
         userExts.setUserID(userId);\r
-        userExts.setIdentifier(new BigInteger(id));\r
+        userExts.setIdentifier(id);\r
         XmlCursor cursor = userExts.newCursor();\r
         cursor.toEndToken();\r
         \r
@@ -1857,7 +1879,7 @@ public class FpdFileContents {
             if (!ues.getUserID().equals(userId)) {\r
                 continue;\r
             }\r
-            if (ues.getIdentifier() == null || ues.getIdentifier().intValue() != id) {\r
+            if (ues.getIdentifier() == null || ues.getIdentifier() != new Integer(id).toString()) {\r
                 continue;\r
             }\r
             XmlCursor cursor = ues.newCursor();\r
@@ -1957,7 +1979,7 @@ public class FpdFileContents {
             if (!ues.getUserID().equals(userId)) {\r
                 continue;\r
             }\r
-            if (ues.getIdentifier()== null || ues.getIdentifier().intValue() != id) {\r
+            if (ues.getIdentifier()== null || ues.getIdentifier() != new Integer(id).toString()) {\r
                 continue;\r
             }\r
             XmlCursor cursor = ues.newCursor();\r
@@ -2129,7 +2151,7 @@ public class FpdFileContents {
             if (!ues.getUserID().equals(userId)) {\r
                 continue;\r
             }\r
-            if (ues.getIdentifier() == null || ues.getIdentifier().intValue() != id) {\r
+            if (ues.getIdentifier() == null || ues.getIdentifier() != new Integer(id).toString()) {\r
                 continue;\r
             }\r
             XmlCursor cursor = ues.newCursor();\r
@@ -2391,10 +2413,8 @@ public class FpdFileContents {
     }\r
     \r
     public void updateBuildOptionsFfsSectionsType(int i, String type) {\r
-        BuildOptionsDocument.BuildOptions.Ffs ffs = getfpdBuildOpts().addNewFfs();\r
-        if (type != null) {\r
-            ffs.addNewSections().setEncapsulationType(type);\r
-        }\r
+        BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
+        ffs.getSections().setEncapsulationType(type);\r
     }\r
     \r
     public void genBuildOptionsFfsAttribute(int i, String name, String value) {\r
@@ -3695,10 +3715,10 @@ class PcdItemTypeConflictException extends Exception {
     PcdItemTypeConflictException (String pcdName, String info) {\r
         ModuleIdentification mi = WorkspaceProfile.getModuleId(info);\r
         if (mi != null) {\r
-            details = pcdName + " ItemType Conflicts with " + mi.getName() + " in Pkg " + mi.getPackageId().getName();    \r
+            details = pcdName + " ItemType Conflicts with " + mi.getName() + "\n in Pkg " + mi.getPackageId().getName();    \r
         }\r
         else {\r
-            details = pcdName + " ItemType Conflicts with " + info;\r
+            details = pcdName + " ItemType Conflicts with \n" + info;\r
         }\r
     }\r
     \r
@@ -3721,7 +3741,7 @@ class PcdItemTypeConflictException extends Exception {
             moduleInfo2 = info2;\r
         }\r
         \r
-        details = pcdName + " ItemType Conflicts in " + moduleInfo1 + " and " + moduleInfo2;\r
+        details = pcdName + " ItemType Conflicts in \n" + moduleInfo1 + "\n and " + moduleInfo2;\r
     }\r
     \r
     public String getMessage() {\r