]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/GenFds/DepexSection.py
2 # process depex section generation
4 # Copyright (c) 2007, 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
23 from CommonDataClass
.FdfClass
import DepexSectionClassObject
24 from AutoGen
.GenDepex
import DependencyExpression
26 from Common
import EdkLogger
27 from Common
.BuildToolError
import *
29 ## generate data section
32 class DepexSection (DepexSectionClassObject
):
35 # @param self The object pointer
38 DepexSectionClassObject
.__init
__(self
)
40 def __FindGuidValue(self
, CName
):
41 for Arch
in GenFdsGlobalVariable
.ArchList
:
42 for PkgDb
in GenFdsGlobalVariable
.WorkSpace
.PackageList
:
43 if CName
in PkgDb
.Ppis
:
44 return PkgDb
.Ppis
[CName
]
45 if CName
in PkgDb
.Protocols
:
46 return PkgDb
.Protocols
[CName
]
47 if CName
in PkgDb
.Guids
:
48 return PkgDb
.Guids
[CName
]
51 ## GenSection() method
53 # Generate compressed section
55 # @param self The object pointer
56 # @param OutputPath Where to place output file
57 # @param ModuleName Which module this section belongs to
58 # @param SecNum Index of section
59 # @param KeyStringList Filter for inputs of section generation
60 # @param FfsInf FfsInfStatement object that contains this section data
61 # @param Dict dictionary contains macro and its value
62 # @retval tuple (Generated file name list, section alignment)
64 def GenSection(self
, OutputPath
, ModuleName
, SecNum
, keyStringList
, FfsFile
= None, Dict
= {}):
66 if self
.ExpressionProcessed
== False:
67 self
.Expression
= self
.Expression
.replace("\n", " ").replace("\r", " ")
68 ExpList
= self
.Expression
.split()
72 if Exp
.upper() not in ('AND', 'OR', 'NOT', 'TRUE', 'FALSE', 'SOR', 'BEFORE', 'AFTER', 'END'):
73 GuidStr
= self
.__FindGuidValue
(Exp
)
75 EdkLogger
.error("GenFds", RESOURCE_NOT_AVAILABLE
,
76 "Depex GUID %s could not be found in build DB! (ModuleName: %s)" % (Exp
, ModuleName
))
78 ExpGuidDict
[Exp
] = GuidStr
80 for Item
in ExpGuidDict
:
81 self
.Expression
= self
.Expression
.replace(Item
, ExpGuidDict
[Item
])
83 self
.Expression
= self
.Expression
.strip()
84 self
.ExpressionProcessed
= True
86 if self
.DepexType
== 'PEI_DEPEX_EXP':
89 elif self
.DepexType
== 'DXE_DEPEX_EXP':
90 ModuleType
= 'DXE_DRIVER'
92 elif self
.DepexType
== 'SMM_DEPEX_EXP':
93 ModuleType
= 'DXE_SMM_DRIVER'
96 EdkLogger
.error("GenFds", FORMAT_INVALID
,
97 "Depex type %s is not valid for module %s" % (self
.DepexType
, ModuleName
))
99 InputFile
= os
.path
.join (OutputPath
, ModuleName
+ 'SEC' + SecNum
+ '.depex')
100 InputFile
= os
.path
.normpath(InputFile
)
101 Depex
= DependencyExpression(self
.Expression
, ModuleType
)
102 Depex
.Generate(InputFile
)
104 OutputFile
= os
.path
.join (OutputPath
, ModuleName
+ 'SEC' + SecNum
+ '.dpx')
105 OutputFile
= os
.path
.normpath(OutputFile
)
107 GenFdsGlobalVariable
.GenerateSection(OutputFile
, [InputFile
], Section
.Section
.SectionType
.get (SecType
))
108 FileList
= [OutputFile
]
109 return FileList
, self
.Alignment