Revision: 15893
          http://sourceforge.net/p/edk2/code/15893
Author:   bobfeng
Date:     2014-08-26 02:52:24 +0000 (Tue, 26 Aug 2014)
Log Message:
-----------
This patch is going to correct the external PCD database generation rule to 
support the case that all binary driver are only listed in FDF file.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Feng, Bob C <[email protected]>
Reviewed-by: Yingke Liu <[email protected]>

Modified Paths:
--------------
    trunk/edk2/BaseTools/Source/Python/AutoGen/AutoGen.py
    trunk/edk2/BaseTools/Source/Python/Workspace/BuildClassObject.py
    trunk/edk2/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
    trunk/edk2/BaseTools/Source/Python/build/build.py

Modified: trunk/edk2/BaseTools/Source/Python/AutoGen/AutoGen.py
===================================================================
--- trunk/edk2/BaseTools/Source/Python/AutoGen/AutoGen.py       2014-08-25 
23:10:18 UTC (rev 15892)
+++ trunk/edk2/BaseTools/Source/Python/AutoGen/AutoGen.py       2014-08-26 
02:52:24 UTC (rev 15893)
@@ -269,6 +269,7 @@
             GlobalData.gAutoGenPhase = True    
             Fdf = FdfParser(self.FdfFile.Path)
             Fdf.ParseFile()
+            GlobalData.gFdfParser = Fdf
             GlobalData.gAutoGenPhase = False
             PcdSet = Fdf.Profile.PcdDict
             ModuleList = Fdf.Profile.InfList
@@ -298,7 +299,14 @@
             DecPcds = {}
             DecPcdsKey = set()
             PGen = PlatformAutoGen(self, self.MetaFile, Target, Toolchain, 
Arch)
-            Pkgs = PGen.PackageList
+            PkgSet = set()
+            for Inf in ModuleList:
+                ModuleFile = PathClass(NormPath(Inf), GlobalData.gWorkspace, 
Arch)
+                if ModuleFile in Platform.Modules:
+                    continue
+                ModuleData = self.BuildDatabase[ModuleFile, Arch, Target, 
Toolchain]
+                PkgSet.update(ModuleData.Packages)
+            Pkgs = list(PkgSet) + list(PGen.PackageList)
             for Pkg in Pkgs:
                 for Pcd in Pkg.Pcds:
                     DecPcds[Pcd[0], Pcd[1]] = Pkg.Pcds[Pcd]
@@ -760,6 +768,8 @@
         self.FdTargetList = self.Workspace.FdTargetList
         self.FvTargetList = self.Workspace.FvTargetList
         self.AllPcdList = []
+        # get the original module/package/platform objects
+        self.BuildDatabase = Workspace.BuildDatabase
 
         # flag indicating if the makefile/C-code file has been created or not
         self.IsMakeFileCreated  = False
@@ -794,12 +804,22 @@
         self._ModuleAutoGenList  = None
         self._LibraryAutoGenList = None
         self._BuildCommand = None
-
+        self._AsBuildInfList = []
+        self._AsBuildModuleList = []
+        if GlobalData.gFdfParser != None:
+            self._AsBuildInfList = GlobalData.gFdfParser.Profile.InfList
+            for Inf in self._AsBuildInfList:
+                InfClass = PathClass(NormPath(Inf), GlobalData.gWorkspace, 
self.Arch)
+                M = self.BuildDatabase[InfClass, self.Arch, self.BuildTarget, 
self.ToolChain]
+                if not M.IsSupportedArch:
+                    continue
+                self._AsBuildModuleList.append(InfClass)
         # get library/modules for build
         self.LibraryBuildDirectoryList = []
         self.ModuleBuildDirectoryList = []
         # get the original module/package/platform objects
-        self.BuildDatabase = Workspace.BuildDatabase
+        self.LibraryBuildDirectoryList = []
+        self.ModuleBuildDirectoryList = []
         return True
 
     def __repr__(self):
@@ -886,8 +906,12 @@
     def CollectPlatformDynamicPcds(self):
         # for gathering error information
         NoDatumTypePcdList = set()
-
+        PcdNotInDb = []
         self._GuidValue = {}
+        FdfModuleList = []
+        for InfName in self._AsBuildInfList:
+            InfName = os.path.join(self.WorkspaceDir, InfName)
+            FdfModuleList.append(os.path.normpath(InfName))
         for F in self.Platform.Modules.keys():
             M = ModuleAutoGen(self.Workspace, F, self.BuildTarget, 
self.ToolChain, self.Arch, self.MetaFile)
             #GuidValue.update(M.Guids)
@@ -899,7 +923,42 @@
                 if PcdFromModule.DatumType == "VOID*" and 
PcdFromModule.MaxDatumSize in [None, '']:
                     NoDatumTypePcdList.add("%s.%s [%s]" % 
(PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, F))
 
+                if M.IsBinaryModule == True:
+                    PcdFromModule.IsFromBinaryInf = True
+                if (PcdFromModule.TokenCName, 
PcdFromModule.TokenSpaceGuidCName) in self.Platform.Pcds.keys():
+                    PcdFromModule.IsFromDsc = True
+                else:
+                    PcdFromModule.IsFromDsc = False
                 if PcdFromModule.Type in GenC.gDynamicPcd or 
PcdFromModule.Type in GenC.gDynamicExPcd:
+                    if F.Path not in FdfModuleList:
+                        # If one of the Source built modules listed in the DSC 
is not listed 
+                        # in FDF modules, and the INF lists a PCD can only use 
the PcdsDynamic 
+                        # access method (it is only listed in the DEC file 
that declares the 
+                        # PCD as PcdsDynamic), then build tool will report 
warning message
+                        # notify the PI that they are attempting to build a 
module that must 
+                        # be included in a flash image in order to be 
functional. These Dynamic 
+                        # PCD will not be added into the Database unless it is 
used by other 
+                        # modules that are included in the FDF file.
+                        if PcdFromModule.Type in GenC.gDynamicPcd and \
+                            PcdFromModule.IsFromBinaryInf == False:
+                            # Print warning message to let the developer make 
a determine.
+                            if PcdFromModule not in PcdNotInDb:
+                                EdkLogger.warn("build",
+                                               "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. " \
+                                               % 
(PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, 
self.Platform.MetaFile.Path),
+                                               File=self.MetaFile, \
+                                               ExtraData=None)
+                                PcdNotInDb.append(PcdFromModule)
+                            continue
+                        # If one of the Source built modules listed in the DSC 
is not listed in 
+                        # FDF modules, and the INF lists a PCD can only use 
the PcdsDynamicEx 
+                        # access method (it is only listed in the DEC file 
that declares the 
+                        # PCD as PcdsDynamicEx), then DO NOT break the build; 
DO NOT add the 
+                        # PCD to the Platform's PCD Database.
+                        if PcdFromModule.Type in GenC.gDynamicExPcd:
+                            if PcdFromModule not in PcdNotInDb:
+                                PcdNotInDb.append(PcdFromModule)
+                            continue
                     #
                     # If a dynamic PCD used by a PEM module/PEI module & DXE 
module,
                     # it should be stored in Pcd PEI database, If a dynamic 
only
@@ -916,6 +975,68 @@
                         self._DynaPcdList_[Index] = PcdFromModule
                 elif PcdFromModule not in self._NonDynaPcdList_:
                     self._NonDynaPcdList_.append(PcdFromModule)
+                elif PcdFromModule in self._NonDynaPcdList_ and 
PcdFromModule.IsFromBinaryInf == True:
+                    Index = self._NonDynaPcdList_.index(PcdFromModule)
+                    if self._NonDynaPcdList_[Index].IsFromBinaryInf == False:
+                        #The PCD from Binary INF will override the same one 
from source INF
+                        self._NonDynaPcdList_.remove 
(self._NonDynaPcdList_[Index])
+                        PcdFromModule.Pending = False
+                        self._NonDynaPcdList_.append (PcdFromModule)
+        # Parse the DynamicEx PCD from the AsBuild INF module list of FDF.
+        DscModuleList = []
+        for ModuleInf in self.Platform.Modules.keys():
+            DscModuleList.append (os.path.normpath(ModuleInf.Path))
+        # add the PCD from modules that listed in FDF but not in DSC to 
Database 
+        for InfName in FdfModuleList:
+            if InfName not in DscModuleList:
+                InfClass = PathClass(InfName)
+                M = self.BuildDatabase[InfClass, self.Arch, self.BuildTarget, 
self.ToolChain]
+                # If a module INF in FDF but not in current arch's DSC module 
list, it must be module (either binary or source) 
+                # for different Arch. PCDs in source module for different Arch 
is already added before, so skip the source module here. 
+                # For binary module, if in current arch, we need to list the 
PCDs into database.   
+                if not M.IsSupportedArch:
+                    continue
+                # Override the module PCD setting by platform setting
+                ModulePcdList = self.ApplyPcdSetting(M, M.Pcds)
+                for PcdFromModule in ModulePcdList:
+                    PcdFromModule.IsFromBinaryInf = True
+                    PcdFromModule.IsFromDsc = False
+                    # Only allow the DynamicEx and Patchable PCD in AsBuild INF
+                    if PcdFromModule.Type not in GenC.gDynamicExPcd and 
PcdFromModule.Type not in TAB_PCDS_PATCHABLE_IN_MODULE:
+                        EdkLogger.error("build", AUTOGEN_ERROR, "PCD setting 
error",
+                                        File=self.MetaFile,
+                                        ExtraData="\n\tExisted %s PCD %s 
in:\n\t\t%s\n"
+                                        % (PcdFromModule.Type, 
PcdFromModule.TokenCName, InfName))
+                    # make sure that the "VOID*" kind of datum has 
MaxDatumSize set
+                    if PcdFromModule.DatumType == "VOID*" and 
PcdFromModule.MaxDatumSize in [None, '']:
+                        NoDatumTypePcdList.add("%s.%s [%s]" % 
(PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, InfName))
+                    if M.ModuleType in ["PEIM", "PEI_CORE"]:
+                        PcdFromModule.Phase = "PEI"
+                    if PcdFromModule not in self._DynaPcdList_ and 
PcdFromModule.Type in GenC.gDynamicExPcd:
+                        self._DynaPcdList_.append(PcdFromModule)
+                    elif PcdFromModule not in self._NonDynaPcdList_ and 
PcdFromModule.Type in TAB_PCDS_PATCHABLE_IN_MODULE:
+                        self._NonDynaPcdList_.append(PcdFromModule)
+                    if PcdFromModule in self._DynaPcdList_ and 
PcdFromModule.Phase == 'PEI' and PcdFromModule.Type in GenC.gDynamicExPcd:
+                        Index = self._DynaPcdList_.index(PcdFromModule)
+                        self._DynaPcdList_[Index].Phase = PcdFromModule.Phase
+                        self._DynaPcdList_[Index].Type = PcdFromModule.Type
+        for PcdFromModule in self._NonDynaPcdList_:
+            # If a PCD is not listed in the DSC file, but binary INF files 
used by 
+            # this platform all (that use this PCD) list the PCD in a 
[PatchPcds] 
+            # section, AND all source INF files used by this platform the 
build 
+            # that use the PCD list the PCD in either a [Pcds] or [PatchPcds] 
+            # section, then the tools must NOT add the PCD to the Platform's 
PCD
+            # Database; the build must assign the access method for this PCD 
as 
+            # PcdsPatchableInModule.
+            if PcdFromModule not in self._DynaPcdList_:
+                continue
+            Index = self._DynaPcdList_.index(PcdFromModule)
+            if PcdFromModule.IsFromDsc == False and \
+                PcdFromModule.Type in TAB_PCDS_PATCHABLE_IN_MODULE and \
+                PcdFromModule.IsFromBinaryInf == True and \
+                self._DynaPcdList_[Index].IsFromBinaryInf == False:
+                Index = self._DynaPcdList_.index(PcdFromModule)
+                self._DynaPcdList_.remove (self._DynaPcdList_[Index])
 
         # print out error information and break the build, if error found
         if len(NoDatumTypePcdList) > 0:
@@ -926,8 +1047,19 @@
                                       % NoDatumTypePcdListString)
         self._NonDynamicPcdList = self._NonDynaPcdList_
         self._DynamicPcdList = self._DynaPcdList_
-        self.AllPcdList = self._NonDynamicPcdList + self._DynamicPcdList
-        
+        # If PCD is listed in a PcdsDynamicHii, PcdsDynamicExHii, 
PcdsDynamicHii or PcdsDynamicExHii
+        # section, and the PCD is not used by any module that is listed in the 
DSC file, the build 
+        # provide a warning message.
+        for PcdKey in self.Platform.Pcds.keys():
+            Pcd = self.Platform.Pcds[PcdKey]
+            if Pcd not in self._DynamicPcdList + PcdNotInDb and \
+                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]:
+                # Print warning message to let the developer make a determine.
+                EdkLogger.warn("build",
+                               "A %s PCD listed in the DSC (%s.%s, %s) is not 
used by any module." \
+                               % (Pcd.Type, Pcd.TokenSpaceGuidCName, 
Pcd.TokenCName, self.Platform.MetaFile.Path),
+                               File=self.MetaFile, \
+                               ExtraData=None)
         #
         # Sort dynamic PCD list to:
         # 1) If PCD's datum type is VOID* and value is unicode string which 
starts with L, the PCD item should 
@@ -1099,7 +1231,7 @@
         self._DynamicPcdList.extend(UnicodePcdArray)
         self._DynamicPcdList.extend(HiiPcdArray)
         self._DynamicPcdList.extend(OtherPcdArray)
-            
+        self.AllPcdList = self._NonDynamicPcdList + self._DynamicPcdList
         
     ## Return the platform build data object
     def _GetPlatform(self):
@@ -1320,7 +1452,14 @@
                 self._PackageList.update(La.DependentPackageList)
             for Ma in self.ModuleAutoGenList:
                 self._PackageList.update(Ma.DependentPackageList)
-            self._PackageList = list(self._PackageList)
+            #Collect package set information from INF of FDF
+            PkgSet = set()
+            for ModuleFile in self._AsBuildModuleList:
+                if ModuleFile in self.Platform.Modules:
+                    continue
+                ModuleData = self.BuildDatabase[ModuleFile, self.Arch, 
self.BuildTarget, self.ToolChain]
+                PkgSet.update(ModuleData.Packages)
+            self._PackageList = list(self._PackageList) + list (PkgSet)
         return self._PackageList
 
     def _GetNonDynamicPcdDict(self):
@@ -1428,7 +1567,8 @@
     #  by the platform or current configuration
     #
     def ValidModule(self, Module):
-        return Module in self.Platform.Modules or Module in 
self.Platform.LibraryInstances
+        return Module in self.Platform.Modules or Module in 
self.Platform.LibraryInstances \
+            or Module in self._AsBuildModuleList
 
     ## Resolve the library classes in a module to library instances
     #
@@ -3020,6 +3160,8 @@
     #                                       dependent libraries will be created
     #
     def CreateMakeFile(self, CreateLibraryMakeFile=True):
+        if self.IsBinaryModule:
+            return
         if self.IsMakeFileCreated:
             return
 
@@ -3040,6 +3182,11 @@
 
         self.IsMakeFileCreated = True
 
+    def CopyBinaryFiles(self):
+        for File in self.Module.Binaries:
+            SrcPath = File.Path
+            DstPath = os.path.join(self.OutputDir , os.path.basename(SrcPath))
+            CopyLongFilePath(SrcPath, DstPath)
     ## Create autogen code for the module and its dependent libraries
     #
     #   @param      CreateLibraryCodeFile   Flag indicating if or not the code 
of
@@ -3053,6 +3200,9 @@
         if self.IsBinaryModule and self.PcdIsDriver != '':
             CreatePcdDatabaseCode(self, TemplateString(), TemplateString())
             return
+        if self.IsBinaryModule:
+            self.CopyBinaryFiles()
+            return
 
         if not self.IsLibrary and CreateLibraryCodeFile:
             for LibraryAutoGen in self.LibraryAutoGenList:

Modified: trunk/edk2/BaseTools/Source/Python/Workspace/BuildClassObject.py
===================================================================
--- trunk/edk2/BaseTools/Source/Python/Workspace/BuildClassObject.py    
2014-08-25 23:10:18 UTC (rev 15892)
+++ trunk/edk2/BaseTools/Source/Python/Workspace/BuildClassObject.py    
2014-08-26 02:52:24 UTC (rev 15893)
@@ -57,6 +57,8 @@
         self.Phase = "DXE"
         self.Pending = False
         self.IsOverrided = IsOverrided
+        self.IsFromBinaryInf = False
+        self.IsFromDsc = False
         
     ## Convert the class to a string
     #

Modified: trunk/edk2/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
===================================================================
--- trunk/edk2/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py   
2014-08-25 23:10:18 UTC (rev 15892)
+++ trunk/edk2/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py   
2014-08-26 02:52:24 UTC (rev 15893)
@@ -2008,7 +2008,7 @@
         return self._Defs
 
     ## Retrieve binary files
-    def _GetBinaryFiles(self):
+    def _GetBinaries(self):
         if self._Binaries == None:
             self._Binaries = []
             RecordList = self._RawData[MODEL_EFI_BINARY_FILE, self._Arch, 
self._Platform]
@@ -2035,6 +2035,20 @@
                 self._Binaries.append(File)
         return self._Binaries
 
+    ## Retrieve binary files with error check.
+    def _GetBinaryFiles(self):
+        Binaries = self._GetBinaries()
+        if GlobalData.gIgnoreSource and Binaries == []:
+            ErrorInfo = "The INF file does not contain any Binaries to use in 
creating the image\n"
+            EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, 
ExtraData=ErrorInfo, File=self.MetaFile)
+
+        return Binaries
+    ## Check whether it exists the binaries with current ARCH in AsBuild INF
+    def _IsSupportedArch(self):
+        if self._GetBinaries() and not self._GetSourceFiles():
+            return True
+        else:
+            return False
     ## Retrieve source files
     def _GetSourceFiles(self):
         if self._Sources == None:
@@ -2537,6 +2551,7 @@
     Depex                   = property(_GetDepex)
     DepexExpression         = property(_GetDepexExpression)
     IsBinaryModule = property(_IsBinaryModule)
+    IsSupportedArch = property(_IsSupportedArch)
 
 ## Database
 #

Modified: trunk/edk2/BaseTools/Source/Python/build/build.py
===================================================================
--- trunk/edk2/BaseTools/Source/Python/build/build.py   2014-08-25 23:10:18 UTC 
(rev 15892)
+++ trunk/edk2/BaseTools/Source/Python/build/build.py   2014-08-26 02:52:24 UTC 
(rev 15893)
@@ -744,6 +744,7 @@
         self.Platform       = None
         self.LoadFixAddress = 0
         self.UniFlag        = BuildOptions.Flag
+        self.BuildModules = []
 
         # print dot character during doing some time-consuming work
         self.Progress = Utils.Progressor()
@@ -929,6 +930,7 @@
         if BuildModule:
             BuildCommand = BuildCommand + [Target]
             LaunchCommand(BuildCommand, AutoGenObject.MakeFileDir)
+            self.CreateAsBuiltInf()
             return True
 
         # build library
@@ -946,6 +948,7 @@
             for Mod in AutoGenObject.ModuleBuildDirectoryList:
                 NewBuildCommand = BuildCommand + ['-f', 
os.path.normpath(os.path.join(Mod, makefile)), 'pbuild']
                 LaunchCommand(NewBuildCommand, AutoGenObject.MakeFileDir)
+            self.CreateAsBuiltInf()
             return True
 
         # cleanlib
@@ -1055,6 +1058,7 @@
         BuildCommand = BuildCommand + [Target]
         if BuildModule:
             LaunchCommand(BuildCommand, AutoGenObject.MakeFileDir)
+            self.CreateAsBuiltInf()
             return True
 
         # build library
@@ -1407,6 +1411,12 @@
                 for Arch in Wa.ArchList:
                     GlobalData.gGlobalDefines['ARCH'] = Arch
                     Pa = PlatformAutoGen(Wa, self.PlatformFile, BuildTarget, 
ToolChain, Arch)
+                    for Module in Pa.Platform.Modules:
+                        # Get ModuleAutoGen object to generate C code file and 
makefile
+                        Ma = ModuleAutoGen(Wa, Module, BuildTarget, ToolChain, 
Arch, self.PlatformFile)
+                        if Ma == None:
+                            continue
+                        self.BuildModules.append(Ma)
                     self._BuildPa(self.Target, Pa)
 
                 # Create MAP file when Load Fix Address is enabled.
@@ -1490,6 +1500,7 @@
                     Ma = ModuleAutoGen(Wa, self.ModuleFile, BuildTarget, 
ToolChain, Arch, self.PlatformFile)
                     if Ma == None: continue
                     MaList.append(Ma)
+                    self.BuildModules.append(Ma)
                     if not Ma.IsBinaryModule:
                         self._Build(self.Target, Ma, BuildModule=True)
 
@@ -1580,10 +1591,20 @@
                     Pa = PlatformAutoGen(Wa, self.PlatformFile, BuildTarget, 
ToolChain, Arch)
                     if Pa == None:
                         continue
-                    pModules = []
-                    for Module in Pa.Platform.Modules:
+                    ModuleList = []
+                    for Inf in Pa.Platform.Modules:
+                        ModuleList.append(Inf)
+                    # Add the INF only list in FDF
+                    if GlobalData.gFdfParser != 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)
+                    for Module in ModuleList:
                         # Get ModuleAutoGen object to generate C code file and 
makefile
                         Ma = ModuleAutoGen(Wa, Module, BuildTarget, ToolChain, 
Arch, self.PlatformFile)
+                        
                         if Ma == None:
                             continue
                         # Not to auto-gen for targets 'clean', 'cleanlib', 
'cleanall', 'run', 'fds'
@@ -1596,15 +1617,15 @@
 
                             if not self.SkipAutoGen or self.Target == 
'genmake':
                                 Ma.CreateMakeFile(True)
-                                Ma.CreateAsBuiltInf()
                             if self.Target == "genmake":
                                 continue
-                        pModules.append(Ma)
+                        self.BuildModules.append(Ma)
                     self.Progress.Stop("done!")
 
-                    for Ma in pModules:
+                    for Ma in self.BuildModules:
                         # Generate build task for the module
-                        Bt = BuildTask.New(ModuleMakeUnit(Ma, self.Target))
+                        if not Ma.IsBinaryModule:
+                            Bt = BuildTask.New(ModuleMakeUnit(Ma, self.Target))
                         # Break build if any build thread has error
                         if BuildTask.HasError():
                             # we need a full version of makefile for platform
@@ -1635,6 +1656,7 @@
                 #
                 ExitFlag.set()
                 BuildTask.WaitForComplete()
+                self.CreateAsBuiltInf()
 
                 #
                 # Check for build error, and raise exception if one
@@ -1765,6 +1787,10 @@
             self.SpawnMode = False
             self._BuildModule()
 
+    def CreateAsBuiltInf(self):
+        for Module in self.BuildModules:
+            Module.CreateAsBuiltInf()
+        self.BuildModules = []
     ## Do some clean-up works when error occurred
     def Relinquish(self):
         OldLogLevel = EdkLogger.GetLevel()

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to