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.
18 from __future__
import absolute_import
20 from .GenFdsGlobalVariable
import GenFdsGlobalVariable
23 import Common
.LongFilePathOs
as os
24 from CommonDataClass
.FdfClass
import DepexSectionClassObject
25 from AutoGen
.GenDepex
import DependencyExpression
26 from Common
import EdkLogger
27 from Common
.BuildToolError
import *
28 from Common
.Misc
import PathClass
29 from Common
.DataType
import *
31 ## generate data section
34 class DepexSection (DepexSectionClassObject
):
37 # @param self The object pointer
40 DepexSectionClassObject
.__init
__(self
)
42 def __FindGuidValue(self
, CName
):
43 for Arch
in GenFdsGlobalVariable
.ArchList
:
44 PkgList
= GenFdsGlobalVariable
.WorkSpace
.GetPackageList(GenFdsGlobalVariable
.ActivePlatform
,
46 GenFdsGlobalVariable
.TargetName
,
47 GenFdsGlobalVariable
.ToolChainTag
)
48 for Inf
in GenFdsGlobalVariable
.FdfParser
.Profile
.InfList
:
49 ModuleFile
= PathClass(Inf
, GenFdsGlobalVariable
.WorkSpaceDir
)
50 ModuleData
= GenFdsGlobalVariable
.WorkSpace
.BuildObject
[
53 GenFdsGlobalVariable
.TargetName
,
54 GenFdsGlobalVariable
.ToolChainTag
56 for Pkg
in ModuleData
.Packages
:
57 if Pkg
not in PkgList
:
60 if CName
in PkgDb
.Ppis
:
61 return PkgDb
.Ppis
[CName
]
62 if CName
in PkgDb
.Protocols
:
63 return PkgDb
.Protocols
[CName
]
64 if CName
in PkgDb
.Guids
:
65 return PkgDb
.Guids
[CName
]
68 ## GenSection() method
70 # Generate compressed section
72 # @param self The object pointer
73 # @param OutputPath Where to place output file
74 # @param ModuleName Which module this section belongs to
75 # @param SecNum Index of section
76 # @param KeyStringList Filter for inputs of section generation
77 # @param FfsInf FfsInfStatement object that contains this section data
78 # @param Dict dictionary contains macro and its value
79 # @retval tuple (Generated file name list, section alignment)
81 def GenSection(self
, OutputPath
, ModuleName
, SecNum
, keyStringList
, FfsFile
= None, Dict
= None, IsMakefile
= False):
82 if self
.ExpressionProcessed
== False:
83 self
.Expression
= self
.Expression
.replace("\n", " ").replace("\r", " ")
84 ExpList
= self
.Expression
.split()
87 if Exp
.upper() not in ('AND', 'OR', 'NOT', 'TRUE', 'FALSE', 'SOR', 'BEFORE', 'AFTER', 'END'):
88 GuidStr
= self
.__FindGuidValue
(Exp
)
90 EdkLogger
.error("GenFds", RESOURCE_NOT_AVAILABLE
,
91 "Depex GUID %s could not be found in build DB! (ModuleName: %s)" % (Exp
, ModuleName
))
93 self
.Expression
= self
.Expression
.replace(Exp
, GuidStr
)
95 self
.Expression
= self
.Expression
.strip()
96 self
.ExpressionProcessed
= True
98 if self
.DepexType
== 'PEI_DEPEX_EXP':
99 ModuleType
= SUP_MODULE_PEIM
100 SecType
= BINARY_FILE_TYPE_PEI_DEPEX
101 elif self
.DepexType
== 'DXE_DEPEX_EXP':
102 ModuleType
= SUP_MODULE_DXE_DRIVER
103 SecType
= BINARY_FILE_TYPE_DXE_DEPEX
104 elif self
.DepexType
== 'SMM_DEPEX_EXP':
105 ModuleType
= SUP_MODULE_DXE_SMM_DRIVER
106 SecType
= BINARY_FILE_TYPE_SMM_DEPEX
108 EdkLogger
.error("GenFds", FORMAT_INVALID
,
109 "Depex type %s is not valid for module %s" % (self
.DepexType
, ModuleName
))
111 InputFile
= os
.path
.join (OutputPath
, ModuleName
+ SUP_MODULE_SEC
+ SecNum
+ '.depex')
112 InputFile
= os
.path
.normpath(InputFile
)
113 Depex
= DependencyExpression(self
.Expression
, ModuleType
)
114 Depex
.Generate(InputFile
)
116 OutputFile
= os
.path
.join (OutputPath
, ModuleName
+ SUP_MODULE_SEC
+ SecNum
+ '.dpx')
117 OutputFile
= os
.path
.normpath(OutputFile
)
119 GenFdsGlobalVariable
.GenerateSection(OutputFile
, [InputFile
], Section
.Section
.SectionType
.get (SecType
), IsMakefile
=IsMakefile
)
120 return [OutputFile
], self
.Alignment