2 # process depex section generation
4 # Copyright (c) 2007 - 2018, 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 *
27 from Common
.Misc
import PathClass
28 from Common
.DataType
import *
30 ## generate data section
33 class DepexSection (DepexSectionClassObject
):
36 # @param self The object pointer
39 DepexSectionClassObject
.__init
__(self
)
41 def __FindGuidValue(self
, CName
):
42 for Arch
in GenFdsGlobalVariable
.ArchList
:
43 PkgList
= GenFdsGlobalVariable
.WorkSpace
.GetPackageList(GenFdsGlobalVariable
.ActivePlatform
,
45 GenFdsGlobalVariable
.TargetName
,
46 GenFdsGlobalVariable
.ToolChainTag
)
47 for Inf
in GenFdsGlobalVariable
.FdfParser
.Profile
.InfList
:
48 ModuleFile
= PathClass(Inf
, GenFdsGlobalVariable
.WorkSpaceDir
)
49 ModuleData
= GenFdsGlobalVariable
.WorkSpace
.BuildObject
[
52 GenFdsGlobalVariable
.TargetName
,
53 GenFdsGlobalVariable
.ToolChainTag
55 for Pkg
in ModuleData
.Packages
:
56 if Pkg
not in PkgList
:
59 if CName
in PkgDb
.Ppis
:
60 return PkgDb
.Ppis
[CName
]
61 if CName
in PkgDb
.Protocols
:
62 return PkgDb
.Protocols
[CName
]
63 if CName
in PkgDb
.Guids
:
64 return PkgDb
.Guids
[CName
]
67 ## GenSection() method
69 # Generate compressed section
71 # @param self The object pointer
72 # @param OutputPath Where to place output file
73 # @param ModuleName Which module this section belongs to
74 # @param SecNum Index of section
75 # @param KeyStringList Filter for inputs of section generation
76 # @param FfsInf FfsInfStatement object that contains this section data
77 # @param Dict dictionary contains macro and its value
78 # @retval tuple (Generated file name list, section alignment)
80 def GenSection(self
, OutputPath
, ModuleName
, SecNum
, keyStringList
, FfsFile
= None, Dict
= None, IsMakefile
= False):
81 if self
.ExpressionProcessed
== False:
82 self
.Expression
= self
.Expression
.replace("\n", " ").replace("\r", " ")
83 ExpList
= self
.Expression
.split()
86 if Exp
.upper() not in ('AND', 'OR', 'NOT', 'TRUE', 'FALSE', 'SOR', 'BEFORE', 'AFTER', 'END'):
87 GuidStr
= self
.__FindGuidValue
(Exp
)
89 EdkLogger
.error("GenFds", RESOURCE_NOT_AVAILABLE
,
90 "Depex GUID %s could not be found in build DB! (ModuleName: %s)" % (Exp
, ModuleName
))
92 self
.Expression
= self
.Expression
.replace(Exp
, GuidStr
)
94 self
.Expression
= self
.Expression
.strip()
95 self
.ExpressionProcessed
= True
97 if self
.DepexType
== 'PEI_DEPEX_EXP':
98 ModuleType
= SUP_MODULE_PEIM
99 SecType
= BINARY_FILE_TYPE_PEI_DEPEX
100 elif self
.DepexType
== 'DXE_DEPEX_EXP':
101 ModuleType
= SUP_MODULE_DXE_DRIVER
102 SecType
= BINARY_FILE_TYPE_DXE_DEPEX
103 elif self
.DepexType
== 'SMM_DEPEX_EXP':
104 ModuleType
= SUP_MODULE_DXE_SMM_DRIVER
105 SecType
= BINARY_FILE_TYPE_SMM_DEPEX
107 EdkLogger
.error("GenFds", FORMAT_INVALID
,
108 "Depex type %s is not valid for module %s" % (self
.DepexType
, ModuleName
))
110 InputFile
= os
.path
.join (OutputPath
, ModuleName
+ SUP_MODULE_SEC
+ SecNum
+ '.depex')
111 InputFile
= os
.path
.normpath(InputFile
)
112 Depex
= DependencyExpression(self
.Expression
, ModuleType
)
113 Depex
.Generate(InputFile
)
115 OutputFile
= os
.path
.join (OutputPath
, ModuleName
+ SUP_MODULE_SEC
+ SecNum
+ '.dpx')
116 OutputFile
= os
.path
.normpath(OutputFile
)
118 GenFdsGlobalVariable
.GenerateSection(OutputFile
, [InputFile
], Section
.Section
.SectionType
.get (SecType
), IsMakefile
=IsMakefile
)
119 return [OutputFile
], self
.Alignment