1. Support BuildRuleFamily attribute of tool chain tag to be filtered build rule.
authorlgao4 <lgao4@7335b38e-4728-0410-8992-fb3ffe349368>
Mon, 6 Jul 2009 09:52:43 +0000 (09:52 +0000)
committerlgao4 <lgao4@7335b38e-4728-0410-8992-fb3ffe349368>
Mon, 6 Jul 2009 09:52:43 +0000 (09:52 +0000)
2. Enhance GenFds tool to get the default PcdValue from DEC file.
3. Enhance AutoGen to generate library function constructors for SEC type module.

git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@1637 7335b38e-4728-0410-8992-fb3ffe349368

Source/Python/AutoGen/AutoGen.py
Source/Python/AutoGen/GenC.py
Source/Python/AutoGen/UniClassObject.py
Source/Python/Common/DataType.py
Source/Python/Common/ToolDefClassObject.py
Source/Python/GenFds/GenFds.py
Source/Python/GenFds/GenFdsGlobalVariable.py
Source/Python/GenFds/OptionRom.py

index f01e43e..57d9342 100755 (executable)
@@ -378,7 +378,8 @@ class PlatformAutoGen(AutoGen):
         self._ToolDefinitions = None
         self._ToolDefFile = None          # toolcode : tool path
         self._ToolChainFamily = None
-        self._BuildOption = None       # toolcode : option
+        self._BuildRuleFamily = None
+        self._BuildOption = None          # toolcode : option
         self._PackageList = None
         self._ModuleAutoGenList  = None
         self._LibraryAutoGenList = None
@@ -668,6 +669,19 @@ class PlatformAutoGen(AutoGen):
                 self._ToolChainFamily = ToolDefinition[TAB_TOD_DEFINES_FAMILY][self.ToolChain]
         return self._ToolChainFamily
 
+    def _GetBuildRuleFamily(self):
+        if self._BuildRuleFamily == None:
+            ToolDefinition = self.Workspace.ToolDef.ToolsDefTxtDatabase
+            if TAB_TOD_DEFINES_BUILDRULEFAMILY not in ToolDefinition \
+               or self.ToolChain not in ToolDefinition[TAB_TOD_DEFINES_BUILDRULEFAMILY] \
+               or not ToolDefinition[TAB_TOD_DEFINES_BUILDRULEFAMILY][self.ToolChain]:
+                EdkLogger.verbose("No tool chain family found in configuration for %s. Default to MSFT." \
+                                   % self.ToolChain)
+                self._BuildRuleFamily = "MSFT"
+            else:
+                self._BuildRuleFamily = ToolDefinition[TAB_TOD_DEFINES_BUILDRULEFAMILY][self.ToolChain]
+        return self._BuildRuleFamily
+
     ## Return the build options specific to this platform
     def _GetBuildOptions(self):
         if self._BuildOption == None:
@@ -1148,6 +1162,7 @@ class PlatformAutoGen(AutoGen):
     ToolDefinition      = property(_GetToolDefinition)    # toolcode : tool path
     ToolDefinitionFile  = property(_GetToolDefFile)    # toolcode : lib path
     ToolChainFamily     = property(_GetToolChainFamily)
+    BuildRuleFamily     = property(_GetBuildRuleFamily)
     BuildOption         = property(_GetBuildOptions)    # toolcode : option
 
     BuildCommand        = property(_GetBuildCommand)
@@ -1200,6 +1215,7 @@ class ModuleAutoGen(AutoGen):
         self.BuildTarget = Target
         self.Arch = Arch
         self.ToolChainFamily = self.PlatformInfo.ToolChainFamily
+        self.BuildRuleFamily = self.PlatformInfo.BuildRuleFamily
 
         self.IsMakeFileCreated = False
         self.IsCodeFileCreated = False
@@ -1520,11 +1536,11 @@ class ModuleAutoGen(AutoGen):
             BuildRules = {}
             BuildRuleDatabase = self.PlatformInfo.BuildRule
             for Type in BuildRuleDatabase.FileTypeList:
-                RuleObject = BuildRuleDatabase[Type, self.BuildType, self.Arch, self.ToolChainFamily]
+                RuleObject = BuildRuleDatabase[Type, self.BuildType, self.Arch, self.BuildRuleFamily]
                 if not RuleObject:
                     # build type is always module type, but ...
                     if self.ModuleType != self.BuildType:
-                        RuleObject = BuildRuleDatabase[Type, self.ModuleType, self.Arch, self.ToolChainFamily]
+                        RuleObject = BuildRuleDatabase[Type, self.ModuleType, self.Arch, self.BuildRuleFamily]
                     if not RuleObject:
                         continue
                 RuleObject = RuleObject.Instantiate(self.Macros)
index 36d9755..90742d5 100644 (file)
@@ -1484,7 +1484,7 @@ def CreateLibraryConstructorCode(Info, AutoGenC, AutoGenH):
         if len(Lib.ConstructorList) <= 0:
             continue
         Dict = {'Function':Lib.ConstructorList}
-        if Lib.ModuleType == 'BASE':
+        if Lib.ModuleType in ['BASE', 'SEC']:
             ConstructorPrototypeString.Append(gLibraryStructorPrototype['BASE'].Replace(Dict))
             ConstructorCallingString.Append(gLibraryStructorCall['BASE'].Replace(Dict))
         elif Lib.ModuleType in ['PEI_CORE','PEIM']:
@@ -1512,7 +1512,7 @@ def CreateLibraryConstructorCode(Info, AutoGenC, AutoGenH):
     if Info.IsLibrary:
         AutoGenH.Append("${BEGIN}${FunctionPrototype}${END}", Dict)
     else:
-        if Info.ModuleType == 'BASE':
+        if Info.ModuleType in ['BASE', 'SEC']:
             AutoGenC.Append(gLibraryString['BASE'].Replace(Dict))
         elif Info.ModuleType in ['PEI_CORE','PEIM']:
             AutoGenC.Append(gLibraryString['PEI'].Replace(Dict))
@@ -1541,7 +1541,7 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH):
         if len(Lib.DestructorList) <= 0:
             continue
         Dict = {'Function':Lib.DestructorList}
-        if Lib.ModuleType == 'BASE':
+        if Lib.ModuleType in ['BASE', 'SEC']:
             DestructorPrototypeString.Append(gLibraryStructorPrototype['BASE'].Replace(Dict))
             DestructorCallingString.Append(gLibraryStructorCall['BASE'].Replace(Dict))
         elif Lib.ModuleType in ['PEI_CORE','PEIM']:
@@ -1569,7 +1569,7 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH):
     if Info.IsLibrary:
         AutoGenH.Append("${BEGIN}${FunctionPrototype}${END}", Dict)
     else:
-        if Info.ModuleType == 'BASE':
+        if Info.ModuleType in ['BASE', 'SEC']:
             AutoGenC.Append(gLibraryString['BASE'].Replace(Dict))
         elif Info.ModuleType in ['PEI_CORE','PEIM']:
             AutoGenC.Append(gLibraryString['PEI'].Replace(Dict))
@@ -1585,7 +1585,7 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH):
 #   @param      AutoGenH    The TemplateString object for header file
 #
 def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
-    if Info.IsLibrary or Info.ModuleType == "USER_DEFINED":
+    if Info.IsLibrary or Info.ModuleType in ['USER_DEFINED', 'SEC']:
         return
     #
     # Module Entry Points
@@ -1656,7 +1656,7 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
 #   @param      AutoGenH    The TemplateString object for header file
 #
 def CreateModuleUnloadImageCode(Info, AutoGenC, AutoGenH):
-    if Info.IsLibrary or Info.ModuleType == "USER_DEFINED":
+    if Info.IsLibrary or Info.ModuleType in ['USER_DEFINED', 'SEC']:
         return
     #
     # Unload Image Handlers
index ccb2eff..412fa72 100644 (file)
@@ -398,16 +398,16 @@ class UniFileClassObject(object):
     #\r
     def LoadUniFiles(self, FileList = []):\r
         if len(FileList) > 0:\r
-                       if len(FileList) > 1:\r
-                               NewList = [];\r
-                               for File in FileList:\r
-                                       NewList.append (File)\r
-                               NewList.sort()\r
-                               for File in NewList:\r
-                                       self.LoadUniFile(File)\r
-                       else:\r
-                               for File in FileList:\r
-                                       self.LoadUniFile(File)\r
+            if len(FileList) > 1:\r
+                NewList = [];\r
+                for File in FileList:\r
+                    NewList.append (File)\r
+                NewList.sort()\r
+                for File in NewList:\r
+                    self.LoadUniFile(File)\r
+            else:\r
+                for File in FileList:\r
+                    self.LoadUniFile(File)\r
 \r
     #\r
     # Add a string to list\r
index 499065d..6436ba1 100644 (file)
@@ -343,6 +343,7 @@ TAB_TOD_DEFINES_TOOL_CHAIN_TAG = 'TOOL_CHAIN_TAG'
 TAB_TOD_DEFINES_TARGET_ARCH = 'TARGET_ARCH'\r
 TAB_TOD_DEFINES_COMMAND_TYPE = 'COMMAND_TYPE'\r
 TAB_TOD_DEFINES_FAMILY = 'FAMILY'\r
+TAB_TOD_DEFINES_BUILDRULEFAMILY = 'BUILDRULEFAMILY'\r
 \r
 #\r
 # Conditional Statements\r
index 964c209..5a9a309 100755 (executable)
@@ -129,10 +129,19 @@ class ToolDefClassObject(object):
                 if List[4] == TAB_TOD_DEFINES_FAMILY and List[2] == '*' and List[3] == '*':\r
                     if TAB_TOD_DEFINES_FAMILY not in self.ToolsDefTxtDatabase:\r
                         self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_FAMILY] = {}\r
+                        self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_FAMILY][List[1]] = Value\r
+                        self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_BUILDRULEFAMILY] = {}\r
+                        self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_BUILDRULEFAMILY][List[1]] = Value\r
                     elif List[1] not in self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_FAMILY]:\r
                         self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_FAMILY][List[1]] = Value\r
+                        self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_BUILDRULEFAMILY][List[1]] = Value\r
                     elif self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_FAMILY][List[1]] != Value:\r
                         EdkLogger.verbose("Line %d: No override allowed for the family of a tool chain: %s" % ((Index + 1), Name))\r
+                if List[4] == TAB_TOD_DEFINES_BUILDRULEFAMILY and List[2] == '*' and List[3] == '*':\r
+                    if TAB_TOD_DEFINES_BUILDRULEFAMILY not in self.ToolsDefTxtDatabase \\r
+                       or List[1] not in self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_FAMILY]:\r
+                        EdkLogger.verbose("Line %d: The family is not specified, but BuildRuleFamily is specified for the tool chain: %s" % ((Index + 1), Name))\r
+                    self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_BUILDRULEFAMILY][List[1]] = Value\r
 \r
         self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TARGET] = list(set(self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TARGET]))\r
         self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TOOL_CHAIN_TAG] = list(set(self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TOOL_CHAIN_TAG]))\r
index d905605..a559e6b 100644 (file)
@@ -20,7 +20,7 @@ import sys
 import os
 import linecache
 import FdfParser
-from Common import BuildToolError
+from Common.BuildToolError import *
 from GenFdsGlobalVariable import GenFdsGlobalVariable
 from Workspace.WorkspaceDatabase import WorkspaceDatabase
 from Workspace.BuildClassObject import PcdClassObject
index 05b2616..d556ce7 100644 (file)
@@ -21,7 +21,7 @@ import subprocess
 import struct
 import array
 
-from Common import BuildToolError
+from Common.BuildToolError import *
 from Common import EdkLogger
 from Common.Misc import SaveFileOnChange
 
@@ -431,23 +431,36 @@ class GenFdsGlobalVariable:
         PcdPair = PcdPattern.lstrip('PCD(').rstrip(')').strip().split('.')
         TokenSpace = PcdPair[0]
         TokenCName = PcdPair[1]
-        
-        PcdDict = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'COMMON'].Pcds
+
         PcdValue = ''
-        for Key in PcdDict:
-            PcdObj = PcdDict[Key]
-            if (PcdObj.TokenCName == TokenCName) and (PcdObj.TokenSpaceGuidCName == TokenSpace):
-                if PcdObj.Type != 'FixedAtBuild':
-                    EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not FixedAtBuild type." % PcdPattern)
-                if PcdObj.DatumType != 'VOID*':
-                    EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not VOID* datum type." % PcdPattern)
-                    
-                PcdValue = PcdObj.DefaultValue
-                break
+        for Platform in GenFdsGlobalVariable.WorkSpace.PlatformList:
+            PcdDict = Platform.Pcds
+            for Key in PcdDict:
+                PcdObj = PcdDict[Key]
+                if (PcdObj.TokenCName == TokenCName) and (PcdObj.TokenSpaceGuidCName == TokenSpace):
+                    if PcdObj.Type != 'FixedAtBuild':
+                        EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not FixedAtBuild type." % PcdPattern)
+                    if PcdObj.DatumType != 'VOID*':
+                        EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not VOID* datum type." % PcdPattern)
+                        
+                    PcdValue = PcdObj.DefaultValue
+                    return PcdValue
+
+        for Package in GenFdsGlobalVariable.WorkSpace.PackageList:
+            PcdDict = Package.Pcds
+            for Key in PcdDict:
+                PcdObj = PcdDict[Key]
+                if (PcdObj.TokenCName == TokenCName) and (PcdObj.TokenSpaceGuidCName == TokenSpace):
+                    if PcdObj.Type != 'FixedAtBuild':
+                        EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not FixedAtBuild type." % PcdPattern)
+                    if PcdObj.DatumType != 'VOID*':
+                        EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not VOID* datum type." % PcdPattern)
+                        
+                    PcdValue = PcdObj.DefaultValue
+                    return PcdValue
 
         return PcdValue
 
-
     SetDir = staticmethod(SetDir)
     ReplaceWorkspaceMacro = staticmethod(ReplaceWorkspaceMacro)
     CallExternalTool = staticmethod(CallExternalTool)
index 3a00f0f..e102e65 100644 (file)
@@ -25,6 +25,8 @@ from GenFdsGlobalVariable import GenFdsGlobalVariable
 from GenFds import GenFds\r
 from CommonDataClass.FdfClass import OptionRomClassObject\r
 from Common.Misc import SaveFileOnChange\r
+from Common import EdkLogger\r
+from Common.BuildToolError import *\r
 \r
 T_CHAR_LF = '\n'\r
 \r