]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/GenFds/DepexSection.py
2 # process depex section generation
4 # Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
6 # This program and the accompanying materials
7 # are licensed and made available under the terms and conditions of the BSD License
8 # which accompanies this distribution. The full text of the license may be found at
9 # http://opensource.org/licenses/bsd-license.php
11 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 from GenFdsGlobalVariable
import GenFdsGlobalVariable
22 import Common
.LongFilePathOs
as os
23 from CommonDataClass
.FdfClass
import DepexSectionClassObject
24 from AutoGen
.GenDepex
import DependencyExpression
25 from Common
import EdkLogger
26 from Common
.BuildToolError
import *
28 ## generate data section
31 class DepexSection (DepexSectionClassObject
):
34 # @param self The object pointer
37 DepexSectionClassObject
.__init
__(self
)
39 def __FindGuidValue(self
, CName
):
40 for Arch
in GenFdsGlobalVariable
.ArchList
:
41 for PkgDb
in GenFdsGlobalVariable
.WorkSpace
.GetPackageList(GenFdsGlobalVariable
.ActivePlatform
,
43 GenFdsGlobalVariable
.TargetName
,
44 GenFdsGlobalVariable
.ToolChainTag
):
45 if CName
in PkgDb
.Ppis
:
46 return PkgDb
.Ppis
[CName
]
47 if CName
in PkgDb
.Protocols
:
48 return PkgDb
.Protocols
[CName
]
49 if CName
in PkgDb
.Guids
:
50 return PkgDb
.Guids
[CName
]
53 ## GenSection() method
55 # Generate compressed section
57 # @param self The object pointer
58 # @param OutputPath Where to place output file
59 # @param ModuleName Which module this section belongs to
60 # @param SecNum Index of section
61 # @param KeyStringList Filter for inputs of section generation
62 # @param FfsInf FfsInfStatement object that contains this section data
63 # @param Dict dictionary contains macro and its value
64 # @retval tuple (Generated file name list, section alignment)
66 def GenSection(self
, OutputPath
, ModuleName
, SecNum
, keyStringList
, FfsFile
= None, Dict
= {}):
68 if self
.ExpressionProcessed
== False:
69 self
.Expression
= self
.Expression
.replace("\n", " ").replace("\r", " ")
70 ExpList
= self
.Expression
.split()
74 if Exp
.upper() not in ('AND', 'OR', 'NOT', 'TRUE', 'FALSE', 'SOR', 'BEFORE', 'AFTER', 'END'):
75 GuidStr
= self
.__FindGuidValue
(Exp
)
77 EdkLogger
.error("GenFds", RESOURCE_NOT_AVAILABLE
,
78 "Depex GUID %s could not be found in build DB! (ModuleName: %s)" % (Exp
, ModuleName
))
80 ExpGuidDict
[Exp
] = GuidStr
82 for Item
in ExpGuidDict
:
83 self
.Expression
= self
.Expression
.replace(Item
, ExpGuidDict
[Item
])
85 self
.Expression
= self
.Expression
.strip()
86 self
.ExpressionProcessed
= True
88 if self
.DepexType
== 'PEI_DEPEX_EXP':
91 elif self
.DepexType
== 'DXE_DEPEX_EXP':
92 ModuleType
= 'DXE_DRIVER'
94 elif self
.DepexType
== 'SMM_DEPEX_EXP':
95 ModuleType
= 'DXE_SMM_DRIVER'
98 EdkLogger
.error("GenFds", FORMAT_INVALID
,
99 "Depex type %s is not valid for module %s" % (self
.DepexType
, ModuleName
))
101 InputFile
= os
.path
.join (OutputPath
, ModuleName
+ 'SEC' + SecNum
+ '.depex')
102 InputFile
= os
.path
.normpath(InputFile
)
103 Depex
= DependencyExpression(self
.Expression
, ModuleType
)
104 Depex
.Generate(InputFile
)
106 OutputFile
= os
.path
.join (OutputPath
, ModuleName
+ 'SEC' + SecNum
+ '.dpx')
107 OutputFile
= os
.path
.normpath(OutputFile
)
109 GenFdsGlobalVariable
.GenerateSection(OutputFile
, [InputFile
], Section
.Section
.SectionType
.get (SecType
))
110 FileList
= [OutputFile
]
111 return FileList
, self
.Alignment