mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-11-27 12:15:19 +01:00
update python tools
Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
parent
d49c68ae80
commit
66218af8aa
@ -3,13 +3,7 @@
|
||||
#
|
||||
# Copyright (c) 2007 - 2017, 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
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#
|
||||
|
||||
ifndef HOST_ARCH
|
||||
@ -50,7 +44,6 @@ all: makerootdir subdirs
|
||||
|
||||
LIBRARIES = Common
|
||||
VFRAUTOGEN = VfrCompile/VfrLexer.h
|
||||
# NON_BUILDABLE_APPLICATIONS = GenBootSector BootSectImage
|
||||
APPLICATIONS = \
|
||||
BrotliCompress \
|
||||
VfrCompile \
|
||||
|
@ -1017,6 +1017,31 @@ WriteSections64 (
|
||||
} else if (mEhdr->e_machine == EM_AARCH64) {
|
||||
|
||||
switch (ELF_R_TYPE(Rel->r_info)) {
|
||||
INT64 Offset;
|
||||
|
||||
case R_AARCH64_LD64_GOT_LO12_NC:
|
||||
//
|
||||
// Convert into an ADD instruction - see R_AARCH64_ADR_GOT_PAGE below.
|
||||
//
|
||||
*(UINT32 *)Targ &= 0x3ff;
|
||||
*(UINT32 *)Targ |= 0x91000000 | ((Sym->st_value & 0xfff) << 10);
|
||||
break;
|
||||
|
||||
case R_AARCH64_ADR_GOT_PAGE:
|
||||
//
|
||||
// This relocation points to the GOT entry that contains the absolute
|
||||
// address of the symbol we are referring to. Since EDK2 only uses
|
||||
// fully linked binaries, we can avoid the indirection, and simply
|
||||
// refer to the symbol directly. This implies having to patch the
|
||||
// subsequent LDR instruction (covered by a R_AARCH64_LD64_GOT_LO12_NC
|
||||
// relocation) into an ADD instruction - this is handled above.
|
||||
//
|
||||
Offset = (Sym->st_value - (Rel->r_offset & ~0xfff)) >> 12;
|
||||
|
||||
*(UINT32 *)Targ &= 0x9000001f;
|
||||
*(UINT32 *)Targ |= ((Offset & 0x1ffffc) << (5 - 2)) | ((Offset & 0x3) << 29);
|
||||
|
||||
/* fall through */
|
||||
|
||||
case R_AARCH64_ADR_PREL_PG_HI21:
|
||||
//
|
||||
@ -1037,7 +1062,6 @@ WriteSections64 (
|
||||
// Attempt to convert the ADRP into an ADR instruction.
|
||||
// This is only possible if the symbol is within +/- 1 MB.
|
||||
//
|
||||
INT64 Offset;
|
||||
|
||||
// Decode the ADRP instruction
|
||||
Offset = (INT32)((*(UINT32 *)Targ & 0xffffe0) << 8);
|
||||
@ -1212,6 +1236,8 @@ WriteRelocations64 (
|
||||
case R_AARCH64_LDST32_ABS_LO12_NC:
|
||||
case R_AARCH64_LDST64_ABS_LO12_NC:
|
||||
case R_AARCH64_LDST128_ABS_LO12_NC:
|
||||
case R_AARCH64_ADR_GOT_PAGE:
|
||||
case R_AARCH64_LD64_GOT_LO12_NC:
|
||||
//
|
||||
// No fixups are required for relative relocations, provided that
|
||||
// the relative offsets between sections have been preserved in
|
||||
|
@ -1111,6 +1111,7 @@ Returns:
|
||||
time_t InputFileTime;
|
||||
time_t OutputFileTime;
|
||||
struct stat Stat_Buf;
|
||||
BOOLEAN ZeroDebugFlag;
|
||||
|
||||
SetUtilityName (UTILITY_NAME);
|
||||
|
||||
@ -1158,6 +1159,7 @@ Returns:
|
||||
NegativeAddr = FALSE;
|
||||
InputFileTime = 0;
|
||||
OutputFileTime = 0;
|
||||
ZeroDebugFlag = FALSE;
|
||||
|
||||
if (argc == 1) {
|
||||
Error (NULL, 0, 1001, "Missing options", "No input options.");
|
||||
@ -1197,6 +1199,9 @@ Returns:
|
||||
goto Finish;
|
||||
}
|
||||
ModuleType = argv[1];
|
||||
if (mOutImageType == FW_ZERO_DEBUG_IMAGE) {
|
||||
ZeroDebugFlag = TRUE;
|
||||
}
|
||||
if (mOutImageType != FW_TE_IMAGE) {
|
||||
mOutImageType = FW_EFI_IMAGE;
|
||||
}
|
||||
@ -1220,6 +1225,9 @@ Returns:
|
||||
}
|
||||
|
||||
if ((stricmp (argv[0], "-t") == 0) || (stricmp (argv[0], "--terse") == 0)) {
|
||||
if (mOutImageType == FW_ZERO_DEBUG_IMAGE) {
|
||||
ZeroDebugFlag = TRUE;
|
||||
}
|
||||
mOutImageType = FW_TE_IMAGE;
|
||||
argc --;
|
||||
argv ++;
|
||||
@ -1241,7 +1249,12 @@ Returns:
|
||||
}
|
||||
|
||||
if ((stricmp (argv[0], "-z") == 0) || (stricmp (argv[0], "--zero") == 0)) {
|
||||
if (mOutImageType == FW_DUMMY_IMAGE) {
|
||||
mOutImageType = FW_ZERO_DEBUG_IMAGE;
|
||||
}
|
||||
if (mOutImageType == FW_TE_IMAGE || mOutImageType == FW_EFI_IMAGE) {
|
||||
ZeroDebugFlag = TRUE;
|
||||
}
|
||||
argc --;
|
||||
argv ++;
|
||||
continue;
|
||||
@ -2588,7 +2601,7 @@ Returns:
|
||||
//
|
||||
// Zero Time/Data field
|
||||
//
|
||||
ZeroDebugData (FileBuffer, FALSE);
|
||||
ZeroDebugData (FileBuffer, ZeroDebugFlag);
|
||||
|
||||
if (mOutImageType == FW_TE_IMAGE) {
|
||||
if ((PeHdr->Pe32.FileHeader.NumberOfSections &~0xFF) || (Type &~0xFF)) {
|
||||
|
@ -2,13 +2,7 @@
|
||||
# Windows makefile for C tools build.
|
||||
#
|
||||
# Copyright (c) 2009 - 2018, 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
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#
|
||||
HOST_ARCH = IA32
|
||||
|
||||
@ -71,6 +65,8 @@ clean:
|
||||
cleanall:
|
||||
@if defined PYTHON_COMMAND $(PYTHON_COMMAND) Makefiles\NmakeSubdirs.py cleanall $(LIBRARIES) $(APPLICATIONS)
|
||||
@if not defined PYTHON_COMMAND $(PYTHON_HOME)\python.exe Makefiles\NmakeSubdirs.py cleanall $(LIBRARIES) $(APPLICATIONS)
|
||||
# Next line protects the libs pseudo target from inadvertent GNU make activity
|
||||
if exist libs RMDIR /S /Q libs
|
||||
|
||||
!INCLUDE Makefiles\ms.rule
|
||||
|
||||
|
@ -155,10 +155,11 @@ class AutoGenWorkerInProcess(mp.Process):
|
||||
try:
|
||||
taskname = "Init"
|
||||
with self.file_lock:
|
||||
if not os.path.exists(self.data_pipe_file_path):
|
||||
try:
|
||||
self.data_pipe = MemoryDataPipe()
|
||||
self.data_pipe.load(self.data_pipe_file_path)
|
||||
except:
|
||||
self.feedback_q.put(taskname + ":" + "load data pipe %s failed." % self.data_pipe_file_path)
|
||||
self.data_pipe = MemoryDataPipe()
|
||||
self.data_pipe.load(self.data_pipe_file_path)
|
||||
EdkLogger.LogClientInitialize(self.log_q)
|
||||
loglevel = self.data_pipe.Get("LogLevel")
|
||||
if not loglevel:
|
||||
@ -241,7 +242,7 @@ class AutoGenWorkerInProcess(mp.Process):
|
||||
continue
|
||||
|
||||
Ma.CreateCodeFile(False)
|
||||
Ma.CreateMakeFile(False,GenFfsList=FfsCmd.get((Ma.MetaFile.File, Ma.Arch),[]))
|
||||
Ma.CreateMakeFile(False,GenFfsList=FfsCmd.get((Ma.MetaFile.Path, Ma.Arch),[]))
|
||||
|
||||
if GlobalData.gBinCacheSource and CommandTarget in [None, "", "all"]:
|
||||
Ma.GenMakeHeaderFilesHash(GlobalData.gCacheIR)
|
||||
|
@ -176,7 +176,9 @@ class FileBuildRule:
|
||||
CommandString = "\n\t".join(self.CommandList)
|
||||
return "%s : %s\n\t%s" % (DestString, SourceString, CommandString)
|
||||
|
||||
def Instantiate(self, Macros={}):
|
||||
def Instantiate(self, Macros = None):
|
||||
if Macros is None:
|
||||
Macros = {}
|
||||
NewRuleObject = copy.copy(self)
|
||||
NewRuleObject.BuildTargets = {}
|
||||
NewRuleObject.DestFileList = []
|
||||
|
@ -1748,59 +1748,60 @@ def CreateIdfFileCode(Info, AutoGenC, StringH, IdfGenCFlag, IdfGenBinBuffer):
|
||||
for FileObj in ImageFiles.ImageFilesDict[Idf]:
|
||||
ID = FileObj.ImageID
|
||||
File = FileObj.File
|
||||
if not os.path.exists(File.Path) or not os.path.isfile(File.Path):
|
||||
EdkLogger.error("build", FILE_NOT_FOUND, ExtraData=File.Path)
|
||||
SearchImageID (FileObj, FileList)
|
||||
if FileObj.Referenced:
|
||||
if (ValueStartPtr - len(DEFINE_STR + ID)) <= 0:
|
||||
Line = DEFINE_STR + ' ' + ID + ' ' + DecToHexStr(Index, 4) + '\n'
|
||||
else:
|
||||
Line = DEFINE_STR + ' ' + ID + ' ' * (ValueStartPtr - len(DEFINE_STR + ID)) + DecToHexStr(Index, 4) + '\n'
|
||||
try:
|
||||
SearchImageID (FileObj, FileList)
|
||||
if FileObj.Referenced:
|
||||
if (ValueStartPtr - len(DEFINE_STR + ID)) <= 0:
|
||||
Line = DEFINE_STR + ' ' + ID + ' ' + DecToHexStr(Index, 4) + '\n'
|
||||
else:
|
||||
Line = DEFINE_STR + ' ' + ID + ' ' * (ValueStartPtr - len(DEFINE_STR + ID)) + DecToHexStr(Index, 4) + '\n'
|
||||
|
||||
if File not in FileDict:
|
||||
FileDict[File] = Index
|
||||
else:
|
||||
DuplicateBlock = pack('B', EFI_HII_IIBT_DUPLICATE)
|
||||
DuplicateBlock += pack('H', FileDict[File])
|
||||
ImageBuffer += DuplicateBlock
|
||||
if File not in FileDict:
|
||||
FileDict[File] = Index
|
||||
else:
|
||||
DuplicateBlock = pack('B', EFI_HII_IIBT_DUPLICATE)
|
||||
DuplicateBlock += pack('H', FileDict[File])
|
||||
ImageBuffer += DuplicateBlock
|
||||
BufferStr = WriteLine(BufferStr, '// %s: %s: %s' % (DecToHexStr(Index, 4), ID, DecToHexStr(Index, 4)))
|
||||
TempBufferList = AscToHexList(DuplicateBlock)
|
||||
BufferStr = WriteLine(BufferStr, CreateArrayItem(TempBufferList, 16) + '\n')
|
||||
StringH.Append(Line)
|
||||
Index += 1
|
||||
continue
|
||||
|
||||
TmpFile = open(File.Path, 'rb')
|
||||
Buffer = TmpFile.read()
|
||||
TmpFile.close()
|
||||
if File.Ext.upper() == '.PNG':
|
||||
TempBuffer = pack('B', EFI_HII_IIBT_IMAGE_PNG)
|
||||
TempBuffer += pack('I', len(Buffer))
|
||||
TempBuffer += Buffer
|
||||
elif File.Ext.upper() == '.JPG':
|
||||
ImageType, = struct.unpack('4s', Buffer[6:10])
|
||||
if ImageType != b'JFIF':
|
||||
EdkLogger.error("build", FILE_TYPE_MISMATCH, "The file %s is not a standard JPG file." % File.Path)
|
||||
TempBuffer = pack('B', EFI_HII_IIBT_IMAGE_JPEG)
|
||||
TempBuffer += pack('I', len(Buffer))
|
||||
TempBuffer += Buffer
|
||||
elif File.Ext.upper() == '.BMP':
|
||||
TempBuffer, TempPalette = BmpImageDecoder(File, Buffer, PaletteIndex, FileObj.TransParent)
|
||||
if len(TempPalette) > 1:
|
||||
PaletteIndex += 1
|
||||
NewPalette = pack('H', len(TempPalette))
|
||||
NewPalette += TempPalette
|
||||
PaletteBuffer += NewPalette
|
||||
PaletteStr = WriteLine(PaletteStr, '// %s: %s: %s' % (DecToHexStr(PaletteIndex - 1, 4), ID, DecToHexStr(PaletteIndex - 1, 4)))
|
||||
TempPaletteList = AscToHexList(NewPalette)
|
||||
PaletteStr = WriteLine(PaletteStr, CreateArrayItem(TempPaletteList, 16) + '\n')
|
||||
ImageBuffer += TempBuffer
|
||||
BufferStr = WriteLine(BufferStr, '// %s: %s: %s' % (DecToHexStr(Index, 4), ID, DecToHexStr(Index, 4)))
|
||||
TempBufferList = AscToHexList(DuplicateBlock)
|
||||
TempBufferList = AscToHexList(TempBuffer)
|
||||
BufferStr = WriteLine(BufferStr, CreateArrayItem(TempBufferList, 16) + '\n')
|
||||
|
||||
StringH.Append(Line)
|
||||
Index += 1
|
||||
continue
|
||||
|
||||
TmpFile = open(File.Path, 'rb')
|
||||
Buffer = TmpFile.read()
|
||||
TmpFile.close()
|
||||
if File.Ext.upper() == '.PNG':
|
||||
TempBuffer = pack('B', EFI_HII_IIBT_IMAGE_PNG)
|
||||
TempBuffer += pack('I', len(Buffer))
|
||||
TempBuffer += Buffer
|
||||
elif File.Ext.upper() == '.JPG':
|
||||
ImageType, = struct.unpack('4s', Buffer[6:10])
|
||||
if ImageType != b'JFIF':
|
||||
EdkLogger.error("build", FILE_TYPE_MISMATCH, "The file %s is not a standard JPG file." % File.Path)
|
||||
TempBuffer = pack('B', EFI_HII_IIBT_IMAGE_JPEG)
|
||||
TempBuffer += pack('I', len(Buffer))
|
||||
TempBuffer += Buffer
|
||||
elif File.Ext.upper() == '.BMP':
|
||||
TempBuffer, TempPalette = BmpImageDecoder(File, Buffer, PaletteIndex, FileObj.TransParent)
|
||||
if len(TempPalette) > 1:
|
||||
PaletteIndex += 1
|
||||
NewPalette = pack('H', len(TempPalette))
|
||||
NewPalette += TempPalette
|
||||
PaletteBuffer += NewPalette
|
||||
PaletteStr = WriteLine(PaletteStr, '// %s: %s: %s' % (DecToHexStr(PaletteIndex - 1, 4), ID, DecToHexStr(PaletteIndex - 1, 4)))
|
||||
TempPaletteList = AscToHexList(NewPalette)
|
||||
PaletteStr = WriteLine(PaletteStr, CreateArrayItem(TempPaletteList, 16) + '\n')
|
||||
ImageBuffer += TempBuffer
|
||||
BufferStr = WriteLine(BufferStr, '// %s: %s: %s' % (DecToHexStr(Index, 4), ID, DecToHexStr(Index, 4)))
|
||||
TempBufferList = AscToHexList(TempBuffer)
|
||||
BufferStr = WriteLine(BufferStr, CreateArrayItem(TempBufferList, 16) + '\n')
|
||||
|
||||
StringH.Append(Line)
|
||||
Index += 1
|
||||
except IOError:
|
||||
EdkLogger.error("build", FILE_NOT_FOUND, ExtraData=File.Path)
|
||||
|
||||
BufferStr = WriteLine(BufferStr, '// End of the Image Info')
|
||||
BufferStr = WriteLine(BufferStr, CreateArrayItem(DecToHexList(EFI_HII_IIBT_END, 2)) + '\n')
|
||||
|
@ -205,10 +205,12 @@ class BuildFile(object):
|
||||
def GetRemoveDirectoryCommand(self, DirList):
|
||||
return [self._RD_TEMPLATE_[self._FileType] % {'dir':Dir} for Dir in DirList]
|
||||
|
||||
def PlaceMacro(self, Path, MacroDefinitions={}):
|
||||
def PlaceMacro(self, Path, MacroDefinitions=None):
|
||||
if Path.startswith("$("):
|
||||
return Path
|
||||
else:
|
||||
if MacroDefinitions is None:
|
||||
MacroDefinitions = {}
|
||||
PathLength = len(Path)
|
||||
for MacroName in MacroDefinitions:
|
||||
MacroValue = MacroDefinitions[MacroName]
|
||||
@ -634,11 +636,13 @@ cleanlib:
|
||||
while not found and os.sep in package_rel_dir:
|
||||
index = package_rel_dir.index(os.sep)
|
||||
current_dir = mws.join(current_dir, package_rel_dir[:index])
|
||||
if os.path.exists(current_dir):
|
||||
try:
|
||||
for fl in os.listdir(current_dir):
|
||||
if fl.endswith('.dec'):
|
||||
found = True
|
||||
break
|
||||
except:
|
||||
EdkLogger.error('build', FILE_NOT_FOUND, "WORKSPACE does not exist.")
|
||||
package_rel_dir = package_rel_dir[index + 1:]
|
||||
|
||||
MakefileTemplateDict = {
|
||||
@ -1580,8 +1584,8 @@ class TopLevelMakefile(BuildFile):
|
||||
|
||||
if GlobalData.gCaseInsensitive:
|
||||
ExtraOption += " -c"
|
||||
if GlobalData.gEnableGenfdsMultiThread:
|
||||
ExtraOption += " --genfds-multi-thread"
|
||||
if not GlobalData.gEnableGenfdsMultiThread:
|
||||
ExtraOption += " --no-genfds-multi-thread"
|
||||
if GlobalData.gIgnoreSource:
|
||||
ExtraOption += " --ignore-sources"
|
||||
|
||||
@ -1692,22 +1696,25 @@ def GetDependencyList(AutoGenObject, FileCache, File, ForceList, SearchPathList)
|
||||
CurrentFileDependencyList = DepDb[F]
|
||||
else:
|
||||
try:
|
||||
Fd = open(F.Path, 'rb')
|
||||
FileContent = Fd.read()
|
||||
Fd.close()
|
||||
with open(F.Path, 'rb') as Fd:
|
||||
FileContent = Fd.read(1)
|
||||
Fd.seek(0)
|
||||
if not FileContent:
|
||||
continue
|
||||
if FileContent[0] == 0xff or FileContent[0] == 0xfe:
|
||||
FileContent2 = Fd.read()
|
||||
FileContent2 = FileContent2.decode('utf-16')
|
||||
IncludedFileList = gIncludePattern.findall(FileContent2)
|
||||
else:
|
||||
FileLines = Fd.readlines()
|
||||
FileContent2 = [line for line in FileLines if str(line).lstrip("#\t ")[:8] == "include "]
|
||||
simpleFileContent="".join(FileContent2)
|
||||
|
||||
IncludedFileList = gIncludePattern.findall(simpleFileContent)
|
||||
except BaseException as X:
|
||||
EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=F.Path + "\n\t" + str(X))
|
||||
if len(FileContent) == 0:
|
||||
if not FileContent:
|
||||
continue
|
||||
try:
|
||||
if FileContent[0] == 0xff or FileContent[0] == 0xfe:
|
||||
FileContent = FileContent.decode('utf-16')
|
||||
else:
|
||||
FileContent = FileContent.decode()
|
||||
except:
|
||||
# The file is not txt file. for example .mcb file
|
||||
continue
|
||||
IncludedFileList = gIncludePattern.findall(FileContent)
|
||||
|
||||
for Inc in IncludedFileList:
|
||||
Inc = Inc.strip()
|
||||
@ -1762,4 +1769,4 @@ def GetDependencyList(AutoGenObject, FileCache, File, ForceList, SearchPathList)
|
||||
|
||||
# This acts like the main() function for the script, unless it is 'import'ed into another script.
|
||||
if __name__ == '__main__':
|
||||
pass
|
||||
pass
|
||||
|
@ -2123,7 +2123,7 @@ class ModuleAutoGen(AutoGen):
|
||||
self.CreateCodeFile()
|
||||
if not (self.MetaFile.Path, self.Arch) in gDict or \
|
||||
not gDict[(self.MetaFile.Path, self.Arch)].CreateMakeFileDone:
|
||||
self.CreateMakeFile(GenFfsList=GlobalData.FfsCmd.get((self.MetaFile.File, self.Arch),[]))
|
||||
self.CreateMakeFile(GenFfsList=GlobalData.FfsCmd.get((self.MetaFile.Path, self.Arch),[]))
|
||||
|
||||
if not (self.MetaFile.Path, self.Arch) in gDict or \
|
||||
not gDict[(self.MetaFile.Path, self.Arch)].CreateCodeFileDone or \
|
||||
|
@ -236,6 +236,10 @@ class AutoGenInfo(object):
|
||||
#
|
||||
class WorkSpaceInfo(AutoGenInfo):
|
||||
def __init__(self,Workspace, MetaFile, Target, ToolChain, Arch):
|
||||
if not hasattr(self, "_Init"):
|
||||
self.do_init(Workspace, MetaFile, Target, ToolChain, Arch)
|
||||
self._Init = True
|
||||
def do_init(self,Workspace, MetaFile, Target, ToolChain, Arch):
|
||||
self._SrcTimeStamp = 0
|
||||
self.Db = BuildDB
|
||||
self.BuildDatabase = self.Db.BuildObject
|
||||
@ -244,10 +248,35 @@ class WorkSpaceInfo(AutoGenInfo):
|
||||
self.WorkspaceDir = Workspace
|
||||
self.ActivePlatform = MetaFile
|
||||
self.ArchList = Arch
|
||||
self.AutoGenObjectList = []
|
||||
@property
|
||||
def BuildDir(self):
|
||||
return self.AutoGenObjectList[0].BuildDir
|
||||
|
||||
@property
|
||||
def Name(self):
|
||||
return self.AutoGenObjectList[0].Platform.PlatformName
|
||||
|
||||
@property
|
||||
def FlashDefinition(self):
|
||||
return self.AutoGenObjectList[0].Platform.FlashDefinition
|
||||
@property
|
||||
def GenFdsCommandDict(self):
|
||||
FdsCommandDict = self.AutoGenObjectList[0].DataPipe.Get("FdsCommandDict")
|
||||
if FdsCommandDict:
|
||||
return FdsCommandDict
|
||||
return {}
|
||||
|
||||
@cached_property
|
||||
def FvDir(self):
|
||||
return os.path.join(self.BuildDir, TAB_FV_DIRECTORY)
|
||||
|
||||
class PlatformInfo(AutoGenInfo):
|
||||
def __init__(self, Workspace, MetaFile, Target, ToolChain, Arch,DataPipe):
|
||||
if not hasattr(self, "_Init"):
|
||||
self.do_init(Workspace, MetaFile, Target, ToolChain, Arch,DataPipe)
|
||||
self._Init = True
|
||||
def do_init(self,Workspace, MetaFile, Target, ToolChain, Arch,DataPipe):
|
||||
self.Wa = Workspace
|
||||
self.WorkspaceDir = self.Wa.WorkspaceDir
|
||||
self.MetaFile = MetaFile
|
||||
|
@ -188,7 +188,9 @@ class PlatformAutoGen(AutoGen):
|
||||
Ma.CreateMakeFile(CreateModuleMakeFile, FfsCommand[key])
|
||||
else:
|
||||
Ma.CreateMakeFile(CreateModuleMakeFile)
|
||||
self.CreateLibModuelDirs()
|
||||
|
||||
def CreateLibModuelDirs(self):
|
||||
# no need to create makefile for the platform more than once
|
||||
if self.IsMakeFileCreated:
|
||||
return
|
||||
@ -273,11 +275,11 @@ class PlatformAutoGen(AutoGen):
|
||||
PcdNvStoreDfBuffer = [item for item in self._DynamicPcdList if item.TokenCName == "PcdNvStoreDefaultValueBuffer" and item.TokenSpaceGuidCName == "gEfiMdeModulePkgTokenSpaceGuid"]
|
||||
|
||||
if PcdNvStoreDfBuffer:
|
||||
if os.path.exists(VpdMapFilePath):
|
||||
try:
|
||||
OrgVpdFile.Read(VpdMapFilePath)
|
||||
PcdItems = OrgVpdFile.GetOffset(PcdNvStoreDfBuffer[0])
|
||||
NvStoreOffset = list(PcdItems.values())[0].strip() if PcdItems else '0'
|
||||
else:
|
||||
except:
|
||||
EdkLogger.error("build", FILE_READ_FAILURE, "Can not find VPD map file %s to fix up VPD offset." % VpdMapFilePath)
|
||||
|
||||
NvStoreOffset = int(NvStoreOffset, 16) if NvStoreOffset.upper().startswith("0X") else int(NvStoreOffset)
|
||||
@ -439,7 +441,7 @@ class PlatformAutoGen(AutoGen):
|
||||
File=self.MetaFile,
|
||||
ExtraData="\n\tPCD(s) without MaxDatumSize:\n\t\t%s\n"
|
||||
% NoDatumTypePcdListString)
|
||||
self._NonDynamicPcdList = self._NonDynaPcdList_
|
||||
self._NonDynamicPcdList = sorted(self._NonDynaPcdList_)
|
||||
self._DynamicPcdList = self._DynaPcdList_
|
||||
|
||||
def SortDynamicPcd(self):
|
||||
@ -663,7 +665,7 @@ class PlatformAutoGen(AutoGen):
|
||||
# Process VPD map file generated by third party BPDG tool
|
||||
if NeedProcessVpdMapFile:
|
||||
VpdMapFilePath = os.path.join(self.BuildDir, TAB_FV_DIRECTORY, "%s.map" % self.Platform.VpdToolGuid)
|
||||
if os.path.exists(VpdMapFilePath):
|
||||
try:
|
||||
VpdFile.Read(VpdMapFilePath)
|
||||
|
||||
# Fixup TAB_STAR offset
|
||||
@ -677,7 +679,7 @@ class PlatformAutoGen(AutoGen):
|
||||
for item in vpdinfo:
|
||||
if item[2] == pcdvalue:
|
||||
sku.VpdOffset = item[1]
|
||||
else:
|
||||
except:
|
||||
EdkLogger.error("build", FILE_READ_FAILURE, "Can not find VPD map file %s to fix up VPD offset." % VpdMapFilePath)
|
||||
|
||||
# Delete the DynamicPcdList At the last time enter into this function
|
||||
@ -702,6 +704,7 @@ class PlatformAutoGen(AutoGen):
|
||||
self._DynamicPcdList.extend(list(UnicodePcdArray))
|
||||
self._DynamicPcdList.extend(list(HiiPcdArray))
|
||||
self._DynamicPcdList.extend(list(OtherPcdArray))
|
||||
self._DynamicPcdList.sort()
|
||||
allskuset = [(SkuName, Sku.SkuId) for pcd in self._DynamicPcdList for (SkuName, Sku) in pcd.SkuInfoList.items()]
|
||||
for pcd in self._DynamicPcdList:
|
||||
if len(pcd.SkuInfoList) == 1:
|
||||
|
@ -371,13 +371,12 @@ class UniFileClassObject(object):
|
||||
# Pre-process before parse .uni file
|
||||
#
|
||||
def PreProcess(self, File):
|
||||
if not os.path.exists(File.Path) or not os.path.isfile(File.Path):
|
||||
EdkLogger.error("Unicode File Parser", FILE_NOT_FOUND, ExtraData=File.Path)
|
||||
|
||||
try:
|
||||
FileIn = UniFileClassObject.OpenUniFile(LongFilePath(File.Path))
|
||||
except UnicodeError as X:
|
||||
EdkLogger.error("build", FILE_READ_FAILURE, "File read failure: %s" % str(X), ExtraData=File.Path);
|
||||
except OSError:
|
||||
EdkLogger.error("Unicode File Parser", FILE_NOT_FOUND, ExtraData=File.Path)
|
||||
except:
|
||||
EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=File.Path);
|
||||
|
||||
|
@ -128,7 +128,6 @@ class WorkspaceAutoGen(AutoGen):
|
||||
self.CreateBuildOptionsFile()
|
||||
self.CreatePcdTokenNumberFile()
|
||||
self.CreateModuleHashInfo()
|
||||
GlobalData.gAutoGenPhase = False
|
||||
|
||||
#
|
||||
# Merge Arch
|
||||
@ -834,8 +833,7 @@ class WorkspaceAutoGen(AutoGen):
|
||||
elif LogLevel == EdkLogger.QUIET:
|
||||
FdsCommandDict["quiet"] = True
|
||||
|
||||
if GlobalData.gEnableGenfdsMultiThread:
|
||||
FdsCommandDict["GenfdsMultiThread"] = True
|
||||
FdsCommandDict["GenfdsMultiThread"] = GlobalData.gEnableGenfdsMultiThread
|
||||
if GlobalData.gIgnoreSource:
|
||||
FdsCommandDict["IgnoreSources"] = True
|
||||
|
||||
|
@ -106,7 +106,7 @@ gBinCacheSource = None
|
||||
gPlatformHash = None
|
||||
gPackageHash = {}
|
||||
gModuleHash = {}
|
||||
gEnableGenfdsMultiThread = False
|
||||
gEnableGenfdsMultiThread = True
|
||||
gSikpAutoGenCache = set()
|
||||
|
||||
# Dictionary for tracking Module build status as success or failure
|
||||
@ -129,4 +129,4 @@ file_lock = None
|
||||
# Common dictionary to share platform libraries' constant Pcd
|
||||
libConstPcd = None
|
||||
# Common dictionary to share platform libraries' reference info
|
||||
Refes = None
|
||||
Refes = None
|
||||
|
@ -492,13 +492,9 @@ def SaveFileOnChange(File, Content, IsBinaryFile=True, FileLock=None):
|
||||
|
||||
|
||||
if GlobalData.gIsWindows and not os.path.exists(File):
|
||||
# write temp file, then rename the temp file to the real file
|
||||
# to make sure the file be immediate saved to disk
|
||||
with tempfile.NamedTemporaryFile(OpenMode, dir=os.path.dirname(File), delete=False) as tf:
|
||||
tf.write(Content)
|
||||
tempname = tf.name
|
||||
try:
|
||||
os.rename(tempname, File)
|
||||
with open(File, OpenMode) as tf:
|
||||
tf.write(Content)
|
||||
except IOError as X:
|
||||
if GlobalData.gBinCacheSource:
|
||||
EdkLogger.quiet("[cache error]:fails to save file with error: %s" % (X))
|
||||
@ -540,7 +536,8 @@ def CopyFileOnChange(SrcFile, Dst, FileLock=None):
|
||||
SrcFile = LongFilePath(SrcFile)
|
||||
Dst = LongFilePath(Dst)
|
||||
|
||||
if not os.path.exists(SrcFile):
|
||||
if os.path.isdir(SrcFile):
|
||||
EdkLogger.error(None, FILE_COPY_FAILURE, ExtraData='CopyFileOnChange SrcFile is a dir, not a file: %s' % SrcFile)
|
||||
return False
|
||||
|
||||
if os.path.isdir(Dst):
|
||||
@ -566,21 +563,8 @@ def CopyFileOnChange(SrcFile, Dst, FileLock=None):
|
||||
if FileLock:
|
||||
FileLock.acquire()
|
||||
|
||||
# os.replace and os.rename are the atomic operations in python 3 and 2.
|
||||
# we use these two atomic operations to ensure the file copy is atomic:
|
||||
# copy the src to a temp file in the dst same folder firstly, then
|
||||
# replace or rename the temp file to the destination file.
|
||||
with tempfile.NamedTemporaryFile(dir=DirName, delete=False) as tf:
|
||||
CopyLong(SrcFile, tf.name)
|
||||
tempname = tf.name
|
||||
try:
|
||||
if hasattr(os, 'replace'):
|
||||
os.replace(tempname, DstFile)
|
||||
else:
|
||||
# os.rename reqire to remove the dst on Windows, otherwise OSError will be raised.
|
||||
if GlobalData.gIsWindows and os.path.exists(DstFile):
|
||||
os.remove(DstFile)
|
||||
os.rename(tempname, DstFile)
|
||||
CopyLong(SrcFile, DstFile)
|
||||
except IOError as X:
|
||||
if GlobalData.gBinCacheSource:
|
||||
EdkLogger.quiet("[cache error]:fails to copy file with error: %s" % (X))
|
||||
|
@ -342,7 +342,9 @@ class RangeExpression(BaseExpression):
|
||||
raise BadExpression(ERR_STRING_EXPR % Operator)
|
||||
|
||||
|
||||
def __init__(self, Expression, PcdDataType, SymbolTable = {}):
|
||||
def __init__(self, Expression, PcdDataType, SymbolTable = None):
|
||||
if SymbolTable is None:
|
||||
SymbolTable = {}
|
||||
super(RangeExpression, self).__init__(self, Expression, PcdDataType, SymbolTable)
|
||||
self._NoProcess = False
|
||||
if not isinstance(Expression, type('')):
|
||||
|
@ -243,8 +243,10 @@ def SplitModuleType(Key):
|
||||
#
|
||||
# @retval NewList A new string list whose macros are replaced
|
||||
#
|
||||
def ReplaceMacros(StringList, MacroDefinitions={}, SelfReplacement=False):
|
||||
def ReplaceMacros(StringList, MacroDefinitions=None, SelfReplacement=False):
|
||||
NewList = []
|
||||
if MacroDefinitions is None:
|
||||
MacroDefinitions = {}
|
||||
for String in StringList:
|
||||
if isinstance(String, type('')):
|
||||
NewList.append(ReplaceMacro(String, MacroDefinitions, SelfReplacement))
|
||||
@ -264,8 +266,10 @@ def ReplaceMacros(StringList, MacroDefinitions={}, SelfReplacement=False):
|
||||
#
|
||||
# @retval string The string whose macros are replaced
|
||||
#
|
||||
def ReplaceMacro(String, MacroDefinitions={}, SelfReplacement=False, RaiseError=False):
|
||||
def ReplaceMacro(String, MacroDefinitions=None, SelfReplacement=False, RaiseError=False):
|
||||
LastString = String
|
||||
if MacroDefinitions is None:
|
||||
MacroDefinitions = {}
|
||||
while String and MacroDefinitions:
|
||||
MacroUsed = GlobalData.gMacroRefPattern.findall(String)
|
||||
# no macro found in String, stop replacing
|
||||
@ -298,7 +302,7 @@ def ReplaceMacro(String, MacroDefinitions={}, SelfReplacement=False, RaiseError=
|
||||
#
|
||||
# @retval Path Formatted path
|
||||
#
|
||||
def NormPath(Path, Defines={}):
|
||||
def NormPath(Path, Defines=None):
|
||||
IsRelativePath = False
|
||||
if Path:
|
||||
if Path[0] == '.':
|
||||
|
@ -84,7 +84,8 @@ def MyOptionParser():
|
||||
Parser.add_option("--hash", action="store_true", dest="UseHashCache", default=False, help="Enable hash-based caching during build process.")
|
||||
Parser.add_option("--binary-destination", action="store", type="string", dest="BinCacheDest", help="Generate a cache of binary files in the specified directory.")
|
||||
Parser.add_option("--binary-source", action="store", type="string", dest="BinCacheSource", help="Consume a cache of binary files from the specified directory.")
|
||||
Parser.add_option("--genfds-multi-thread", action="store_true", dest="GenfdsMultiThread", default=False, help="Enable GenFds multi thread to generate ffs file.")
|
||||
Parser.add_option("--genfds-multi-thread", action="store_true", dest="GenfdsMultiThread", default=True, help="Enable GenFds multi thread to generate ffs file.")
|
||||
Parser.add_option("--no-genfds-multi-thread", action="store_true", dest="NoGenfdsMultiThread", default=False, help="Disable GenFds multi thread to generate ffs file.")
|
||||
Parser.add_option("--disable-include-path-check", action="store_true", dest="DisableIncludePathCheck", default=False, help="Disable the include path check for outside of package.")
|
||||
(Opt, Args) = Parser.parse_args()
|
||||
return (Opt, Args)
|
||||
|
@ -441,7 +441,7 @@ class Check(object):
|
||||
self.DeclCheckUnionType()
|
||||
|
||||
|
||||
# Check whether no use of int, unsigned, char, void, static, long in any .c, .h or .asl files.
|
||||
# Check whether no use of int, unsigned, char, void, long in any .c, .h or .asl files.
|
||||
def DeclCheckNoUseCType(self):
|
||||
if EccGlobalData.gConfig.DeclarationDataTypeCheckNoUseCType == '1' or EccGlobalData.gConfig.DeclarationDataTypeCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
|
||||
EdkLogger.quiet("Checking Declaration No use C type ...")
|
||||
|
@ -256,7 +256,7 @@ class Configuration(object):
|
||||
## Declarations and Data Types Checking
|
||||
self.DeclarationDataTypeCheckAll = 0
|
||||
|
||||
# Check whether no use of int, unsigned, char, void, static, long in any .c, .h or .asl files.
|
||||
# Check whether no use of int, unsigned, char, void, long in any .c, .h or .asl files.
|
||||
self.DeclarationDataTypeCheckNoUseCType = 1
|
||||
# Check whether the modifiers IN, OUT, OPTIONAL, and UNALIGNED are used only to qualify arguments to a function and should not appear in a data type declaration
|
||||
self.DeclarationDataTypeCheckInOutModifier = 1
|
||||
|
@ -149,7 +149,7 @@ gEccErrorMessage = {
|
||||
ERROR_INCLUDE_FILE_CHECK_NAME : "No permission for the include file with same names",
|
||||
|
||||
ERROR_DECLARATION_DATA_TYPE_CHECK_ALL : "",
|
||||
ERROR_DECLARATION_DATA_TYPE_CHECK_NO_USE_C_TYPE : "There should be no use of int, unsigned, char, void, static, long in any .c, .h or .asl files",
|
||||
ERROR_DECLARATION_DATA_TYPE_CHECK_NO_USE_C_TYPE : "There should be no use of int, unsigned, char, void, long in any .c, .h or .asl files",
|
||||
ERROR_DECLARATION_DATA_TYPE_CHECK_IN_OUT_MODIFIER : """The modifiers IN, OUT, OPTIONAL, and UNALIGNED should be used only to qualify arguments to a function and should not appear in a data type declaration""",
|
||||
ERROR_DECLARATION_DATA_TYPE_CHECK_EFI_API_MODIFIER : "The EFIAPI modifier should be used at the entry of drivers, events, and member functions of protocols",
|
||||
ERROR_DECLARATION_DATA_TYPE_CHECK_ENUMERATED_TYPE : "Enumerated Type should have a 'typedef' and the name must be in capital letters",
|
||||
|
@ -1859,7 +1859,7 @@ def CheckDeclNoUseCType(FullFileName):
|
||||
where Model = %d
|
||||
""" % (FileTable, DataClass.MODEL_IDENTIFIER_VARIABLE)
|
||||
ResultSet = Db.TblFile.Exec(SqlStatement)
|
||||
CTypeTuple = ('int', 'unsigned', 'char', 'void', 'static', 'long')
|
||||
CTypeTuple = ('int', 'unsigned', 'char', 'void', 'long')
|
||||
for Result in ResultSet:
|
||||
for Type in CTypeTuple:
|
||||
if PatternInModifier(Result[0], Type):
|
||||
@ -2388,7 +2388,7 @@ def CheckFileHeaderDoxygenComments(FullFileName):
|
||||
PrintErrorMsg(ERROR_HEADER_CHECK_FILE, 'File header comment content should start with two spaces at each line', FileTable, ID)
|
||||
|
||||
CommentLine = CommentLine.strip()
|
||||
if CommentLine.startswith('Copyright'):
|
||||
if CommentLine.startswith('Copyright') or ('Copyright' in CommentLine and CommentLine.lower().startswith('(c)')):
|
||||
NoCopyrightFlag = False
|
||||
if CommentLine.find('All rights reserved') == -1:
|
||||
for Copyright in EccGlobalData.gConfig.Copyright:
|
||||
|
@ -46,7 +46,9 @@ class AprioriSection (object):
|
||||
# @param Dict dictionary contains macro and its value
|
||||
# @retval string Generated file name
|
||||
#
|
||||
def GenFfs (self, FvName, Dict = {}, IsMakefile = False):
|
||||
def GenFfs (self, FvName, Dict = None, IsMakefile = False):
|
||||
if Dict is None:
|
||||
Dict = {}
|
||||
Buffer = BytesIO()
|
||||
if self.AprioriType == "PEI":
|
||||
AprioriFileGuid = PEI_APRIORI_GUID
|
||||
|
@ -49,7 +49,7 @@ class CompressSection (CompressSectionClassObject) :
|
||||
# @param Dict dictionary contains macro and its value
|
||||
# @retval tuple (Generated file name, section alignment)
|
||||
#
|
||||
def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}, IsMakefile = False):
|
||||
def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = None, IsMakefile = False):
|
||||
|
||||
if FfsInf is not None:
|
||||
self.CompType = FfsInf.__ExtendMacro__(self.CompType)
|
||||
@ -59,6 +59,8 @@ class CompressSection (CompressSectionClassObject) :
|
||||
SectAlign = []
|
||||
Index = 0
|
||||
MaxAlign = None
|
||||
if Dict is None:
|
||||
Dict = {}
|
||||
for Sect in self.SectionList:
|
||||
Index = Index + 1
|
||||
SecIndex = '%s.%d' %(SecNum, Index)
|
||||
|
@ -44,10 +44,12 @@ class DataSection (DataSectionClassObject):
|
||||
# @param Dict dictionary contains macro and its value
|
||||
# @retval tuple (Generated file name list, section alignment)
|
||||
#
|
||||
def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, FfsFile = None, Dict = {}, IsMakefile = False):
|
||||
def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, FfsFile = None, Dict = None, IsMakefile = False):
|
||||
#
|
||||
# Prepare the parameter of GenSection
|
||||
#
|
||||
if Dict is None:
|
||||
Dict = {}
|
||||
if FfsFile is not None:
|
||||
self.SectFileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.SectFileName)
|
||||
self.SectFileName = GenFdsGlobalVariable.MacroExtend(self.SectFileName, Dict, FfsFile.CurrentArch)
|
||||
|
@ -49,7 +49,7 @@ class EfiSection (EfiSectionClassObject):
|
||||
# @param Dict dictionary contains macro and its value
|
||||
# @retval tuple (Generated file name list, section alignment)
|
||||
#
|
||||
def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}, IsMakefile = False) :
|
||||
def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = None, IsMakefile = False) :
|
||||
|
||||
if self.FileName is not None and self.FileName.startswith('PCD('):
|
||||
self.FileName = GenFdsGlobalVariable.GetPcdValue(self.FileName)
|
||||
@ -76,6 +76,8 @@ class EfiSection (EfiSectionClassObject):
|
||||
|
||||
"""If the file name was pointed out, add it in FileList"""
|
||||
FileList = []
|
||||
if Dict is None:
|
||||
Dict = {}
|
||||
if Filename is not None:
|
||||
Filename = GenFdsGlobalVariable.MacroExtend(Filename, Dict)
|
||||
# check if the path is absolute or relative
|
||||
|
@ -48,7 +48,7 @@ class FileStatement (FileStatementClassObject):
|
||||
# @param FvParentAddr Parent Fv base address
|
||||
# @retval string Generated FFS file name
|
||||
#
|
||||
def GenFfs(self, Dict = {}, FvChildAddr=[], FvParentAddr=None, IsMakefile=False, FvName=None):
|
||||
def GenFfs(self, Dict = None, FvChildAddr=[], FvParentAddr=None, IsMakefile=False, FvName=None):
|
||||
|
||||
if self.NameGuid and self.NameGuid.startswith('PCD('):
|
||||
PcdValue = GenFdsGlobalVariable.GetPcdValue(self.NameGuid)
|
||||
@ -70,6 +70,9 @@ class FileStatement (FileStatementClassObject):
|
||||
if not os.path.exists(OutputDir):
|
||||
os.makedirs(OutputDir)
|
||||
|
||||
if Dict is None:
|
||||
Dict = {}
|
||||
|
||||
Dict.update(self.DefineVarDict)
|
||||
SectionAlignments = None
|
||||
if self.FvName:
|
||||
|
@ -437,11 +437,12 @@ class FfsInfStatement(FfsInfStatementClassObject):
|
||||
# @param FvParentAddr Parent Fv base address
|
||||
# @retval string Generated FFS file name
|
||||
#
|
||||
def GenFfs(self, Dict = {}, FvChildAddr = [], FvParentAddr=None, IsMakefile=False, FvName=None):
|
||||
def GenFfs(self, Dict = None, FvChildAddr = [], FvParentAddr=None, IsMakefile=False, FvName=None):
|
||||
#
|
||||
# Parse Inf file get Module related information
|
||||
#
|
||||
|
||||
if Dict is None:
|
||||
Dict = {}
|
||||
self.__InfParse__(Dict, IsGenFfs=True)
|
||||
Arch = self.GetCurrentArch()
|
||||
SrcFile = mws.join( GenFdsGlobalVariable.WorkSpaceDir, self.InfFileName);
|
||||
@ -502,7 +503,10 @@ class FfsInfStatement(FfsInfStatementClassObject):
|
||||
if self.IsBinaryModule:
|
||||
IsMakefile = False
|
||||
if IsMakefile:
|
||||
MakefilePath = self.InfFileName, Arch
|
||||
PathClassObj = PathClass(self.InfFileName, GenFdsGlobalVariable.WorkSpaceDir)
|
||||
if self.OverrideGuid:
|
||||
PathClassObj = ProcessDuplicatedInf(PathClassObj, self.OverrideGuid, GenFdsGlobalVariable.WorkSpaceDir)
|
||||
MakefilePath = PathClassObj.Path, Arch
|
||||
if isinstance (Rule, RuleSimpleFile.RuleSimpleFile):
|
||||
SectionOutputList = self.__GenSimpleFileSection__(Rule, IsMakefile=IsMakefile)
|
||||
FfsOutput = self.__GenSimpleFileFfs__(Rule, SectionOutputList, MakefilePath=MakefilePath)
|
||||
|
@ -71,9 +71,11 @@ class FV (object):
|
||||
# @param MacroDict macro value pair
|
||||
# @retval string Generated FV file path
|
||||
#
|
||||
def AddToBuffer (self, Buffer, BaseAddress=None, BlockSize= None, BlockNum=None, ErasePloarity='1', MacroDict = {}, Flag=False):
|
||||
def AddToBuffer (self, Buffer, BaseAddress=None, BlockSize= None, BlockNum=None, ErasePloarity='1', MacroDict = None, Flag=False):
|
||||
if BaseAddress is None and self.UiFvName.upper() + 'fv' in GenFdsGlobalVariable.ImageBinDict:
|
||||
return GenFdsGlobalVariable.ImageBinDict[self.UiFvName.upper() + 'fv']
|
||||
if MacroDict is None:
|
||||
MacroDict = {}
|
||||
|
||||
#
|
||||
# Check whether FV in Capsule is in FD flash region.
|
||||
|
@ -47,9 +47,11 @@ class FvImageSection(FvImageSectionClassObject):
|
||||
# @param Dict dictionary contains macro and its value
|
||||
# @retval tuple (Generated file name, section alignment)
|
||||
#
|
||||
def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}, IsMakefile = False):
|
||||
def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = None, IsMakefile = False):
|
||||
|
||||
OutputFileList = []
|
||||
if Dict is None:
|
||||
Dict = {}
|
||||
if self.FvFileType is not None:
|
||||
FileList, IsSect = Section.Section.GetFileList(FfsInf, self.FvFileType, self.FvFileExtension)
|
||||
if IsSect :
|
||||
|
@ -93,7 +93,7 @@ def resetFdsGlobalVariable():
|
||||
GenFdsGlobalVariable.SecCmdList = []
|
||||
GenFdsGlobalVariable.CopyList = []
|
||||
GenFdsGlobalVariable.ModuleFile = ''
|
||||
GenFdsGlobalVariable.EnableGenfdsMultiThread = False
|
||||
GenFdsGlobalVariable.EnableGenfdsMultiThread = True
|
||||
|
||||
GenFdsGlobalVariable.LargeFileInFvFlags = []
|
||||
GenFdsGlobalVariable.EFI_FIRMWARE_FILE_SYSTEM3_GUID = '5473C07A-3DCB-4dca-BD6F-1E9689E7349A'
|
||||
@ -140,6 +140,8 @@ def GenFdsApi(FdsCommandDict, WorkSpaceDataBase=None):
|
||||
GenFdsGlobalVariable.VerboseLogger("Using Workspace:" + Workspace)
|
||||
if FdsCommandDict.get("GenfdsMultiThread"):
|
||||
GenFdsGlobalVariable.EnableGenfdsMultiThread = True
|
||||
else:
|
||||
GenFdsGlobalVariable.EnableGenfdsMultiThread = False
|
||||
os.chdir(GenFdsGlobalVariable.WorkSpaceDir)
|
||||
|
||||
# set multiple workspace
|
||||
@ -402,7 +404,7 @@ def OptionsToCommandDict(Options):
|
||||
FdsCommandDict["quiet"] = Options.quiet
|
||||
FdsCommandDict["debug"] = Options.debug
|
||||
FdsCommandDict["Workspace"] = Options.Workspace
|
||||
FdsCommandDict["GenfdsMultiThread"] = Options.GenfdsMultiThread
|
||||
FdsCommandDict["GenfdsMultiThread"] = not Options.NoGenfdsMultiThread
|
||||
FdsCommandDict["fdf_file"] = [PathClass(Options.filename)] if Options.filename else []
|
||||
FdsCommandDict["build_target"] = Options.BuildTarget
|
||||
FdsCommandDict["toolchain_tag"] = Options.ToolChain
|
||||
@ -459,7 +461,8 @@ def myOptionParser():
|
||||
Parser.add_option("--conf", action="store", type="string", dest="ConfDirectory", help="Specify the customized Conf directory.")
|
||||
Parser.add_option("--ignore-sources", action="store_true", dest="IgnoreSources", default=False, help="Focus to a binary build and ignore all source files")
|
||||
Parser.add_option("--pcd", action="append", dest="OptionPcd", help="Set PCD value by command line. Format: \"PcdName=Value\" ")
|
||||
Parser.add_option("--genfds-multi-thread", action="store_true", dest="GenfdsMultiThread", default=False, help="Enable GenFds multi thread to generate ffs file.")
|
||||
Parser.add_option("--genfds-multi-thread", action="store_true", dest="GenfdsMultiThread", default=True, help="Enable GenFds multi thread to generate ffs file.")
|
||||
Parser.add_option("--no-genfds-multi-thread", action="store_true", dest="NoGenfdsMultiThread", default=False, help="Disable GenFds multi thread to generate ffs file.")
|
||||
|
||||
Options, _ = Parser.parse_args()
|
||||
return Options
|
||||
|
@ -69,7 +69,7 @@ class GenFdsGlobalVariable:
|
||||
SecCmdList = []
|
||||
CopyList = []
|
||||
ModuleFile = ''
|
||||
EnableGenfdsMultiThread = False
|
||||
EnableGenfdsMultiThread = True
|
||||
|
||||
#
|
||||
# The list whose element are flags to indicate if large FFS or SECTION files exist in FV.
|
||||
@ -489,7 +489,7 @@ class GenFdsGlobalVariable:
|
||||
if GlobalData.gGlobalDefines.get("FAMILY") == "MSFT":
|
||||
Cmd = ['if', 'exist', Input[0]] + Cmd
|
||||
else:
|
||||
Cmd = ['test', '-e', Input[0], "&&"] + Cmd
|
||||
Cmd = ['-test', '-e', Input[0], "&&"] + Cmd
|
||||
if ' '.join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList:
|
||||
GenFdsGlobalVariable.SecCmdList.append(' '.join(Cmd).strip())
|
||||
elif GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [CommandFile]):
|
||||
@ -742,7 +742,7 @@ class GenFdsGlobalVariable:
|
||||
# @param MacroDict Dictionary that contains macro value pair
|
||||
#
|
||||
@staticmethod
|
||||
def MacroExtend (Str, MacroDict={}, Arch=DataType.TAB_COMMON):
|
||||
def MacroExtend (Str, MacroDict=None, Arch=DataType.TAB_COMMON):
|
||||
if Str is None:
|
||||
return None
|
||||
|
||||
|
@ -50,7 +50,7 @@ class GuidSection(GuidSectionClassObject) :
|
||||
# @param Dict dictionary contains macro and its value
|
||||
# @retval tuple (Generated file name, section alignment)
|
||||
#
|
||||
def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf=None, Dict={}, IsMakefile=False):
|
||||
def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf=None, Dict=None, IsMakefile=False):
|
||||
#
|
||||
# Generate all section
|
||||
#
|
||||
@ -66,6 +66,8 @@ class GuidSection(GuidSectionClassObject) :
|
||||
SectAlign = []
|
||||
Index = 0
|
||||
MaxAlign = None
|
||||
if Dict is None:
|
||||
Dict = {}
|
||||
if self.FvAddr != []:
|
||||
FvAddrIsSet = True
|
||||
else:
|
||||
|
@ -34,7 +34,10 @@ class OptRomFileStatement:
|
||||
# @param Dict dictionary contains macro and value pair
|
||||
# @retval string Generated FFS file name
|
||||
#
|
||||
def GenFfs(self, Dict = {}, IsMakefile=False):
|
||||
def GenFfs(self, Dict = None, IsMakefile=False):
|
||||
|
||||
if Dict is None:
|
||||
Dict = {}
|
||||
|
||||
if self.FileName is not None:
|
||||
self.FileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FileName)
|
||||
|
@ -73,8 +73,10 @@ class Region(object):
|
||||
# @retval string Generated FV file path
|
||||
#
|
||||
|
||||
def AddToBuffer(self, Buffer, BaseAddress, BlockSizeList, ErasePolarity, ImageBinDict, MacroDict={}, Flag=False):
|
||||
def AddToBuffer(self, Buffer, BaseAddress, BlockSizeList, ErasePolarity, ImageBinDict, MacroDict=None, Flag=False):
|
||||
Size = self.Size
|
||||
if MacroDict is None:
|
||||
MacroDict = {}
|
||||
if not Flag:
|
||||
GenFdsGlobalVariable.InfLogger('\nGenerate Region at Offset 0x%X' % self.Offset)
|
||||
GenFdsGlobalVariable.InfLogger(" Region Size = 0x%X" % Size)
|
||||
|
@ -92,7 +92,7 @@ class Section (SectionClassObject):
|
||||
# @param FfsInf FfsInfStatement object that contains this section data
|
||||
# @param Dict dictionary contains macro and its value
|
||||
#
|
||||
def GenSection(self, OutputPath, GuidName, SecNum, keyStringList, FfsInf = None, Dict = {}):
|
||||
def GenSection(self, OutputPath, GuidName, SecNum, keyStringList, FfsInf = None, Dict = None):
|
||||
pass
|
||||
|
||||
## GetFileList() method
|
||||
|
@ -44,7 +44,7 @@ class UiSection (UiSectionClassObject):
|
||||
# @param Dict dictionary contains macro and its value
|
||||
# @retval tuple (Generated file name, section alignment)
|
||||
#
|
||||
def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf=None, Dict={}, IsMakefile = False):
|
||||
def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf=None, Dict=None, IsMakefile = False):
|
||||
#
|
||||
# Prepare the parameter of GenSection
|
||||
#
|
||||
@ -58,6 +58,8 @@ class UiSection (UiSectionClassObject):
|
||||
if self.StringData is not None :
|
||||
NameString = self.StringData
|
||||
elif self.FileName is not None:
|
||||
if Dict is None:
|
||||
Dict = {}
|
||||
FileNameStr = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FileName)
|
||||
FileNameStr = GenFdsGlobalVariable.MacroExtend(FileNameStr, Dict)
|
||||
FileObj = open(FileNameStr, 'r')
|
||||
|
@ -42,7 +42,7 @@ class VerSection (VerSectionClassObject):
|
||||
# @param Dict dictionary contains macro and its value
|
||||
# @retval tuple (Generated file name, section alignment)
|
||||
#
|
||||
def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf=None, Dict={}, IsMakefile = False):
|
||||
def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf=None, Dict=None, IsMakefile = False):
|
||||
#
|
||||
# Prepare the parameter of GenSection
|
||||
#
|
||||
@ -61,6 +61,8 @@ class VerSection (VerSectionClassObject):
|
||||
if self.StringData:
|
||||
StringData = self.StringData
|
||||
elif self.FileName:
|
||||
if Dict is None:
|
||||
Dict = {}
|
||||
FileNameStr = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FileName)
|
||||
FileNameStr = GenFdsGlobalVariable.MacroExtend(FileNameStr, Dict)
|
||||
FileObj = open(FileNameStr, 'r')
|
||||
|
@ -14,6 +14,7 @@ from Common.Misc import CopyDict,ArrayIndex
|
||||
import copy
|
||||
import Common.EdkLogger as EdkLogger
|
||||
from Common.BuildToolError import OPTION_VALUE_INVALID
|
||||
from Common.caching import cached_property
|
||||
StructPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_\[\]]*$')
|
||||
|
||||
## PcdClassObject
|
||||
@ -227,6 +228,15 @@ class PcdClassObject(object):
|
||||
def __hash__(self):
|
||||
return hash((self.TokenCName, self.TokenSpaceGuidCName))
|
||||
|
||||
@cached_property
|
||||
def _fullname(self):
|
||||
return ".".join((self.TokenSpaceGuidCName,self.TokenCName))
|
||||
|
||||
def __lt__(self,pcd):
|
||||
return self._fullname < pcd._fullname
|
||||
def __gt__(self,pcd):
|
||||
return self._fullname > pcd._fullname
|
||||
|
||||
def sharedcopy(self,new_pcd):
|
||||
new_pcd.TokenCName = self.TokenCName
|
||||
new_pcd.TokenSpaceGuidCName = self.TokenSpaceGuidCName
|
||||
|
@ -3014,7 +3014,7 @@ class DscBuildData(PlatformBuildClassObject):
|
||||
|
||||
|
||||
# Remove redundant PCD candidates, per the ARCH and SKU
|
||||
for PcdCName, TokenSpaceGuid, SkuName, DefaultStore, Dummy4 in PcdList:
|
||||
for index,(PcdCName, TokenSpaceGuid, SkuName, DefaultStore, Dummy4) in enumerate(PcdList):
|
||||
|
||||
Setting = PcdDict[self._Arch, SkuName, PcdCName, TokenSpaceGuid, DefaultStore]
|
||||
if Setting is None:
|
||||
@ -3083,7 +3083,7 @@ class DscBuildData(PlatformBuildClassObject):
|
||||
PcdClassObj.UserDefinedDefaultStoresFlag = True
|
||||
Pcds[PcdCName, TokenSpaceGuid] = PcdClassObj
|
||||
|
||||
Pcds[PcdCName, TokenSpaceGuid].CustomAttribute['DscPosition'] = int(Dummy4)
|
||||
Pcds[PcdCName, TokenSpaceGuid].CustomAttribute['DscPosition'] = index
|
||||
if SkuName not in Pcds[PcdCName, TokenSpaceGuid].DscRawValue:
|
||||
Pcds[PcdCName, TokenSpaceGuid].DscRawValue[SkuName] = {}
|
||||
Pcds[PcdCName, TokenSpaceGuid].DscRawValueInfo[SkuName] = {}
|
||||
|
@ -1419,10 +1419,19 @@ class PcdReport(object):
|
||||
FileWrite(File, '%*s' % (self.MaxLen + 4, SkuInfo.VpdOffset))
|
||||
VPDPcdItem = (Pcd.TokenSpaceGuidCName + '.' + PcdTokenCName, SkuIdName, SkuInfo.VpdOffset, Pcd.MaxDatumSize, SkuInfo.DefaultValue)
|
||||
if VPDPcdItem not in VPDPcdList:
|
||||
VPDPcdList.append(VPDPcdItem)
|
||||
PcdGuidList = self.UnusedPcds.get(Pcd.TokenSpaceGuidCName)
|
||||
if PcdGuidList:
|
||||
PcdList = PcdGuidList.get(Pcd.Type)
|
||||
if not PcdList:
|
||||
VPDPcdList.append(VPDPcdItem)
|
||||
for VpdPcd in PcdList:
|
||||
if PcdTokenCName == VpdPcd.TokenCName:
|
||||
break
|
||||
else:
|
||||
VPDPcdList.append(VPDPcdItem)
|
||||
if IsStructure:
|
||||
FiledOverrideFlag = False
|
||||
OverrideValues = Pcd.SkuOverrideValues[Sku]
|
||||
OverrideValues = Pcd.SkuOverrideValues.get(Sku)
|
||||
if OverrideValues:
|
||||
Keys = list(OverrideValues.keys())
|
||||
OverrideFieldStruct = self.OverrideFieldValue(Pcd, OverrideValues[Keys[0]])
|
||||
|
@ -54,6 +54,9 @@ import Common.GlobalData as GlobalData
|
||||
from GenFds.GenFds import GenFds, GenFdsApi
|
||||
import multiprocessing as mp
|
||||
from multiprocessing import Manager
|
||||
from AutoGen.DataPipe import MemoryDataPipe
|
||||
from AutoGen.ModuleAutoGenHelper import WorkSpaceInfo, PlatformInfo
|
||||
from GenFds.FdfParser import FdfParser
|
||||
|
||||
|
||||
## standard targets of build command
|
||||
@ -728,7 +731,7 @@ class Build():
|
||||
GlobalData.gUseHashCache = BuildOptions.UseHashCache
|
||||
GlobalData.gBinCacheDest = BuildOptions.BinCacheDest
|
||||
GlobalData.gBinCacheSource = BuildOptions.BinCacheSource
|
||||
GlobalData.gEnableGenfdsMultiThread = BuildOptions.GenfdsMultiThread
|
||||
GlobalData.gEnableGenfdsMultiThread = not BuildOptions.NoGenfdsMultiThread
|
||||
GlobalData.gDisableIncludePathCheck = BuildOptions.DisableIncludePathCheck
|
||||
|
||||
if GlobalData.gBinCacheDest and not GlobalData.gUseHashCache:
|
||||
@ -812,23 +815,21 @@ class Build():
|
||||
os.chdir(self.WorkspaceDir)
|
||||
GlobalData.gCacheIR = Manager().dict()
|
||||
self.log_q = log_q
|
||||
GlobalData.file_lock = mp.Lock()
|
||||
GlobalData.cache_lock = mp.Lock()
|
||||
def StartAutoGen(self,mqueue, DataPipe,SkipAutoGen,PcdMaList,share_data):
|
||||
try:
|
||||
if SkipAutoGen:
|
||||
return True,0
|
||||
feedback_q = mp.Queue()
|
||||
file_lock = mp.Lock()
|
||||
error_event = mp.Event()
|
||||
GlobalData.file_lock = file_lock
|
||||
cache_lock = mp.Lock()
|
||||
GlobalData.cache_lock = cache_lock
|
||||
FfsCmd = DataPipe.Get("FfsCommand")
|
||||
if FfsCmd is None:
|
||||
FfsCmd = {}
|
||||
GlobalData.FfsCmd = FfsCmd
|
||||
GlobalData.libConstPcd = DataPipe.Get("LibConstPcd")
|
||||
GlobalData.Refes = DataPipe.Get("REFS")
|
||||
auto_workers = [AutoGenWorkerInProcess(mqueue,DataPipe.dump_file,feedback_q,file_lock,cache_lock,share_data,self.log_q,error_event) for _ in range(self.ThreadNumber)]
|
||||
auto_workers = [AutoGenWorkerInProcess(mqueue,DataPipe.dump_file,feedback_q,GlobalData.file_lock,GlobalData.cache_lock,share_data,self.log_q,error_event) for _ in range(self.ThreadNumber)]
|
||||
self.AutoGenMgr = AutoGenManager(auto_workers,feedback_q,error_event)
|
||||
self.AutoGenMgr.start()
|
||||
for w in auto_workers:
|
||||
@ -839,10 +840,10 @@ class Build():
|
||||
PcdMa.GenModuleFilesHash(share_data)
|
||||
PcdMa.GenPreMakefileHash(share_data)
|
||||
if PcdMa.CanSkipbyPreMakefileCache(share_data):
|
||||
continue
|
||||
continue
|
||||
|
||||
PcdMa.CreateCodeFile(False)
|
||||
PcdMa.CreateMakeFile(False,GenFfsList = DataPipe.Get("FfsCommand").get((PcdMa.MetaFile.File, PcdMa.Arch),[]))
|
||||
PcdMa.CreateMakeFile(False,GenFfsList = DataPipe.Get("FfsCommand").get((PcdMa.MetaFile.Path, PcdMa.Arch),[]))
|
||||
|
||||
if GlobalData.gBinCacheSource and self.Target in [None, "", "all"]:
|
||||
PcdMa.GenMakeHeaderFilesHash(share_data)
|
||||
@ -1220,14 +1221,24 @@ class Build():
|
||||
mqueue.put(m)
|
||||
|
||||
AutoGenObject.DataPipe.DataContainer = {"CommandTarget": self.Target}
|
||||
AutoGenObject.DataPipe.DataContainer = {"Workspace_timestamp": AutoGenObject.Workspace._SrcTimeStamp}
|
||||
AutoGenObject.CreateLibModuelDirs()
|
||||
AutoGenObject.DataPipe.DataContainer = {"LibraryBuildDirectoryList":AutoGenObject.LibraryBuildDirectoryList}
|
||||
AutoGenObject.DataPipe.DataContainer = {"ModuleBuildDirectoryList":AutoGenObject.ModuleBuildDirectoryList}
|
||||
AutoGenObject.DataPipe.DataContainer = {"FdsCommandDict": AutoGenObject.Workspace.GenFdsCommandDict}
|
||||
self.Progress.Start("Generating makefile and code")
|
||||
data_pipe_file = os.path.join(AutoGenObject.BuildDir, "GlobalVar_%s_%s.bin" % (str(AutoGenObject.Guid),AutoGenObject.Arch))
|
||||
AutoGenObject.DataPipe.dump(data_pipe_file)
|
||||
autogen_rt,errorcode = self.StartAutoGen(mqueue, AutoGenObject.DataPipe, self.SkipAutoGen, PcdMaList, GlobalData.gCacheIR)
|
||||
AutoGenIdFile = os.path.join(GlobalData.gConfDirectory,".AutoGenIdFile.txt")
|
||||
with open(AutoGenIdFile,"w") as fw:
|
||||
fw.write("Arch=%s\n" % "|".join((AutoGenObject.Workspace.ArchList)))
|
||||
fw.write("BuildDir=%s\n" % AutoGenObject.Workspace.BuildDir)
|
||||
fw.write("PlatformGuid=%s\n" % str(AutoGenObject.Guid))
|
||||
self.Progress.Stop("done!")
|
||||
if not autogen_rt:
|
||||
self.AutoGenMgr.TerminateWorkers()
|
||||
self.AutoGenMgr.join(0.1)
|
||||
self.AutoGenMgr.join(1)
|
||||
raise FatalError(errorcode)
|
||||
AutoGenObject.CreateCodeFile(False)
|
||||
AutoGenObject.CreateMakeFile(False)
|
||||
@ -1780,6 +1791,7 @@ class Build():
|
||||
# Save MAP buffer into MAP file.
|
||||
#
|
||||
self._SaveMapFile (MapBuffer, Wa)
|
||||
self.CreateGuidedSectionToolsFile(Wa)
|
||||
|
||||
## Build active module for different build targets, different tool chains and different archs
|
||||
#
|
||||
@ -1848,15 +1860,18 @@ class Build():
|
||||
Ma = ModuleAutoGen(Wa, Module, BuildTarget, ToolChain, Arch, self.PlatformFile,Pa.DataPipe)
|
||||
if Ma is None:
|
||||
continue
|
||||
if Ma.PcdIsDriver:
|
||||
Ma.PlatformInfo = Pa
|
||||
Ma.Workspace = Wa
|
||||
MaList.append(Ma)
|
||||
|
||||
if GlobalData.gBinCacheSource and self.Target in [None, "", "all"]:
|
||||
Ma.GenModuleFilesHash(GlobalData.gCacheIR)
|
||||
Ma.GenPreMakefileHash(GlobalData.gCacheIR)
|
||||
if Ma.CanSkipbyPreMakefileCache(GlobalData.gCacheIR):
|
||||
self.HashSkipModules.append(Ma)
|
||||
EdkLogger.quiet("cache hit: %s[%s]" % (Ma.MetaFile.Path, Ma.Arch))
|
||||
continue
|
||||
self.HashSkipModules.append(Ma)
|
||||
EdkLogger.quiet("cache hit: %s[%s]" % (Ma.MetaFile.Path, Ma.Arch))
|
||||
continue
|
||||
|
||||
# Not to auto-gen for targets 'clean', 'cleanlib', 'cleanall', 'run', 'fds'
|
||||
if self.Target not in ['clean', 'cleanlib', 'cleanall', 'run', 'fds']:
|
||||
@ -1869,9 +1884,9 @@ class Build():
|
||||
return True
|
||||
if not self.SkipAutoGen or self.Target == 'genmake':
|
||||
self.Progress.Start("Generating makefile")
|
||||
if CmdListDict and self.Fdf and (Module.File, Arch) in CmdListDict:
|
||||
Ma.CreateMakeFile(True, CmdListDict[Module.File, Arch])
|
||||
del CmdListDict[Module.File, Arch]
|
||||
if CmdListDict and self.Fdf and (Module.Path, Arch) in CmdListDict:
|
||||
Ma.CreateMakeFile(True, CmdListDict[Module.Path, Arch])
|
||||
del CmdListDict[Module.Path, Arch]
|
||||
else:
|
||||
Ma.CreateMakeFile(True)
|
||||
self.Progress.Stop("done!")
|
||||
@ -1989,121 +2004,218 @@ class Build():
|
||||
tmpInf, tmpArch = GenFfsDict[Cmd]
|
||||
CmdSetDict[tmpInf, tmpArch].add(Cmd)
|
||||
return CmdSetDict
|
||||
def VerifyAutoGenFiles(self):
|
||||
AutoGenIdFile = os.path.join(GlobalData.gConfDirectory,".AutoGenIdFile.txt")
|
||||
try:
|
||||
with open(AutoGenIdFile) as fd:
|
||||
lines = fd.readlines()
|
||||
except:
|
||||
return None
|
||||
for line in lines:
|
||||
if "Arch" in line:
|
||||
ArchList = line.strip().split("=")[1].split("|")
|
||||
if "BuildDir" in line:
|
||||
BuildDir = line.split("=")[1].strip()
|
||||
if "PlatformGuid" in line:
|
||||
PlatformGuid = line.split("=")[1].strip()
|
||||
GlobalVarList = []
|
||||
for arch in ArchList:
|
||||
global_var = os.path.join(BuildDir, "GlobalVar_%s_%s.bin" % (str(PlatformGuid),arch))
|
||||
if not os.path.exists(global_var):
|
||||
return None
|
||||
GlobalVarList.append(global_var)
|
||||
for global_var in GlobalVarList:
|
||||
data_pipe = MemoryDataPipe()
|
||||
data_pipe.load(global_var)
|
||||
target = data_pipe.Get("P_Info").get("Target")
|
||||
toolchain = data_pipe.Get("P_Info").get("ToolChain")
|
||||
archlist = data_pipe.Get("P_Info").get("ArchList")
|
||||
Arch = data_pipe.Get("P_Info").get("Arch")
|
||||
active_p = data_pipe.Get("P_Info").get("ActivePlatform")
|
||||
workspacedir = data_pipe.Get("P_Info").get("WorkspaceDir")
|
||||
PackagesPath = os.getenv("PACKAGES_PATH")
|
||||
mws.setWs(workspacedir, PackagesPath)
|
||||
LibraryBuildDirectoryList = data_pipe.Get("LibraryBuildDirectoryList")
|
||||
ModuleBuildDirectoryList = data_pipe.Get("ModuleBuildDirectoryList")
|
||||
|
||||
for m_build_dir in LibraryBuildDirectoryList:
|
||||
if not os.path.exists(os.path.join(m_build_dir,GenMake.BuildFile._FILE_NAME_[GenMake.gMakeType])):
|
||||
return None
|
||||
for m_build_dir in ModuleBuildDirectoryList:
|
||||
if not os.path.exists(os.path.join(m_build_dir,GenMake.BuildFile._FILE_NAME_[GenMake.gMakeType])):
|
||||
return None
|
||||
Wa = WorkSpaceInfo(
|
||||
workspacedir,active_p,target,toolchain,archlist
|
||||
)
|
||||
Pa = PlatformInfo(Wa, active_p, target, toolchain, Arch,data_pipe)
|
||||
Wa.AutoGenObjectList.append(Pa)
|
||||
return Wa
|
||||
def SetupMakeSetting(self,Wa):
|
||||
BuildModules = []
|
||||
for Pa in Wa.AutoGenObjectList:
|
||||
for m in Pa._MbList:
|
||||
ma = ModuleAutoGen(Wa,m.MetaFile, Pa.BuildTarget, Wa.ToolChain, Pa.Arch, Pa.MetaFile,Pa.DataPipe)
|
||||
BuildModules.append(ma)
|
||||
fdf_file = Wa.FlashDefinition
|
||||
if fdf_file:
|
||||
Fdf = FdfParser(fdf_file.Path)
|
||||
Fdf.ParseFile()
|
||||
GlobalData.gFdfParser = Fdf
|
||||
if Fdf.CurrentFdName and Fdf.CurrentFdName in Fdf.Profile.FdDict:
|
||||
FdDict = Fdf.Profile.FdDict[Fdf.CurrentFdName]
|
||||
for FdRegion in FdDict.RegionList:
|
||||
if str(FdRegion.RegionType) is 'FILE' and self.Platform.VpdToolGuid in str(FdRegion.RegionDataList):
|
||||
if int(FdRegion.Offset) % 8 != 0:
|
||||
EdkLogger.error("build", FORMAT_INVALID, 'The VPD Base Address %s must be 8-byte aligned.' % (FdRegion.Offset))
|
||||
Wa.FdfProfile = Fdf.Profile
|
||||
self.Fdf = Fdf
|
||||
else:
|
||||
self.Fdf = None
|
||||
return BuildModules
|
||||
|
||||
## Build a platform in multi-thread mode
|
||||
#
|
||||
def PerformAutoGen(self,BuildTarget,ToolChain):
|
||||
WorkspaceAutoGenTime = time.time()
|
||||
Wa = WorkspaceAutoGen(
|
||||
self.WorkspaceDir,
|
||||
self.PlatformFile,
|
||||
BuildTarget,
|
||||
ToolChain,
|
||||
self.ArchList,
|
||||
self.BuildDatabase,
|
||||
self.TargetTxt,
|
||||
self.ToolDef,
|
||||
self.Fdf,
|
||||
self.FdList,
|
||||
self.FvList,
|
||||
self.CapList,
|
||||
self.SkuId,
|
||||
self.UniFlag,
|
||||
self.Progress
|
||||
)
|
||||
self.Fdf = Wa.FdfFile
|
||||
self.LoadFixAddress = Wa.Platform.LoadFixAddress
|
||||
self.BuildReport.AddPlatformReport(Wa)
|
||||
Wa.CreateMakeFile(False)
|
||||
|
||||
# Add ffs build to makefile
|
||||
CmdListDict = {}
|
||||
if GlobalData.gEnableGenfdsMultiThread and self.Fdf:
|
||||
CmdListDict = self._GenFfsCmd(Wa.ArchList)
|
||||
|
||||
# Add Platform and Package level hash in share_data for module hash calculation later
|
||||
if GlobalData.gBinCacheSource or GlobalData.gBinCacheDest:
|
||||
GlobalData.gCacheIR[('PlatformHash')] = GlobalData.gPlatformHash
|
||||
for PkgName in GlobalData.gPackageHash.keys():
|
||||
GlobalData.gCacheIR[(PkgName, 'PackageHash')] = GlobalData.gPackageHash[PkgName]
|
||||
|
||||
self.AutoGenTime += int(round((time.time() - WorkspaceAutoGenTime)))
|
||||
BuildModules = []
|
||||
TotalModules = []
|
||||
for Arch in Wa.ArchList:
|
||||
PcdMaList = []
|
||||
AutoGenStart = time.time()
|
||||
GlobalData.gGlobalDefines['ARCH'] = Arch
|
||||
Pa = PlatformAutoGen(Wa, self.PlatformFile, BuildTarget, ToolChain, Arch)
|
||||
if Pa is None:
|
||||
continue
|
||||
ModuleList = []
|
||||
for Inf in Pa.Platform.Modules:
|
||||
ModuleList.append(Inf)
|
||||
# Add the INF only list in FDF
|
||||
if GlobalData.gFdfParser is not None:
|
||||
for InfName in GlobalData.gFdfParser.Profile.InfList:
|
||||
Inf = PathClass(NormPath(InfName), self.WorkspaceDir, Arch)
|
||||
if Inf in Pa.Platform.Modules:
|
||||
continue
|
||||
ModuleList.append(Inf)
|
||||
Pa.DataPipe.DataContainer = {"FfsCommand":CmdListDict}
|
||||
Pa.DataPipe.DataContainer = {"Workspace_timestamp": Wa._SrcTimeStamp}
|
||||
Pa.DataPipe.DataContainer = {"CommandTarget": self.Target}
|
||||
Pa.CreateLibModuelDirs()
|
||||
Pa.DataPipe.DataContainer = {"LibraryBuildDirectoryList":Pa.LibraryBuildDirectoryList}
|
||||
Pa.DataPipe.DataContainer = {"ModuleBuildDirectoryList":Pa.ModuleBuildDirectoryList}
|
||||
Pa.DataPipe.DataContainer = {"FdsCommandDict": Wa.GenFdsCommandDict}
|
||||
ModuleCodaFile = {}
|
||||
for ma in Pa.ModuleAutoGenList:
|
||||
ModuleCodaFile[(ma.MetaFile.File,ma.MetaFile.Root,ma.Arch,ma.MetaFile.Path)] = [item.Target for item in ma.CodaTargetList]
|
||||
Pa.DataPipe.DataContainer = {"ModuleCodaFile":ModuleCodaFile}
|
||||
for Module in ModuleList:
|
||||
# Get ModuleAutoGen object to generate C code file and makefile
|
||||
Ma = ModuleAutoGen(Wa, Module, BuildTarget, ToolChain, Arch, self.PlatformFile,Pa.DataPipe)
|
||||
|
||||
if Ma is None:
|
||||
continue
|
||||
if Ma.PcdIsDriver:
|
||||
Ma.PlatformInfo = Pa
|
||||
Ma.Workspace = Wa
|
||||
PcdMaList.append(Ma)
|
||||
TotalModules.append(Ma)
|
||||
# Initialize all modules in tracking to 'FAIL'
|
||||
GlobalData.gModuleBuildTracking[Ma] = 'FAIL'
|
||||
|
||||
|
||||
mqueue = mp.Queue()
|
||||
for m in Pa.GetAllModuleInfo:
|
||||
mqueue.put(m)
|
||||
data_pipe_file = os.path.join(Pa.BuildDir, "GlobalVar_%s_%s.bin" % (str(Pa.Guid),Pa.Arch))
|
||||
Pa.DataPipe.dump(data_pipe_file)
|
||||
|
||||
autogen_rt, errorcode = self.StartAutoGen(mqueue, Pa.DataPipe, self.SkipAutoGen, PcdMaList,GlobalData.gCacheIR)
|
||||
|
||||
# Skip cache hit modules
|
||||
if GlobalData.gBinCacheSource:
|
||||
for Ma in TotalModules:
|
||||
if (Ma.MetaFile.Path, Ma.Arch) in GlobalData.gCacheIR and \
|
||||
GlobalData.gCacheIR[(Ma.MetaFile.Path, Ma.Arch)].PreMakeCacheHit:
|
||||
self.HashSkipModules.append(Ma)
|
||||
continue
|
||||
if (Ma.MetaFile.Path, Ma.Arch) in GlobalData.gCacheIR and \
|
||||
GlobalData.gCacheIR[(Ma.MetaFile.Path, Ma.Arch)].MakeCacheHit:
|
||||
self.HashSkipModules.append(Ma)
|
||||
continue
|
||||
BuildModules.append(Ma)
|
||||
else:
|
||||
BuildModules.extend(TotalModules)
|
||||
|
||||
if not autogen_rt:
|
||||
self.AutoGenMgr.TerminateWorkers()
|
||||
self.AutoGenMgr.join(1)
|
||||
raise FatalError(errorcode)
|
||||
self.AutoGenTime += int(round((time.time() - AutoGenStart)))
|
||||
AutoGenIdFile = os.path.join(GlobalData.gConfDirectory,".AutoGenIdFile.txt")
|
||||
with open(AutoGenIdFile,"w") as fw:
|
||||
fw.write("Arch=%s\n" % "|".join((Wa.ArchList)))
|
||||
fw.write("BuildDir=%s\n" % Wa.BuildDir)
|
||||
fw.write("PlatformGuid=%s\n" % str(Wa.AutoGenObjectList[0].Guid))
|
||||
self.Progress.Stop("done!")
|
||||
return Wa, BuildModules
|
||||
|
||||
def _MultiThreadBuildPlatform(self):
|
||||
SaveFileOnChange(self.PlatformBuildPath, '# DO NOT EDIT \n# FILE auto-generated\n', False)
|
||||
for BuildTarget in self.BuildTargetList:
|
||||
GlobalData.gGlobalDefines['TARGET'] = BuildTarget
|
||||
index = 0
|
||||
for ToolChain in self.ToolChainList:
|
||||
WorkspaceAutoGenTime = time.time()
|
||||
GlobalData.gGlobalDefines['TOOLCHAIN'] = ToolChain
|
||||
GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] = ToolChain
|
||||
GlobalData.gGlobalDefines['FAMILY'] = self.ToolChainFamily[index]
|
||||
index += 1
|
||||
Wa = WorkspaceAutoGen(
|
||||
self.WorkspaceDir,
|
||||
self.PlatformFile,
|
||||
BuildTarget,
|
||||
ToolChain,
|
||||
self.ArchList,
|
||||
self.BuildDatabase,
|
||||
self.TargetTxt,
|
||||
self.ToolDef,
|
||||
self.Fdf,
|
||||
self.FdList,
|
||||
self.FvList,
|
||||
self.CapList,
|
||||
self.SkuId,
|
||||
self.UniFlag,
|
||||
self.Progress
|
||||
)
|
||||
self.Fdf = Wa.FdfFile
|
||||
self.LoadFixAddress = Wa.Platform.LoadFixAddress
|
||||
self.BuildReport.AddPlatformReport(Wa)
|
||||
Wa.CreateMakeFile(False)
|
||||
|
||||
# Add ffs build to makefile
|
||||
CmdListDict = {}
|
||||
if GlobalData.gEnableGenfdsMultiThread and self.Fdf:
|
||||
CmdListDict = self._GenFfsCmd(Wa.ArchList)
|
||||
|
||||
# Add Platform and Package level hash in share_data for module hash calculation later
|
||||
if GlobalData.gBinCacheSource or GlobalData.gBinCacheDest:
|
||||
GlobalData.gCacheIR[('PlatformHash')] = GlobalData.gPlatformHash
|
||||
for PkgName in GlobalData.gPackageHash.keys():
|
||||
GlobalData.gCacheIR[(PkgName, 'PackageHash')] = GlobalData.gPackageHash[PkgName]
|
||||
|
||||
# multi-thread exit flag
|
||||
ExitFlag = threading.Event()
|
||||
ExitFlag.clear()
|
||||
self.AutoGenTime += int(round((time.time() - WorkspaceAutoGenTime)))
|
||||
self.BuildModules = []
|
||||
TotalModules = []
|
||||
for Arch in Wa.ArchList:
|
||||
PcdMaList = []
|
||||
AutoGenStart = time.time()
|
||||
GlobalData.gGlobalDefines['ARCH'] = Arch
|
||||
Pa = PlatformAutoGen(Wa, self.PlatformFile, BuildTarget, ToolChain, Arch)
|
||||
if Pa is None:
|
||||
continue
|
||||
ModuleList = []
|
||||
for Inf in Pa.Platform.Modules:
|
||||
ModuleList.append(Inf)
|
||||
# Add the INF only list in FDF
|
||||
if GlobalData.gFdfParser is not None:
|
||||
for InfName in GlobalData.gFdfParser.Profile.InfList:
|
||||
Inf = PathClass(NormPath(InfName), self.WorkspaceDir, Arch)
|
||||
if Inf in Pa.Platform.Modules:
|
||||
continue
|
||||
ModuleList.append(Inf)
|
||||
Pa.DataPipe.DataContainer = {"FfsCommand":CmdListDict}
|
||||
Pa.DataPipe.DataContainer = {"Workspace_timestamp": Wa._SrcTimeStamp}
|
||||
Pa.DataPipe.DataContainer = {"CommandTarget": self.Target}
|
||||
for Module in ModuleList:
|
||||
# Get ModuleAutoGen object to generate C code file and makefile
|
||||
Ma = ModuleAutoGen(Wa, Module, BuildTarget, ToolChain, Arch, self.PlatformFile,Pa.DataPipe)
|
||||
|
||||
if Ma is None:
|
||||
continue
|
||||
if Ma.PcdIsDriver:
|
||||
Ma.PlatformInfo = Pa
|
||||
Ma.Workspace = Wa
|
||||
PcdMaList.append(Ma)
|
||||
TotalModules.append(Ma)
|
||||
# Initialize all modules in tracking to 'FAIL'
|
||||
GlobalData.gModuleBuildTracking[Ma] = 'FAIL'
|
||||
|
||||
mqueue = mp.Queue()
|
||||
for m in Pa.GetAllModuleInfo:
|
||||
mqueue.put(m)
|
||||
data_pipe_file = os.path.join(Pa.BuildDir, "GlobalVar_%s_%s.bin" % (str(Pa.Guid),Pa.Arch))
|
||||
Pa.DataPipe.dump(data_pipe_file)
|
||||
autogen_rt, errorcode = self.StartAutoGen(mqueue, Pa.DataPipe, self.SkipAutoGen, PcdMaList, GlobalData.gCacheIR)
|
||||
|
||||
# Skip cache hit modules
|
||||
if GlobalData.gBinCacheSource:
|
||||
for Ma in TotalModules:
|
||||
if (Ma.MetaFile.Path, Ma.Arch) in GlobalData.gCacheIR and \
|
||||
GlobalData.gCacheIR[(Ma.MetaFile.Path, Ma.Arch)].PreMakeCacheHit:
|
||||
self.HashSkipModules.append(Ma)
|
||||
continue
|
||||
if (Ma.MetaFile.Path, Ma.Arch) in GlobalData.gCacheIR and \
|
||||
GlobalData.gCacheIR[(Ma.MetaFile.Path, Ma.Arch)].MakeCacheHit:
|
||||
self.HashSkipModules.append(Ma)
|
||||
continue
|
||||
self.BuildModules.append(Ma)
|
||||
if self.SkipAutoGen:
|
||||
Wa = self.VerifyAutoGenFiles()
|
||||
if Wa is None:
|
||||
self.SkipAutoGen = False
|
||||
Wa, self.BuildModules = self.PerformAutoGen(BuildTarget,ToolChain)
|
||||
else:
|
||||
self.BuildModules.extend(TotalModules)
|
||||
|
||||
if not autogen_rt:
|
||||
self.AutoGenMgr.TerminateWorkers()
|
||||
self.AutoGenMgr.join(0.1)
|
||||
raise FatalError(errorcode)
|
||||
self.AutoGenTime += int(round((time.time() - AutoGenStart)))
|
||||
self.Progress.Stop("done!")
|
||||
GlobalData.gAutoGenPhase = True
|
||||
self.BuildModules = self.SetupMakeSetting(Wa)
|
||||
else:
|
||||
Wa, self.BuildModules = self.PerformAutoGen(BuildTarget,ToolChain)
|
||||
Pa = Wa.AutoGenObjectList[0]
|
||||
GlobalData.gAutoGenPhase = False
|
||||
|
||||
if GlobalData.gBinCacheSource:
|
||||
EdkLogger.quiet("Total cache hit driver num: %s, cache miss driver num: %s" % (len(set(self.HashSkipModules)), len(set(self.BuildModules))))
|
||||
@ -2138,14 +2250,13 @@ class Build():
|
||||
BuildTask.StartScheduler(self.ThreadNumber, ExitFlag)
|
||||
|
||||
# in case there's an interruption. we need a full version of makefile for platform
|
||||
Pa.CreateMakeFile(False)
|
||||
|
||||
if BuildTask.HasError():
|
||||
self.invalidateHash()
|
||||
EdkLogger.error("build", BUILD_ERROR, "Failed to build module", ExtraData=GlobalData.gBuildingModule)
|
||||
self.MakeTime += int(round((time.time() - MakeStart)))
|
||||
|
||||
MakeContiue = time.time()
|
||||
|
||||
#
|
||||
#
|
||||
# All modules have been put in build tasks queue. Tell task scheduler
|
||||
@ -2177,13 +2288,8 @@ class Build():
|
||||
#
|
||||
# Get Module List
|
||||
#
|
||||
ModuleList = {}
|
||||
for Pa in Wa.AutoGenObjectList:
|
||||
for Ma in Pa.ModuleAutoGenList:
|
||||
if Ma is None:
|
||||
continue
|
||||
if not Ma.IsLibrary:
|
||||
ModuleList[Ma.Guid.upper()] = Ma
|
||||
ModuleList = {ma.Guid.upper():ma for ma in self.BuildModules}
|
||||
|
||||
#
|
||||
# Rebase module to the preferred memory address before GenFds
|
||||
#
|
||||
@ -2208,29 +2314,13 @@ class Build():
|
||||
# Save MAP buffer into MAP file.
|
||||
#
|
||||
self._SaveMapFile(MapBuffer, Wa)
|
||||
self.CreateGuidedSectionToolsFile(Wa)
|
||||
self.invalidateHash()
|
||||
|
||||
## Generate GuidedSectionTools.txt in the FV directories.
|
||||
#
|
||||
def CreateGuidedSectionToolsFile(self):
|
||||
def CreateGuidedSectionToolsFile(self,Wa):
|
||||
for BuildTarget in self.BuildTargetList:
|
||||
for ToolChain in self.ToolChainList:
|
||||
Wa = WorkspaceAutoGen(
|
||||
self.WorkspaceDir,
|
||||
self.PlatformFile,
|
||||
BuildTarget,
|
||||
ToolChain,
|
||||
self.ArchList,
|
||||
self.BuildDatabase,
|
||||
self.TargetTxt,
|
||||
self.ToolDef,
|
||||
self.Fdf,
|
||||
self.FdList,
|
||||
self.FvList,
|
||||
self.CapList,
|
||||
self.SkuId,
|
||||
self.UniFlag
|
||||
)
|
||||
FvDir = Wa.FvDir
|
||||
if not os.path.exists(FvDir):
|
||||
continue
|
||||
@ -2287,7 +2377,6 @@ class Build():
|
||||
self._BuildPlatform()
|
||||
else:
|
||||
self._MultiThreadBuildPlatform()
|
||||
self.CreateGuidedSectionToolsFile()
|
||||
else:
|
||||
self.SpawnMode = False
|
||||
self._BuildModule()
|
||||
|
Loading…
Reference in New Issue
Block a user