Remove empty FfsFileNameGuid element under ModuleSaBuildOptions if user input empty...
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / FpdFileContents.java
index 0e1f4cc..6e7c79f 100644 (file)
@@ -40,6 +40,7 @@ import org.tianocore.FrameworkModulesDocument;
 import org.tianocore.IntermediateOutputType;\r
 import org.tianocore.LibrariesDocument;\r
 import org.tianocore.ModuleSADocument;\r
+import org.tianocore.ModuleSaBuildOptionsDocument;\r
 import org.tianocore.ModuleSurfaceAreaDocument;\r
 import org.tianocore.OptionDocument;\r
 import org.tianocore.OptionsDocument;\r
@@ -570,10 +571,21 @@ public class FpdFileContents {
             return;\r
         }\r
         if(msa.getModuleSaBuildOptions() == null){\r
-            msa.addNewModuleSaBuildOptions().setFfsFileNameGuid(fileGuid);\r
-            return;\r
+            msa.addNewModuleSaBuildOptions();\r
+            \r
+        }\r
+        ModuleSaBuildOptionsDocument.ModuleSaBuildOptions msaBuildOpts= msa.getModuleSaBuildOptions();\r
+        if (fileGuid != null) {\r
+            msaBuildOpts.setFfsFileNameGuid(fileGuid);\r
+        }\r
+        else{\r
+            XmlCursor cursor = msaBuildOpts.newCursor();\r
+            if (cursor.toChild(xmlNs, "FfsFileNameGuid")) {\r
+                cursor.removeXml();\r
+            }\r
+            cursor.dispose();\r
         }\r
-        msa.getModuleSaBuildOptions().setFfsFileNameGuid(fileGuid);\r
+        \r
     }\r
     \r
     public String getFfsFormatKey(String moduleKey){\r