]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/GenFds/DepexSection.py
b7b1ae7d93afdb61c93b2fc892d1002f1d92c9da
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
.GetPackageList(GenFdsGlobalVariable
.ActivePlatform
,
44 GenFdsGlobalVariable
.TargetName
,
45 GenFdsGlobalVariable
.ToolChainTag
):
46 if CName
in PkgDb
.Ppis
:
47 return PkgDb
.Ppis
[CName
]
48 if CName
in PkgDb
.Protocols
:
49 return PkgDb
.Protocols
[CName
]
50 if CName
in PkgDb
.Guids
:
51 return PkgDb
.Guids
[CName
]
54 ## GenSection() method
56 # Generate compressed section
58 # @param self The object pointer
59 # @param OutputPath Where to place output file
60 # @param ModuleName Which module this section belongs to
61 # @param SecNum Index of section
62 # @param KeyStringList Filter for inputs of section generation
63 # @param FfsInf FfsInfStatement object that contains this section data
64 # @param Dict dictionary contains macro and its value
65 # @retval tuple (Generated file name list, section alignment)
67 def GenSection(self
, OutputPath
, ModuleName
, SecNum
, keyStringList
, FfsFile
= None, Dict
= {}):
69 if self
.ExpressionProcessed
== False:
70 self
.Expression
= self
.Expression
.replace("\n", " ").replace("\r", " ")
71 ExpList
= self
.Expression
.split()
75 if Exp
.upper() not in ('AND', 'OR', 'NOT', 'TRUE', 'FALSE', 'SOR', 'BEFORE', 'AFTER', 'END'):
76 GuidStr
= self
.__FindGuidValue
(Exp
)
78 EdkLogger
.error("GenFds", RESOURCE_NOT_AVAILABLE
,
79 "Depex GUID %s could not be found in build DB! (ModuleName: %s)" % (Exp
, ModuleName
))
81 ExpGuidDict
[Exp
] = GuidStr
83 for Item
in ExpGuidDict
:
84 self
.Expression
= self
.Expression
.replace(Item
, ExpGuidDict
[Item
])
86 self
.Expression
= self
.Expression
.strip()
87 self
.ExpressionProcessed
= True
89 if self
.DepexType
== 'PEI_DEPEX_EXP':
92 elif self
.DepexType
== 'DXE_DEPEX_EXP':
93 ModuleType
= 'DXE_DRIVER'
95 elif self
.DepexType
== 'SMM_DEPEX_EXP':
96 ModuleType
= 'DXE_SMM_DRIVER'
99 EdkLogger
.error("GenFds", FORMAT_INVALID
,
100 "Depex type %s is not valid for module %s" % (self
.DepexType
, ModuleName
))
102 InputFile
= os
.path
.join (OutputPath
, ModuleName
+ 'SEC' + SecNum
+ '.depex')
103 InputFile
= os
.path
.normpath(InputFile
)
104 Depex
= DependencyExpression(self
.Expression
, ModuleType
)
105 Depex
.Generate(InputFile
)
107 OutputFile
= os
.path
.join (OutputPath
, ModuleName
+ 'SEC' + SecNum
+ '.dpx')
108 OutputFile
= os
.path
.normpath(OutputFile
)
110 GenFdsGlobalVariable
.GenerateSection(OutputFile
, [InputFile
], Section
.Section
.SectionType
.get (SecType
))
111 FileList
= [OutputFile
]
112 return FileList
, self
.Alignment