Home | History | Annotate | Download | only in Workspace
      1 ## @file

      2 # This file is used to define each component of the build database

      3 #

      4 # Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>

      5 # This program and the accompanying materials

      6 # are licensed and made available under the terms and conditions of the BSD License

      7 # which accompanies this distribution.  The full text of the license may be found at

      8 # http://opensource.org/licenses/bsd-license.php

      9 #

     10 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,

     11 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

     12 #

     13 
     14 import Common.LongFilePathOs as os
     15 
     16 from Common.Misc import sdict
     17 from Common.Misc import RealPath2
     18 from Common.BuildToolError import *
     19 
     20 ## PcdClassObject

     21 #

     22 # This Class is used for PcdObject

     23 #

     24 # @param object:             Inherited from object class

     25 # @param Name:               Input value for Name of Pcd, default is None

     26 # @param Guid:               Input value for Guid of Pcd, default is None

     27 # @param Type:               Input value for Type of Pcd, default is None

     28 # @param DatumType:          Input value for DatumType of Pcd, default is None

     29 # @param Value:              Input value for Value of Pcd, default is None

     30 # @param Token:              Input value for Token of Pcd, default is None

     31 # @param MaxDatumSize:       Input value for MaxDatumSize of Pcd, default is None

     32 # @param SkuInfoList:        Input value for SkuInfoList of Pcd, default is {}

     33 # @param IsOverrided:        Input value for IsOverrided of Pcd, default is False

     34 # @param GuidValue:          Input value for TokenSpaceGuidValue of Pcd, default is None

     35 #

     36 # @var TokenCName:           To store value for TokenCName

     37 # @var TokenSpaceGuidCName:  To store value for TokenSpaceGuidCName

     38 # @var Type:                 To store value for Type

     39 # @var DatumType:            To store value for DatumType

     40 # @var TokenValue:           To store value for TokenValue

     41 # @var MaxDatumSize:         To store value for MaxDatumSize

     42 # @var SkuInfoList:          To store value for SkuInfoList

     43 # @var IsOverrided:          To store value for IsOverrided

     44 # @var Phase:                To store value for Phase, default is "DXE"

     45 #

     46 class PcdClassObject(object):
     47     def __init__(self, Name = None, Guid = None, Type = None, DatumType = None, Value = None, Token = None, MaxDatumSize = None, SkuInfoList = {}, IsOverrided = False, GuidValue = None, validateranges = [], validlists = [], expressions = []):
     48         self.TokenCName = Name
     49         self.TokenSpaceGuidCName = Guid
     50         self.TokenSpaceGuidValue = GuidValue
     51         self.Type = Type
     52         self.DatumType = DatumType
     53         self.DefaultValue = Value
     54         self.TokenValue = Token
     55         self.MaxDatumSize = MaxDatumSize
     56         self.SkuInfoList = SkuInfoList
     57         self.Phase = "DXE"
     58         self.Pending = False
     59         self.IsOverrided = IsOverrided
     60         self.IsFromBinaryInf = False
     61         self.IsFromDsc = False
     62         self.validateranges = validateranges
     63         self.validlists = validlists
     64         self.expressions = expressions
     65         
     66     ## Convert the class to a string

     67     #

     68     #  Convert each member of the class to string

     69     #  Organize to a signle line format string

     70     #

     71     #  @retval Rtn Formatted String

     72     #

     73     def __str__(self):
     74         Rtn = '\tTokenCName=' + str(self.TokenCName) + ', ' + \
     75               'TokenSpaceGuidCName=' + str(self.TokenSpaceGuidCName) + ', ' + \
     76               'Type=' + str(self.Type) + ', ' + \
     77               'DatumType=' + str(self.DatumType) + ', ' + \
     78               'DefaultValue=' + str(self.DefaultValue) + ', ' + \
     79               'TokenValue=' + str(self.TokenValue) + ', ' + \
     80               'MaxDatumSize=' + str(self.MaxDatumSize) + ', '
     81         for Item in self.SkuInfoList.values():
     82             Rtn = Rtn + 'SkuId=' + Item.SkuId + ', ' + 'SkuIdName=' + Item.SkuIdName
     83         Rtn = Rtn + ', IsOverrided=' + str(self.IsOverrided)
     84 
     85         return Rtn
     86 
     87     ## Override __eq__ function

     88     #

     89     # Check whether pcds are the same

     90     #

     91     # @retval False The two pcds are different

     92     # @retval True  The two pcds are the same

     93     #

     94     def __eq__(self, Other):
     95         return Other and self.TokenCName == Other.TokenCName and self.TokenSpaceGuidCName == Other.TokenSpaceGuidCName
     96 
     97     ## Override __hash__ function

     98     #

     99     # Use (TokenCName, TokenSpaceGuidCName) as key in hash table

    100     #

    101     # @retval truple() Key for hash table

    102     #

    103     def __hash__(self):
    104         return hash((self.TokenCName, self.TokenSpaceGuidCName))
    105 
    106 ## LibraryClassObject

    107 #

    108 # This Class defines LibraryClassObject used in BuildDatabase

    109 #

    110 # @param object:      Inherited from object class

    111 # @param Name:        Input value for LibraryClassName, default is None

    112 # @param SupModList:  Input value for SupModList, default is []

    113 # @param Type:        Input value for Type, default is None

    114 #

    115 # @var LibraryClass:  To store value for LibraryClass

    116 # @var SupModList:    To store value for SupModList

    117 # @var Type:          To store value for Type

    118 #

    119 class LibraryClassObject(object):
    120     def __init__(self, Name = None, SupModList = [], Type = None):
    121         self.LibraryClass = Name
    122         self.SupModList = SupModList
    123         if Type != None:
    124             self.SupModList = CleanString(Type).split(DataType.TAB_SPACE_SPLIT)
    125 
    126 ## ModuleBuildClassObject

    127 #

    128 # This Class defines ModuleBuildClass

    129 #

    130 # @param object:               Inherited from object class

    131 #

    132 # @var MetaFile:              To store value for module meta file path

    133 # @var BaseName:               To store value for BaseName

    134 # @var ModuleType:             To store value for ModuleType

    135 # @var Guid:                   To store value for Guid

    136 # @var Version:                To store value for Version

    137 # @var PcdIsDriver:            To store value for PcdIsDriver

    138 # @var BinaryModule:           To store value for BinaryModule

    139 # @var CustomMakefile:         To store value for CustomMakefile

    140 # @var Specification:          To store value for Specification

    141 # @var Shadow                  To store value for Shadow

    142 # @var LibraryClass:           To store value for LibraryClass, it is a list structure as

    143 #                              [ LibraryClassObject, ...]

    144 # @var ModuleEntryPointList:   To store value for ModuleEntryPointList

    145 # @var ModuleUnloadImageList:  To store value for ModuleUnloadImageList

    146 # @var ConstructorList:        To store value for ConstructorList

    147 # @var DestructorList:         To store value for DestructorList

    148 # @var Binaries:               To store value for Binaries, it is a list structure as

    149 #                              [ ModuleBinaryClassObject, ...]

    150 # @var Sources:                To store value for Sources, it is a list structure as

    151 #                              [ ModuleSourceFilesClassObject, ... ]

    152 # @var LibraryClasses:         To store value for LibraryClasses, it is a set structure as

    153 #                              { [LibraryClassName, ModuleType] : LibraryClassInfFile }

    154 # @var Protocols:              To store value for Protocols, it is a list structure as

    155 #                              [ ProtocolName, ... ]

    156 # @var Ppis:                   To store value for Ppis, it is a list structure as

    157 #                              [ PpiName, ... ]

    158 # @var Guids:                  To store value for Guids, it is a list structure as

    159 #                              [ GuidName, ... ]

    160 # @var Includes:               To store value for Includes, it is a list structure as

    161 #                              [ IncludePath, ... ]

    162 # @var Packages:               To store value for Packages, it is a list structure as

    163 #                              [ DecFileName, ... ]

    164 # @var Pcds:                   To store value for Pcds, it is a set structure as

    165 #                              { [(PcdCName, PcdGuidCName)] : PcdClassObject}

    166 # @var BuildOptions:           To store value for BuildOptions, it is a set structure as

    167 #                              { [BuildOptionKey] : BuildOptionValue}

    168 # @var Depex:                  To store value for Depex

    169 #

    170 class ModuleBuildClassObject(object):
    171     def __init__(self):
    172         self.AutoGenVersion          = 0
    173         self.MetaFile                = ''
    174         self.BaseName                = ''
    175         self.ModuleType              = ''
    176         self.Guid                    = ''
    177         self.Version                 = ''
    178         self.PcdIsDriver             = ''
    179         self.BinaryModule            = ''
    180         self.Shadow                  = ''
    181         self.SourceOverridePath      = ''
    182         self.CustomMakefile          = {}
    183         self.Specification           = {}
    184         self.LibraryClass            = []
    185         self.ModuleEntryPointList    = []
    186         self.ModuleUnloadImageList   = []
    187         self.ConstructorList         = []
    188         self.DestructorList          = []
    189 
    190         self.Binaries                = []
    191         self.Sources                 = []
    192         self.LibraryClasses          = sdict()
    193         self.Libraries               = []
    194         self.Protocols               = []
    195         self.Ppis                    = []
    196         self.Guids                   = []
    197         self.Includes                = []
    198         self.Packages                = []
    199         self.Pcds                    = {}
    200         self.BuildOptions            = {}
    201         self.Depex                   = {}
    202 
    203     ## Convert the class to a string

    204     #

    205     #  Convert member MetaFile of the class to a string

    206     #

    207     #  @retval string Formatted String

    208     #

    209     def __str__(self):
    210         return str(self.MetaFile)
    211 
    212     ## Override __eq__ function

    213     #

    214     # Check whether ModuleBuildClassObjects are the same

    215     #

    216     # @retval False The two ModuleBuildClassObjects are different

    217     # @retval True  The two ModuleBuildClassObjects are the same

    218     #

    219     def __eq__(self, Other):
    220         return self.MetaFile == Other
    221 
    222     ## Override __hash__ function

    223     #

    224     # Use MetaFile as key in hash table

    225     #

    226     # @retval string Key for hash table

    227     #

    228     def __hash__(self):
    229         return hash(self.MetaFile)
    230 
    231 ## PackageBuildClassObject

    232 #

    233 # This Class defines PackageBuildClass

    234 #

    235 # @param object:        Inherited from object class

    236 #

    237 # @var MetaFile:       To store value for package meta file path

    238 # @var PackageName:     To store value for PackageName

    239 # @var Guid:            To store value for Guid

    240 # @var Version:         To store value for Version

    241 # @var Protocols:       To store value for Protocols, it is a set structure as

    242 #                       { [ProtocolName] : Protocol Guid, ... }

    243 # @var Ppis:            To store value for Ppis, it is a set structure as

    244 #                       { [PpiName] : Ppi Guid, ... }

    245 # @var Guids:           To store value for Guids, it is a set structure as

    246 #                       { [GuidName] : Guid, ... }

    247 # @var Includes:        To store value for Includes, it is a list structure as

    248 #                       [ IncludePath, ... ]

    249 # @var LibraryClasses:  To store value for LibraryClasses, it is a set structure as

    250 #                       { [LibraryClassName] : LibraryClassInfFile }

    251 # @var Pcds:            To store value for Pcds, it is a set structure as

    252 #                       { [(PcdCName, PcdGuidCName)] : PcdClassObject}

    253 #

    254 class PackageBuildClassObject(object):
    255     def __init__(self):
    256         self.MetaFile                = ''
    257         self.PackageName             = ''
    258         self.Guid                    = ''
    259         self.Version                 = ''
    260 
    261         self.Protocols               = {}
    262         self.Ppis                    = {}
    263         self.Guids                   = {}
    264         self.Includes                = []
    265         self.LibraryClasses          = {}
    266         self.Pcds                    = {}
    267 
    268     ## Convert the class to a string

    269     #

    270     #  Convert member MetaFile of the class to a string

    271     #

    272     #  @retval string Formatted String

    273     #

    274     def __str__(self):
    275         return str(self.MetaFile)
    276 
    277     ## Override __eq__ function

    278     #

    279     # Check whether PackageBuildClassObjects are the same

    280     #

    281     # @retval False The two PackageBuildClassObjects are different

    282     # @retval True  The two PackageBuildClassObjects are the same

    283     #

    284     def __eq__(self, Other):
    285         return self.MetaFile == Other
    286 
    287     ## Override __hash__ function

    288     #

    289     # Use MetaFile as key in hash table

    290     #

    291     # @retval string Key for hash table

    292     #

    293     def __hash__(self):
    294         return hash(self.MetaFile)
    295 
    296 ## PlatformBuildClassObject

    297 #

    298 # This Class defines PlatformBuildClass

    299 #

    300 # @param object:          Inherited from object class

    301 #

    302 # @var MetaFile:         To store value for platform meta-file path

    303 # @var PlatformName:      To store value for PlatformName

    304 # @var Guid:              To store value for Guid

    305 # @var Version:           To store value for Version

    306 # @var DscSpecification:  To store value for DscSpecification

    307 # @var OutputDirectory:   To store value for OutputDirectory

    308 # @var FlashDefinition:   To store value for FlashDefinition

    309 # @var BuildNumber:       To store value for BuildNumber

    310 # @var MakefileName:      To store value for MakefileName

    311 # @var SkuIds:            To store value for SkuIds, it is a set structure as

    312 #                         { 'SkuName' : SkuId, '!include' : includefilename, ...}

    313 # @var Modules:           To store value for Modules, it is a list structure as

    314 #                         [ InfFileName, ... ]

    315 # @var Libraries:         To store value for Libraries, it is a list structure as

    316 #                         [ InfFileName, ... ]

    317 # @var LibraryClasses:    To store value for LibraryClasses, it is a set structure as

    318 #                         { (LibraryClassName, ModuleType) : LibraryClassInfFile }

    319 # @var Pcds:              To store value for Pcds, it is a set structure as

    320 #                         { [(PcdCName, PcdGuidCName)] : PcdClassObject }

    321 # @var BuildOptions:      To store value for BuildOptions, it is a set structure as

    322 #                         { [BuildOptionKey] : BuildOptionValue }

    323 #

    324 class PlatformBuildClassObject(object):
    325     def __init__(self):
    326         self.MetaFile                = ''
    327         self.PlatformName            = ''
    328         self.Guid                    = ''
    329         self.Version                 = ''
    330         self.DscSpecification        = ''
    331         self.OutputDirectory         = ''
    332         self.FlashDefinition         = ''
    333         self.BuildNumber             = ''
    334         self.MakefileName            = ''
    335 
    336         self.SkuIds                  = {}
    337         self.Modules                 = []
    338         self.LibraryInstances        = []
    339         self.LibraryClasses          = {}
    340         self.Libraries               = {}
    341         self.Pcds                    = {}
    342         self.BuildOptions            = {}
    343 
    344     ## Convert the class to a string

    345     #

    346     #  Convert member MetaFile of the class to a string

    347     #

    348     #  @retval string Formatted String

    349     #

    350     def __str__(self):
    351         return str(self.MetaFile)
    352 
    353     ## Override __eq__ function

    354     #

    355     # Check whether PlatformBuildClassObjects are the same

    356     #

    357     # @retval False The two PlatformBuildClassObjects are different

    358     # @retval True  The two PlatformBuildClassObjects are the same

    359     #

    360     def __eq__(self, Other):
    361         return self.MetaFile == Other
    362 
    363     ## Override __hash__ function

    364     #

    365     # Use MetaFile as key in hash table

    366     #

    367     # @retval string Key for hash table

    368     #

    369     def __hash__(self):
    370         return hash(self.MetaFile)
    371 
    372