]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
Sync BaseTool trunk (version r2599) into EDKII BaseTools.
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / GenFdsGlobalVariable.py
index ea6b191bc1254178afe92cd048b7aa25f87dff82..2fa4cb8c0dfa411a3991e4b20db26a41c7082ef4 100644 (file)
@@ -1,7 +1,7 @@
 ## @file
 # Global variables for GenFds
 #
-#  Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
@@ -345,7 +345,7 @@ class GenFdsGlobalVariable:
 
     @staticmethod
     def GenerateSection(Output, Input, Type=None, CompressionType=None, Guid=None,
-                        GuidHdrLen=None, GuidAttr=[], Ui=None, Ver=None, InputAlign=None):
+                        GuidHdrLen=None, GuidAttr=[], Ui=None, Ver=None, InputAlign=None, BuildNumber=None):
         Cmd = ["GenSec"]
         if Type not in [None, '']:
             Cmd += ["-s", Type]
@@ -364,6 +364,7 @@ class GenFdsGlobalVariable:
             for SecAlign in InputAlign:
                 Cmd += ["--sectionalign", SecAlign]
 
+        CommandFile = Output + '.txt'
         if Ui not in [None, '']:
             #Cmd += ["-n", '"' + Ui + '"']
             SectionData = array.array('B', [0,0,0,0])
@@ -374,19 +375,20 @@ class GenFdsGlobalVariable:
             GenFdsGlobalVariable.SectionHeader.pack_into(SectionData, 0, Len & 0xff, (Len >> 8) & 0xff, (Len >> 16) & 0xff, 0x15)
             SaveFileOnChange(Output,  SectionData.tostring())
         elif Ver not in [None, '']:
-            #Cmd += ["-j", Ver]
-            SectionData = array.array('B', [0,0,0,0])
-            SectionData.fromstring(Ver.encode("utf_16_le"))
-            SectionData.append(0)
-            SectionData.append(0)
-            Len = len(SectionData)
-            GenFdsGlobalVariable.SectionHeader.pack_into(SectionData, 0, Len & 0xff, (Len >> 8) & 0xff, (Len >> 16) & 0xff, 0x14)
-            SaveFileOnChange(Output,  SectionData.tostring())
+            Cmd += ["-n", Ver]
+            if BuildNumber:
+                Cmd += ["-j", BuildNumber]
+            Cmd += ["-o", Output]
+
+            SaveFileOnChange(CommandFile, ' '.join(Cmd), False)
+            if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [CommandFile]):
+                return
+
+            GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate section")
         else:
             Cmd += ["-o", Output]
             Cmd += Input
 
-            CommandFile = Output + '.txt'
             SaveFileOnChange(CommandFile, ' '.join(Cmd), False)
             if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [CommandFile]):
                 return
@@ -581,7 +583,7 @@ class GenFdsGlobalVariable:
                 sys.stdout.write('\n')
 
         try:
-            PopenObject = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr= subprocess.PIPE)
+            PopenObject = subprocess.Popen(' '.join(cmd), stdout=subprocess.PIPE, stderr= subprocess.PIPE, shell=True)
         except Exception, X:
             EdkLogger.error("GenFds", COMMAND_FAILURE, ExtraData="%s: %s" % (str(X), cmd[0]))
         (out, error) = PopenObject.communicate()