##\r
# Import Modules\r
#\r
+from struct import *\r
import Section\r
from GenFdsGlobalVariable import GenFdsGlobalVariable\r
import subprocess\r
import shutil\r
from Common import EdkLogger\r
from Common.BuildToolError import *\r
+from Common.Misc import PeImageClass\r
\r
## generate rule section\r
#\r
FileList = []\r
if Filename != None:\r
Filename = GenFdsGlobalVariable.MacroExtend(Filename, Dict)\r
+ # check if the path is absolute or relative
+ if os.path.isabs(Filename):
+ Filename = os.path.normpath(Filename)
+ else:
+ Filename = os.path.normpath(os.path.join(FfsInf.EfiOutputPath, Filename))
+\r
if not self.Optional:\r
FileList.append(Filename)\r
elif os.path.exists(Filename):\r
f = open(File, 'r')\r
VerString = f.read()\r
f.close()\r
-# VerTuple = ('-n', '"' + VerString + '"')\r
BuildNum = VerString\r
if BuildNum != None and BuildNum != '':\r
BuildNumTuple = ('-j', BuildNum)\r
OutputFileList.append(OutputFile)\r
\r
else:\r
-# if StringData != None and len(StringData) > 0:\r
-# VerTuple = ('-n', '"' + StringData + '"')\r
-# else:\r
-# VerTuple = tuple()\r
-# VerString = ' ' + ' '.join(VerTuple)\r
BuildNum = StringData\r
if BuildNum != None and BuildNum != '':\r
BuildNumTuple = ('-j', BuildNum)\r
Num = '%s.%d' %(SecNum , Index)\r
OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get(SectionType))\r
File = GenFdsGlobalVariable.MacroExtend(File, Dict)\r
+ \r
+ #Get PE Section alignment when align is set to AUTO\r
+ if self.Alignment == 'Auto' and (SectionType == 'PE32' or SectionType == 'TE'):\r
+ ImageObj = PeImageClass (File)\r
+ if ImageObj.SectionAlignment < 0x400:\r
+ self.Alignment = str (ImageObj.SectionAlignment)\r
+ else:\r
+ self.Alignment = str (ImageObj.SectionAlignment / 0x400) + 'K'\r
+\r
if File[(len(File)-4):] == '.efi':\r
MapFile = File.replace('.efi', '.map')\r
if os.path.exists(MapFile):\r
StrippedFile = os.path.join(OutputPath, ModuleName + '.stripped')\r
GenFdsGlobalVariable.GenerateFirmwareImage(\r
StrippedFile,\r
- [GenFdsGlobalVariable.MacroExtend(File, Dict)],\r
+ [File],\r
Strip=True\r
)\r
File = StrippedFile\r
+ \r
"""For TE Section call GenFw to generate TE image"""\r
\r
if SectionType == 'TE':\r
TeFile = os.path.join( OutputPath, ModuleName + 'Te.raw')\r
GenFdsGlobalVariable.GenerateFirmwareImage(\r
TeFile,\r
- [GenFdsGlobalVariable.MacroExtend(File, Dict)],\r
+ [File],\r
Type='te'\r
)\r
File = TeFile\r
\r
"""Call GenSection"""\r
GenFdsGlobalVariable.GenerateSection(OutputFile,\r
- [GenFdsGlobalVariable.MacroExtend(File)],\r
+ [File],\r
Section.Section.SectionType.get (SectionType)\r
)\r
OutputFileList.append(OutputFile)\r