GlobalData.gAutoGenPhase = True \r
Fdf = FdfParser(self.FdfFile.Path)\r
Fdf.ParseFile()\r
+ GlobalData.gFdfParser = Fdf\r
GlobalData.gAutoGenPhase = False\r
PcdSet = Fdf.Profile.PcdDict\r
ModuleList = Fdf.Profile.InfList\r
DecPcds = {}\r
DecPcdsKey = set()\r
PGen = PlatformAutoGen(self, self.MetaFile, Target, Toolchain, Arch)\r
- Pkgs = PGen.PackageList\r
+ PkgSet = set()\r
+ for Inf in ModuleList:\r
+ ModuleFile = PathClass(NormPath(Inf), GlobalData.gWorkspace, Arch)\r
+ if ModuleFile in Platform.Modules:\r
+ continue\r
+ ModuleData = self.BuildDatabase[ModuleFile, Arch, Target, Toolchain]\r
+ PkgSet.update(ModuleData.Packages)\r
+ Pkgs = list(PkgSet) + list(PGen.PackageList)\r
for Pkg in Pkgs:\r
for Pcd in Pkg.Pcds:\r
DecPcds[Pcd[0], Pcd[1]] = Pkg.Pcds[Pcd]\r
self.FdTargetList = self.Workspace.FdTargetList\r
self.FvTargetList = self.Workspace.FvTargetList\r
self.AllPcdList = []\r
+ # get the original module/package/platform objects\r
+ self.BuildDatabase = Workspace.BuildDatabase\r
\r
# flag indicating if the makefile/C-code file has been created or not\r
self.IsMakeFileCreated = False\r
self._ModuleAutoGenList = None\r
self._LibraryAutoGenList = None\r
self._BuildCommand = None\r
-\r
+ self._AsBuildInfList = []\r
+ self._AsBuildModuleList = []\r
+ if GlobalData.gFdfParser != None:\r
+ self._AsBuildInfList = GlobalData.gFdfParser.Profile.InfList\r
+ for Inf in self._AsBuildInfList:\r
+ InfClass = PathClass(NormPath(Inf), GlobalData.gWorkspace, self.Arch)\r
+ M = self.BuildDatabase[InfClass, self.Arch, self.BuildTarget, self.ToolChain]\r
+ if not M.IsSupportedArch:\r
+ continue\r
+ self._AsBuildModuleList.append(InfClass)\r
# get library/modules for build\r
self.LibraryBuildDirectoryList = []\r
self.ModuleBuildDirectoryList = []\r
# get the original module/package/platform objects\r
- self.BuildDatabase = Workspace.BuildDatabase\r
+ self.LibraryBuildDirectoryList = []\r
+ self.ModuleBuildDirectoryList = []\r
return True\r
\r
def __repr__(self):\r
def CollectPlatformDynamicPcds(self):\r
# for gathering error information\r
NoDatumTypePcdList = set()\r
-\r
+ PcdNotInDb = []\r
self._GuidValue = {}\r
+ FdfModuleList = []\r
+ for InfName in self._AsBuildInfList:\r
+ InfName = os.path.join(self.WorkspaceDir, InfName)\r
+ FdfModuleList.append(os.path.normpath(InfName))\r
for F in self.Platform.Modules.keys():\r
M = ModuleAutoGen(self.Workspace, F, self.BuildTarget, self.ToolChain, self.Arch, self.MetaFile)\r
#GuidValue.update(M.Guids)\r
if PcdFromModule.DatumType == "VOID*" and PcdFromModule.MaxDatumSize in [None, '']:\r
NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, F))\r
\r
+ if M.IsBinaryModule == True:\r
+ PcdFromModule.IsFromBinaryInf = True\r
+ if (PcdFromModule.TokenCName, PcdFromModule.TokenSpaceGuidCName) in self.Platform.Pcds.keys():\r
+ PcdFromModule.IsFromDsc = True\r
+ else:\r
+ PcdFromModule.IsFromDsc = False\r
if PcdFromModule.Type in GenC.gDynamicPcd or PcdFromModule.Type in GenC.gDynamicExPcd:\r
+ if F.Path not in FdfModuleList:\r
+ # If one of the Source built modules listed in the DSC is not listed \r
+ # in FDF modules, and the INF lists a PCD can only use the PcdsDynamic \r
+ # access method (it is only listed in the DEC file that declares the \r
+ # PCD as PcdsDynamic), then build tool will report warning message\r
+ # notify the PI that they are attempting to build a module that must \r
+ # be included in a flash image in order to be functional. These Dynamic \r
+ # PCD will not be added into the Database unless it is used by other \r
+ # modules that are included in the FDF file.\r
+ if PcdFromModule.Type in GenC.gDynamicPcd and \\r
+ PcdFromModule.IsFromBinaryInf == False:\r
+ # Print warning message to let the developer make a determine.\r
+ if PcdFromModule not in PcdNotInDb:\r
+ EdkLogger.warn("build",\r
+ "A PCD listed in the DSC (%s.%s, %s) is used by a module not in the FDF. If the PCD is not used by any module listed in the FDF this PCD will be ignored. " \\r
+ % (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, self.Platform.MetaFile.Path),\r
+ File=self.MetaFile, \\r
+ ExtraData=None)\r
+ PcdNotInDb.append(PcdFromModule)\r
+ continue\r
+ # If one of the Source built modules listed in the DSC is not listed in \r
+ # FDF modules, and the INF lists a PCD can only use the PcdsDynamicEx \r
+ # access method (it is only listed in the DEC file that declares the \r
+ # PCD as PcdsDynamicEx), then DO NOT break the build; DO NOT add the \r
+ # PCD to the Platform's PCD Database.\r
+ if PcdFromModule.Type in GenC.gDynamicExPcd:\r
+ if PcdFromModule not in PcdNotInDb:\r
+ PcdNotInDb.append(PcdFromModule)\r
+ continue\r
#\r
# If a dynamic PCD used by a PEM module/PEI module & DXE module,\r
# it should be stored in Pcd PEI database, If a dynamic only\r
self._DynaPcdList_[Index] = PcdFromModule\r
elif PcdFromModule not in self._NonDynaPcdList_:\r
self._NonDynaPcdList_.append(PcdFromModule)\r
+ elif PcdFromModule in self._NonDynaPcdList_ and PcdFromModule.IsFromBinaryInf == True:\r
+ Index = self._NonDynaPcdList_.index(PcdFromModule)\r
+ if self._NonDynaPcdList_[Index].IsFromBinaryInf == False:\r
+ #The PCD from Binary INF will override the same one from source INF\r
+ self._NonDynaPcdList_.remove (self._NonDynaPcdList_[Index])\r
+ PcdFromModule.Pending = False\r
+ self._NonDynaPcdList_.append (PcdFromModule)\r
+ # Parse the DynamicEx PCD from the AsBuild INF module list of FDF.\r
+ DscModuleList = []\r
+ for ModuleInf in self.Platform.Modules.keys():\r
+ DscModuleList.append (os.path.normpath(ModuleInf.Path))\r
+ # add the PCD from modules that listed in FDF but not in DSC to Database \r
+ for InfName in FdfModuleList:\r
+ if InfName not in DscModuleList:\r
+ InfClass = PathClass(InfName)\r
+ M = self.BuildDatabase[InfClass, self.Arch, self.BuildTarget, self.ToolChain]\r
+ # If a module INF in FDF but not in current arch's DSC module list, it must be module (either binary or source) \r
+ # for different Arch. PCDs in source module for different Arch is already added before, so skip the source module here. \r
+ # For binary module, if in current arch, we need to list the PCDs into database. \r
+ if not M.IsSupportedArch:\r
+ continue\r
+ # Override the module PCD setting by platform setting\r
+ ModulePcdList = self.ApplyPcdSetting(M, M.Pcds)\r
+ for PcdFromModule in ModulePcdList:\r
+ PcdFromModule.IsFromBinaryInf = True\r
+ PcdFromModule.IsFromDsc = False\r
+ # Only allow the DynamicEx and Patchable PCD in AsBuild INF\r
+ if PcdFromModule.Type not in GenC.gDynamicExPcd and PcdFromModule.Type not in TAB_PCDS_PATCHABLE_IN_MODULE:\r
+ EdkLogger.error("build", AUTOGEN_ERROR, "PCD setting error",\r
+ File=self.MetaFile,\r
+ ExtraData="\n\tExisted %s PCD %s in:\n\t\t%s\n"\r
+ % (PcdFromModule.Type, PcdFromModule.TokenCName, InfName))\r
+ # make sure that the "VOID*" kind of datum has MaxDatumSize set\r
+ if PcdFromModule.DatumType == "VOID*" and PcdFromModule.MaxDatumSize in [None, '']:\r
+ NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, InfName))\r
+ if M.ModuleType in ["PEIM", "PEI_CORE"]:\r
+ PcdFromModule.Phase = "PEI"\r
+ if PcdFromModule not in self._DynaPcdList_ and PcdFromModule.Type in GenC.gDynamicExPcd:\r
+ self._DynaPcdList_.append(PcdFromModule)\r
+ elif PcdFromModule not in self._NonDynaPcdList_ and PcdFromModule.Type in TAB_PCDS_PATCHABLE_IN_MODULE:\r
+ self._NonDynaPcdList_.append(PcdFromModule)\r
+ if PcdFromModule in self._DynaPcdList_ and PcdFromModule.Phase == 'PEI' and PcdFromModule.Type in GenC.gDynamicExPcd:\r
+ Index = self._DynaPcdList_.index(PcdFromModule)\r
+ self._DynaPcdList_[Index].Phase = PcdFromModule.Phase\r
+ self._DynaPcdList_[Index].Type = PcdFromModule.Type\r
+ for PcdFromModule in self._NonDynaPcdList_:\r
+ # If a PCD is not listed in the DSC file, but binary INF files used by \r
+ # this platform all (that use this PCD) list the PCD in a [PatchPcds] \r
+ # section, AND all source INF files used by this platform the build \r
+ # that use the PCD list the PCD in either a [Pcds] or [PatchPcds] \r
+ # section, then the tools must NOT add the PCD to the Platform's PCD\r
+ # Database; the build must assign the access method for this PCD as \r
+ # PcdsPatchableInModule.\r
+ if PcdFromModule not in self._DynaPcdList_:\r
+ continue\r
+ Index = self._DynaPcdList_.index(PcdFromModule)\r
+ if PcdFromModule.IsFromDsc == False and \\r
+ PcdFromModule.Type in TAB_PCDS_PATCHABLE_IN_MODULE and \\r
+ PcdFromModule.IsFromBinaryInf == True and \\r
+ self._DynaPcdList_[Index].IsFromBinaryInf == False:\r
+ Index = self._DynaPcdList_.index(PcdFromModule)\r
+ self._DynaPcdList_.remove (self._DynaPcdList_[Index])\r
\r
# print out error information and break the build, if error found\r
if len(NoDatumTypePcdList) > 0:\r
% NoDatumTypePcdListString)\r
self._NonDynamicPcdList = self._NonDynaPcdList_\r
self._DynamicPcdList = self._DynaPcdList_\r
- self.AllPcdList = self._NonDynamicPcdList + self._DynamicPcdList\r
- \r
+ # If PCD is listed in a PcdsDynamicHii, PcdsDynamicExHii, PcdsDynamicHii or PcdsDynamicExHii\r
+ # section, and the PCD is not used by any module that is listed in the DSC file, the build \r
+ # provide a warning message.\r
+ for PcdKey in self.Platform.Pcds.keys():\r
+ Pcd = self.Platform.Pcds[PcdKey]\r
+ if Pcd not in self._DynamicPcdList + PcdNotInDb and \\r
+ Pcd.Type in [TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_DEFAULT, TAB_PCDS_DYNAMIC_HII, TAB_PCDS_DYNAMIC_EX, TAB_PCDS_DYNAMIC_EX_DEFAULT, TAB_PCDS_DYNAMIC_EX_HII]:\r
+ # Print warning message to let the developer make a determine.\r
+ EdkLogger.warn("build",\r
+ "A %s PCD listed in the DSC (%s.%s, %s) is not used by any module." \\r
+ % (Pcd.Type, Pcd.TokenSpaceGuidCName, Pcd.TokenCName, self.Platform.MetaFile.Path),\r
+ File=self.MetaFile, \\r
+ ExtraData=None)\r
#\r
# Sort dynamic PCD list to:\r
# 1) If PCD's datum type is VOID* and value is unicode string which starts with L, the PCD item should \r
self._DynamicPcdList.extend(UnicodePcdArray)\r
self._DynamicPcdList.extend(HiiPcdArray)\r
self._DynamicPcdList.extend(OtherPcdArray)\r
- \r
+ self.AllPcdList = self._NonDynamicPcdList + self._DynamicPcdList\r
\r
## Return the platform build data object\r
def _GetPlatform(self):\r
self._PackageList.update(La.DependentPackageList)\r
for Ma in self.ModuleAutoGenList:\r
self._PackageList.update(Ma.DependentPackageList)\r
- self._PackageList = list(self._PackageList)\r
+ #Collect package set information from INF of FDF\r
+ PkgSet = set()\r
+ for ModuleFile in self._AsBuildModuleList:\r
+ if ModuleFile in self.Platform.Modules:\r
+ continue\r
+ ModuleData = self.BuildDatabase[ModuleFile, self.Arch, self.BuildTarget, self.ToolChain]\r
+ PkgSet.update(ModuleData.Packages)\r
+ self._PackageList = list(self._PackageList) + list (PkgSet)\r
return self._PackageList\r
\r
def _GetNonDynamicPcdDict(self):\r
# by the platform or current configuration\r
#\r
def ValidModule(self, Module):\r
- return Module in self.Platform.Modules or Module in self.Platform.LibraryInstances\r
+ return Module in self.Platform.Modules or Module in self.Platform.LibraryInstances \\r
+ or Module in self._AsBuildModuleList\r
\r
## Resolve the library classes in a module to library instances\r
#\r
# dependent libraries will be created\r
#\r
def CreateMakeFile(self, CreateLibraryMakeFile=True):\r
+ if self.IsBinaryModule:\r
+ return\r
if self.IsMakeFileCreated:\r
return\r
\r
\r
self.IsMakeFileCreated = True\r
\r
+ def CopyBinaryFiles(self):\r
+ for File in self.Module.Binaries:\r
+ SrcPath = File.Path\r
+ DstPath = os.path.join(self.OutputDir , os.path.basename(SrcPath))\r
+ CopyLongFilePath(SrcPath, DstPath)\r
## Create autogen code for the module and its dependent libraries\r
#\r
# @param CreateLibraryCodeFile Flag indicating if or not the code of\r
if self.IsBinaryModule and self.PcdIsDriver != '':\r
CreatePcdDatabaseCode(self, TemplateString(), TemplateString())\r
return\r
+ if self.IsBinaryModule:\r
+ self.CopyBinaryFiles()\r
+ return\r
\r
if not self.IsLibrary and CreateLibraryCodeFile:\r
for LibraryAutoGen in self.LibraryAutoGenList:\r
self.Platform = None\r
self.LoadFixAddress = 0\r
self.UniFlag = BuildOptions.Flag\r
+ self.BuildModules = []\r
\r
# print dot character during doing some time-consuming work\r
self.Progress = Utils.Progressor()\r
if BuildModule:\r
BuildCommand = BuildCommand + [Target]\r
LaunchCommand(BuildCommand, AutoGenObject.MakeFileDir)\r
+ self.CreateAsBuiltInf()\r
return True\r
\r
# build library\r
for Mod in AutoGenObject.ModuleBuildDirectoryList:\r
NewBuildCommand = BuildCommand + ['-f', os.path.normpath(os.path.join(Mod, makefile)), 'pbuild']\r
LaunchCommand(NewBuildCommand, AutoGenObject.MakeFileDir)\r
+ self.CreateAsBuiltInf()\r
return True\r
\r
# cleanlib\r
BuildCommand = BuildCommand + [Target]\r
if BuildModule:\r
LaunchCommand(BuildCommand, AutoGenObject.MakeFileDir)\r
+ self.CreateAsBuiltInf()\r
return True\r
\r
# build library\r
for Arch in Wa.ArchList:\r
GlobalData.gGlobalDefines['ARCH'] = Arch\r
Pa = PlatformAutoGen(Wa, self.PlatformFile, BuildTarget, ToolChain, Arch)\r
+ for Module in Pa.Platform.Modules:\r
+ # Get ModuleAutoGen object to generate C code file and makefile\r
+ Ma = ModuleAutoGen(Wa, Module, BuildTarget, ToolChain, Arch, self.PlatformFile)\r
+ if Ma == None:\r
+ continue\r
+ self.BuildModules.append(Ma)\r
self._BuildPa(self.Target, Pa)\r
\r
# Create MAP file when Load Fix Address is enabled.\r
Ma = ModuleAutoGen(Wa, self.ModuleFile, BuildTarget, ToolChain, Arch, self.PlatformFile)\r
if Ma == None: continue\r
MaList.append(Ma)\r
+ self.BuildModules.append(Ma)\r
if not Ma.IsBinaryModule:\r
self._Build(self.Target, Ma, BuildModule=True)\r
\r
Pa = PlatformAutoGen(Wa, self.PlatformFile, BuildTarget, ToolChain, Arch)\r
if Pa == None:\r
continue\r
- pModules = []\r
- for Module in Pa.Platform.Modules:\r
+ ModuleList = []\r
+ for Inf in Pa.Platform.Modules:\r
+ ModuleList.append(Inf)\r
+ # Add the INF only list in FDF\r
+ if GlobalData.gFdfParser != None:\r
+ for InfName in GlobalData.gFdfParser.Profile.InfList:\r
+ Inf = PathClass(NormPath(InfName), self.WorkspaceDir, Arch)\r
+ if Inf in Pa.Platform.Modules:\r
+ continue\r
+ ModuleList.append(Inf)\r
+ for Module in ModuleList:\r
# Get ModuleAutoGen object to generate C code file and makefile\r
Ma = ModuleAutoGen(Wa, Module, BuildTarget, ToolChain, Arch, self.PlatformFile)\r
+ \r
if Ma == None:\r
continue\r
# Not to auto-gen for targets 'clean', 'cleanlib', 'cleanall', 'run', 'fds'\r
\r
if not self.SkipAutoGen or self.Target == 'genmake':\r
Ma.CreateMakeFile(True)\r
- Ma.CreateAsBuiltInf()\r
if self.Target == "genmake":\r
continue\r
- pModules.append(Ma)\r
+ self.BuildModules.append(Ma)\r
self.Progress.Stop("done!")\r
\r
- for Ma in pModules:\r
+ for Ma in self.BuildModules:\r
# Generate build task for the module\r
- Bt = BuildTask.New(ModuleMakeUnit(Ma, self.Target))\r
+ if not Ma.IsBinaryModule:\r
+ Bt = BuildTask.New(ModuleMakeUnit(Ma, self.Target))\r
# Break build if any build thread has error\r
if BuildTask.HasError():\r
# we need a full version of makefile for platform\r
#\r
ExitFlag.set()\r
BuildTask.WaitForComplete()\r
+ self.CreateAsBuiltInf()\r
\r
#\r
# Check for build error, and raise exception if one\r
self.SpawnMode = False\r
self._BuildModule()\r
\r
+ def CreateAsBuiltInf(self):\r
+ for Module in self.BuildModules:\r
+ Module.CreateAsBuiltInf()\r
+ self.BuildModules = []\r
## Do some clean-up works when error occurred\r
def Relinquish(self):\r
OldLogLevel = EdkLogger.GetLevel()\r