Skip to content

Commit

Permalink
Added more error check
Browse files Browse the repository at this point in the history
git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@1291 7335b38e-4728-0410-8992-fb3ffe349368
  • Loading branch information
jwang36 committed Jul 31, 2008
1 parent e832ad3 commit 8d8c918
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 30 deletions.
42 changes: 17 additions & 25 deletions Source/Python/AutoGen/AutoGen.py
Expand Up @@ -36,6 +36,7 @@
from Common.DataType import *
from Common.Misc import *
from Common.String import *
import Common.GlobalData as GlobalData
from GenFds.FdfParser import *

## Regular expression for splitting Dependency Expression stirng into tokens
Expand Down Expand Up @@ -334,6 +335,7 @@ class PlatformAutoGen(AutoGen):
#
def _Init(self, Workspace, PlatformFile, Target, Toolchain, Arch):
EdkLogger.verbose("\nAutoGen platform [%s] [%s]" % (PlatformFile, Arch))
GlobalData.gProcessingFile = "%s [%s, %s, %s]" % (PlatformFile, Arch, Toolchain, Target)

self._MetaFile = str(PlatformFile)
self.Workspace = Workspace
Expand Down Expand Up @@ -620,7 +622,9 @@ def _GetToolOptions(self):
#
def _GetBuildRule(self):
if self._BuildRule == None:
BuildRuleFile = self.Workspace.TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_BUILD_RULE_CONF]
BuildRuleFile = None
if TAB_TAT_DEFINES_BUILD_RULE_CONF in self.Workspace.TargetTxt.TargetTxtDictionary:
BuildRuleFile = self.Workspace.TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_BUILD_RULE_CONF]
if BuildRuleFile in [None, '']:
BuildRuleFile = gBuildRuleFile
self._BuildRule = BuildRule(BuildRuleFile)
Expand Down Expand Up @@ -791,21 +795,22 @@ def ApplyLibraryInstance(self, Module):
LibraryPath = self.Platform.LibraryClasses[LibraryClassName, ModuleType]
if LibraryPath == None or LibraryPath == "":
LibraryPath = M.LibraryClasses[LibraryClassName]
if LibraryPath == None:
if LibraryPath == None or LibraryPath == "":
EdkLogger.error("build", RESOURCE_NOT_AVAILABLE,
"Instance of library class [%s] is not found" % LibraryClassName,
File=self._MetaFile,
ExtraData="consumed by [%s] [%s]\n\t[%s]" % (str(M), self.Arch, str(Module)))
ExtraData="in [%s] [%s]\n\tconsumed by module [%s]" % (str(M), self.Arch, str(Module)))

LibraryModule = self.BuildDatabase[LibraryPath, self.Arch]
# for those forced library instance (NULL library), add a fake library class
if LibraryClassName.startswith("NULL"):
LibraryModule.LibraryClass.append(LibraryClassObject(LibraryClassName, [ModuleType]))
elif ModuleType not in LibraryModule.LibraryClass[0].SupModList:
elif LibraryModule.LibraryClass == None or len(LibraryModule.LibraryClass) == 0 \
or ModuleType not in LibraryModule.LibraryClass[0].SupModList:
EdkLogger.error("build", OPTION_MISSING,
"Module type [%s] is not supported by library instance [%s]" \
% (ModuleType, LibraryPath), File=self._MetaFile,
ExtraData="\tconsumed by [%s]" % str(Module))
ExtraData="consumed by [%s]" % str(Module))

LibraryInstance[LibraryClassName] = LibraryModule
LibraryConsumerList.append(LibraryModule)
Expand Down Expand Up @@ -837,25 +842,7 @@ def ApplyLibraryInstance(self, Module):
Q = []
for LibraryClassName in LibraryInstance:
M = LibraryInstance[LibraryClassName]
#if M == None:
# EdkLogger.error("build", RESOURCE_NOT_AVAILABLE,
# "Library instance of library class [%s] is not found" % LibraryClassName,
# File=self._MetaFile, ExtraData="consumed by [%s] [%s]" % (str(Module), self.Arch))
LibraryList.append(M)
#
# check if there're library classes
#
#for Lc in M.LibraryClass:
# if Lc.SupModList != None and ModuleType not in Lc.SupModList:
# EdkLogger.error("build", OPTION_MISSING,
# "Module type [%s] is not supported by library instance [%s]" % (ModuleType, str(M)),
# File=self._MetaFile, ExtraData="\tconsumed by [%s]" % str(Module))

#if Lc.LibraryClass in LibraryInstance and str(M) != str(LibraryInstance[Lc.LibraryClass]):
# EdkLogger.error("build", OPTION_CONFLICT,
# "More than one library instance found for library class [%s] in module [%s]" % (Lc.LibraryClass, str(Module)),
# ExtraData="\t%s\n\t%s" % (LibraryInstance[Lc.LibraryClass], str(M))
# )
if ConsumedByList[M] == []:
Q.insert(0, M)

Expand Down Expand Up @@ -962,7 +949,9 @@ def _OverridePcd(self, ToPcd, FromPcd, Module=""):
EdkLogger.verbose("No MaxDatumSize specified for PCD %s.%s" \
% (ToPcd.TokenSpaceGuidCName, ToPcd.TokenCName))
Value = ToPcd.DefaultValue
if Value[0] == 'L':
if Value in [None, '']:
ToPcd.MaxDatumSize = 1
elif Value[0] == 'L':
ToPcd.MaxDatumSize = str(len(Value) * 2)
elif Value[0] == '{':
ToPcd.MaxDatumSize = str(len(Value.split(',')))
Expand Down Expand Up @@ -1040,7 +1029,9 @@ def ResolveLibraryReference(self, Module):
while len(LibraryConsumerList) > 0:
M = LibraryConsumerList.pop()
for LibraryName in M.Libraries:
Library = self.Platform.LibraryClasses[LibraryName, ':dummy:']
Library = None
if (LibraryName, ':dummy:') in self.Platform.LibraryClasses:
Library = self.Platform.LibraryClasses[LibraryName, ':dummy:']
if Library == None:
EdkLogger.warn("build", "Library [%s] is not found" % LibraryName, File=str(M),
ExtraData="\t%s [%s]" % (str(Module), self.Arch))
Expand Down Expand Up @@ -1161,6 +1152,7 @@ class ModuleAutoGen(AutoGen):
#
def _Init(self, Workspace, ModuleFile, Target, Toolchain, Arch, PlatformFile):
EdkLogger.verbose("\nAutoGen module [%s] [%s]" % (ModuleFile, Arch))
GlobalData.gProcessingFile = "%s [%s, %s, %s]" % (ModuleFile, Arch, Toolchain, Target)

self.Workspace = Workspace
self.WorkspaceDir = Workspace.WorkspaceDir
Expand Down
3 changes: 3 additions & 0 deletions Source/Python/Workspace/WorkspaceDatabase.py
Expand Up @@ -409,6 +409,9 @@ def _GetLibraryClasses(self):
if not ValidFile(LibraryInstance, '.inf'):
EdkLogger.error('build', FILE_NOT_FOUND, File=self.DescFilePath,
ExtraData=LibraryInstance, Line=LineNo)
if ModuleType != 'COMMON' and ModuleType not in SUP_MODULE_LIST:
EdkLogger.error('build', OPTION_UNKNOWN, "Unknown module type [%s]" % ModuleType,
File=self.DescFilePath, ExtraData=LibraryInstance, Line=LineNo)
LibraryClassDict[Arch, ModuleType, LibraryClass] = LibraryInstance
if LibraryInstance not in self._LibraryInstances:
self._LibraryInstances.append(LibraryInstance)
Expand Down
16 changes: 11 additions & 5 deletions Source/Python/build/build.py
Expand Up @@ -587,6 +587,12 @@ def _CommandThread(self, Command, WorkingDir):
# TRICK: hide the output of threads left runing, so that the user can
# catch the error message easily
#
if not BuildTask._ErrorFlag.isSet():
GlobalData.gBuildingModule = "%s [%s, %s, %s]" % (str(self.BuildItem.BuildObject),
self.BuildItem.BuildObject.Arch,
self.BuildItem.BuildObject.ToolChain,
self.BuildItem.BuildObject.BuildTarget
)
EdkLogger.SetLevel(EdkLogger.QUIET)
BuildTask._ErrorFlag.set()
BuildTask._ErrorMessage = "%s broken\n %s [%s]" % \
Expand Down Expand Up @@ -998,15 +1004,15 @@ def _MultiThreadBuildPlatform(self):
ExitFlag.set()
BuildTask.WaitForComplete()
Pa.CreateMakeFile(False)
EdkLogger.error("build", BUILD_ERROR, BuildTask.GetErrorMessage())
EdkLogger.error("build", BUILD_ERROR, "Failed to build module", ExtraData=GlobalData.gBuildingModule)
# Start task scheduler
if not BuildTask.IsOnGoing():
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():
EdkLogger.error("build", BUILD_ERROR, BuildTask.GetErrorMessage())
EdkLogger.error("build", BUILD_ERROR, "Failed to build module", ExtraData=GlobalData.gBuildingModule)

#
# All modules have been put in build tasks queue. Tell task scheduler
Expand All @@ -1020,7 +1026,7 @@ def _MultiThreadBuildPlatform(self):
# has been signaled.
#
if BuildTask.HasError():
EdkLogger.error("build", BUILD_ERROR, BuildTask.GetErrorMessage())
EdkLogger.error("build", BUILD_ERROR, "Failed to build module", ExtraData=GlobalData.gBuildingModule)

# Generate FD image if there's a FDF file found
if self.Fdf != '' and self.Target in ["", "all", "fds"]:
Expand Down Expand Up @@ -1301,8 +1307,8 @@ def Main():
EdkLogger.error(
"\nbuild",
CODE_ERROR,
"Unknown fatal error",
ExtraData="Please send email to dev@buildtools.tianocore.org for help, attaching following call stack trace!\n",
"Unknown fatal error when processing [%s]" % GlobalData.gProcessingFile,
ExtraData="\n(Please send email to dev@buildtools.tianocore.org for help, attaching following call stack trace!)\n",
RaiseError=False
)
EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc())
Expand Down

0 comments on commit 8d8c918

Please sign in to comment.