summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python/build
diff options
context:
space:
mode:
Diffstat (limited to 'BaseTools/Source/Python/build')
-rw-r--r--BaseTools/Source/Python/build/build.py82
1 files changed, 57 insertions, 25 deletions
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py
index 6129308011..f608dee9b8 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -656,14 +656,16 @@ class PeImageInfo():
# @param BaseName The full file path of image.
# @param Guid The GUID for image.
# @param Arch Arch of this image.
- # @param OutpuDir The output directory for image.
+ # @param OutputDir The output directory for image.
+ # @param DebugDir The debug directory for image.
# @param ImageClass PeImage Information
#
- def __init__(self, BaseName, Guid, Arch, OutpuDir, ImageClass):
+ def __init__(self, BaseName, Guid, Arch, OutputDir, DebugDir, ImageClass):
self.BaseName = BaseName
self.Guid = Guid
self.Arch = Arch
- self.OutpuDir = OutpuDir
+ self.OutputDir = OutputDir
+ self.DebugDir = DebugDir
self.Image = ImageClass
self.Image.Size = (self.Image.Size / 0x1000 + 1) * 0x1000
@@ -704,7 +706,7 @@ class Build():
BuildTarget, FlashDefinition, FdList=[], FvList=[],
MakefileType="nmake", SilentMode=False, ThreadNumber=2,
SkipAutoGen=False, Reparse=False, SkuId=None,
- ReportFile=None, ReportType=None):
+ ReportFile=None, ReportType=None, UniFlag=None):
self.WorkspaceDir = WorkspaceDir
self.Target = Target
@@ -731,6 +733,7 @@ class Build():
self.BuildDatabase = self.Db.BuildObject
self.Platform = None
self.LoadFixAddress = 0
+ self.UniFlag = UniFlag
# print dot charater during doing some time-consuming work
self.Progress = Utils.Progressor()
@@ -1007,22 +1010,26 @@ class Build():
sys.stdout.flush()
ModuleInfo = ModuleList[InfFile]
ModuleName = ModuleInfo.BaseName
+ ModuleOutputImage = ModuleInfo.Image.FileName
+ ModuleDebugImage = os.path.join(ModuleInfo.DebugDir, ModuleInfo.BaseName + '.efi')
## for SMM module in SMRAM, the SMRAM will be allocated from base to top.
if not ModeIsSmm:
BaseAddress = BaseAddress - ModuleInfo.Image.Size
#
# Update Image to new BaseAddress by GenFw tool
#
- LaunchCommand(["GenFw", "--rebase", str(BaseAddress), "-r", ModuleInfo.Image.FileName], ModuleInfo.OutpuDir)
+ LaunchCommand(["GenFw", "--rebase", str(BaseAddress), "-r", ModuleOutputImage], ModuleInfo.OutputDir)
+ LaunchCommand(["GenFw", "--rebase", str(BaseAddress), "-r", ModuleDebugImage], ModuleInfo.DebugDir)
else:
#
# Set new address to the section header only for SMM driver.
#
- LaunchCommand(["GenFw", "--address", str(BaseAddress), "-r", ModuleInfo.Image.FileName], ModuleInfo.OutpuDir)
+ LaunchCommand(["GenFw", "--address", str(BaseAddress), "-r", ModuleOutputImage], ModuleInfo.OutputDir)
+ LaunchCommand(["GenFw", "--address", str(BaseAddress), "-r", ModuleDebugImage], ModuleInfo.DebugDir)
#
# Collect funtion address from Map file
#
- ImageMapTable = ModuleInfo.Image.FileName.replace('.efi', '.map')
+ ImageMapTable = ModuleOutputImage.replace('.efi', '.map')
FunctionList = []
if os.path.exists(ImageMapTable):
OrigImageBaseAddress = 0
@@ -1069,9 +1076,13 @@ class Build():
elif SectionHeader[0] in ['.data', '.sdata']:
DataSectionAddress = SectionHeader[1]
if AddrIsOffset:
- MapBuffer.write('(GUID=%s, .textbaseaddress=-0x%010X, .databaseaddress=-0x%010X)\n\n' % (ModuleInfo.Guid, 0 - (BaseAddress + TextSectionAddress), 0 - (BaseAddress + DataSectionAddress)))
+ MapBuffer.write('(GUID=%s, .textbaseaddress=-0x%010X, .databaseaddress=-0x%010X)\n' % (ModuleInfo.Guid, 0 - (BaseAddress + TextSectionAddress), 0 - (BaseAddress + DataSectionAddress)))
else:
- MapBuffer.write('(GUID=%s, .textbaseaddress=0x%010X, .databaseaddress=0x%010X)\n\n' % (ModuleInfo.Guid, BaseAddress + TextSectionAddress, BaseAddress + DataSectionAddress))
+ MapBuffer.write('(GUID=%s, .textbaseaddress=0x%010X, .databaseaddress=0x%010X)\n' % (ModuleInfo.Guid, BaseAddress + TextSectionAddress, BaseAddress + DataSectionAddress))
+ #
+ # Add debug image full path.
+ #
+ MapBuffer.write('(IMAGE=%s)\n\n' % (ModuleDebugImage))
#
# Add funtion address
#
@@ -1094,6 +1105,7 @@ class Build():
if self.Fdf != '':
# First get the XIP base address for FV map file.
GuidPattern = re.compile("[-a-fA-F0-9]+")
+ GuidName = re.compile("\(GUID=[-a-fA-F0-9]+")
for FvName in Wa.FdfProfile.FvDict.keys():
FvMapBuffer = os.path.join(Wa.FvDir, FvName + '.Fv.map')
if not os.path.exists(FvMapBuffer):
@@ -1114,6 +1126,15 @@ class Build():
if GuidString.upper() in ModuleList:
Line = Line.replace(GuidString, ModuleList[GuidString.upper()].Name)
MapBuffer.write('%s' % (Line))
+ #
+ # Add the debug image full path.
+ #
+ MatchGuid = GuidName.match(Line)
+ if MatchGuid != None:
+ GuidString = MatchGuid.group().split("=")[1]
+ if GuidString.upper() in ModuleList:
+ MapBuffer.write('(IMAGE=%s)\n' % (os.path.join(ModuleList[GuidString.upper()].DebugDir, ModuleList[GuidString.upper()].Name + '.efi')))
+
FvMap.close()
## Collect MAP information of all modules
@@ -1148,7 +1169,7 @@ class Build():
ImageClass = PeImageClass (OutputImageFile)
if not ImageClass.IsValid:
EdkLogger.error("build", FILE_PARSE_FAILURE, ExtraData=ImageClass.ErrorInfo)
- ImageInfo = PeImageInfo(Module.Name, Module.Guid, Module.Arch, Module.OutputDir, ImageClass)
+ ImageInfo = PeImageInfo(Module.Name, Module.Guid, Module.Arch, Module.OutputDir, Module.DebugDir, ImageClass)
if Module.ModuleType in ['PEI_CORE', 'PEIM', 'COMBINED_PEIM_DRIVER','PIC_PEIM', 'RELOCATABLE_PEIM', 'DXE_CORE']:
PeiModuleList[Module.MetaFile] = ImageInfo
PeiSize += ImageInfo.Image.Size
@@ -1268,7 +1289,9 @@ class Build():
#
# Save address map into MAP file.
#
- SaveFileOnChange(MapFilePath, MapBuffer.getvalue(), False)
+ MapFile = open(MapFilePath, "wb")
+ MapFile.write(MapBuffer.getvalue())
+ MapFile.close()
MapBuffer.close()
if self.LoadFixAddress != 0:
sys.stdout.write ("\nLoad Module At Fix Address Map file saved to %s\n" %(MapFilePath))
@@ -1291,7 +1314,8 @@ class Build():
self.Fdf,
self.FdList,
self.FvList,
- self.SkuId
+ self.SkuId,
+ self.UniFlag
)
self.BuildReport.AddPlatformReport(Wa)
self.Progress.Stop("done!")
@@ -1322,12 +1346,13 @@ class Build():
# Rebase module to the preferred memory address before GenFds
#
self._CollectModuleMapBuffer(MapBuffer, ModuleList)
+ if self.Fdf != '':
+ #
+ # create FDS again for the updated EFI image
+ #
+ self._Build("fds", Wa)
if self.Fdf != '':
#
- # create FDS again for the updated EFI image
- #
- self._Build("fds", Wa)
- #
# Create MAP file for all platform FVs after GenFds.
#
self._CollectFvMapBuffer(MapBuffer, Wa, ModuleList)
@@ -1357,7 +1382,8 @@ class Build():
self.Fdf,
self.FdList,
self.FvList,
- self.SkuId
+ self.SkuId,
+ self.UniFlag
)
Wa.CreateMakeFile(False)
self.Progress.Stop("done!")
@@ -1434,7 +1460,8 @@ class Build():
self.Fdf,
self.FdList,
self.FvList,
- self.SkuId
+ self.SkuId,
+ self.UniFlag
)
self.BuildReport.AddPlatformReport(Wa)
Wa.CreateMakeFile(False)
@@ -1521,14 +1548,12 @@ class Build():
if self.LoadFixAddress != 0:
self._CollectModuleMapBuffer(MapBuffer, ModuleList)
- # Generate FD image if there's a FDF file found
- if self.Fdf != '' and self.Target in ["", "all", "fds"]:
- LaunchCommand(Wa.BuildCommand + ["fds"], Wa.MakeFileDir)
-
- # Create MAP file for all platform FV after GenFds
- if self.Target in ["", "all", "fds"]:
if self.Fdf != '':
#
+ # Generate FD image if there's a FDF file found
+ #
+ LaunchCommand(Wa.BuildCommand + ["fds"], Wa.MakeFileDir)
+ #
# Create MAP file for all platform FVs after GenFds.
#
self._CollectFvMapBuffer(MapBuffer, Wa, ModuleList)
@@ -1711,6 +1736,10 @@ def MyOptionParser():
Parser.add_option("-Y", "--report-type", action="append", type="choice", choices=['PCD','LIBRARY','FLASH','DEPEX','BUILD_FLAGS','FIXED_ADDRESS', 'EXECUTION_ORDER'], dest="ReportType", default=[],
help="Flags that control the type of build report to generate. Must be one of: [PCD, LIBRARY, FLASH, DEPEX, BUILD_FLAGS, FIXED_ADDRESS, EXECUTION_ORDER]. "\
"To specify more than one flag, repeat this option on the command line and the default flag set is [PCD, LIBRARY, FLASH, DEPEX, BUILD_FLAGS, FIXED_ADDRESS]")
+ Parser.add_option("-F", "--flag", action="store", type="string", dest="Flag",
+ help="Specify the specific option to parse EDK UNI file. Must be one of: [-c, -s]. -c is for EDK framework UNI file, and -s is for EDK UEFI UNI file. "\
+ "This option can also be specified by setting *_*_*_BUILD_FLAGS in [BuildOptions] section of platform DSC. If they are both specified, this value "\
+ "will override the setting in [BuildOptions] section of platform DSC.")
(Opt, Args)=Parser.parse_args()
return (Opt, Args)
@@ -1822,12 +1851,15 @@ def Main():
if ErrorCode != 0:
EdkLogger.error("build", ErrorCode, ExtraData=ErrorInfo)
+ if Option.Flag != None and Option.Flag not in ['-c', '-s']:
+ EdkLogger.error("build", OPTION_VALUE_INVALID, "UNI flag must be one of -c or -s")
+
MyBuild = Build(Target, Workspace, Option.PlatformFile, Option.ModuleFile,
Option.TargetArch, Option.ToolChain, Option.BuildTarget,
Option.FdfFile, Option.RomImage, Option.FvImage,
None, Option.SilentMode, Option.ThreadNumber,
Option.SkipAutoGen, Option.Reparse, Option.SkuId,
- Option.ReportFile, Option.ReportType)
+ Option.ReportFile, Option.ReportType, Option.Flag)
MyBuild.Launch()
#MyBuild.DumpBuildData()
except FatalError, X: