1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
## @file
# This file is used to define class objects of INF file [Depex] section.
# It will consumed by InfParser.
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
'''
InfDepexObject
'''
from Library import DataType as DT
from Library import GlobalData
import Logger.Log as Logger
from Logger import ToolError
from Logger import StringTable as ST
from Object.Parser.InfCommonObject import InfSectionCommonDef
from Library.ParserValidate import IsValidArch
class InfDepexContentItem():
def __init__(self):
self.SectionType = ''
self.SectionString = ''
def SetSectionType(self, SectionType):
self.SectionType = SectionType
def GetSectionType(self):
return self.SectionType
def SetSectionString(self, SectionString):
self.SectionString = SectionString
def GetSectionString(self):
return self.SectionString
class InfDepexItem():
def __init__(self):
self.DepexContent = ''
self.ModuleType = ''
self.SupArch = ''
self.HelpString = ''
self.FeatureFlagExp = ''
self.InfDepexContentItemList = []
def SetFeatureFlagExp(self, FeatureFlagExp):
self.FeatureFlagExp = FeatureFlagExp
def GetFeatureFlagExp(self):
return self.FeatureFlagExp
def SetSupArch(self, Arch):
self.SupArch = Arch
def GetSupArch(self):
return self.SupArch
def SetHelpString(self, HelpString):
self.HelpString = HelpString
def GetHelpString(self):
return self.HelpString
def SetModuleType(self, Type):
self.ModuleType = Type
def GetModuleType(self):
return self.ModuleType
def SetDepexConent(self, Content):
self.DepexContent = Content
def GetDepexContent(self):
return self.DepexContent
def SetInfDepexContentItemList(self, InfDepexContentItemList):
self.InfDepexContentItemList = InfDepexContentItemList
def GetInfDepexContentItemList(self):
return self.InfDepexContentItemList
## InfDepexObject
#
#
#
class InfDepexObject(InfSectionCommonDef):
def __init__(self):
self.Depex = []
self.AllContent = ''
self.SectionContent = ''
InfSectionCommonDef.__init__(self)
def SetDepex(self, DepexContent, KeyList=None, CommentList=None):
for KeyItem in KeyList:
Arch = KeyItem[0]
ModuleType = KeyItem[1]
InfDepexItemIns = InfDepexItem()
#
# Validate Arch
#
if IsValidArch(Arch.strip().upper()):
InfDepexItemIns.SetSupArch(Arch)
else:
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
ST.ERR_INF_PARSER_DEFINE_NAME_INVALID % (Arch),
File=GlobalData.gINF_MODULE_NAME,
Line=KeyItem[2])
#
# Validate Module Type
#
if ModuleType and ModuleType != 'COMMON':
if ModuleType in DT.VALID_DEPEX_MODULE_TYPE_LIST:
InfDepexItemIns.SetModuleType(ModuleType)
else:
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
ST.ERR_INF_PARSER_DEPEX_SECTION_MODULE_TYPE_ERROR % (ModuleType),
File=GlobalData.gINF_MODULE_NAME,
Line=KeyItem[2])
#
# Parser content in [Depex] section.
#
DepexString = ''
HelpString = ''
#
# Get Depex Expression
#
for Line in DepexContent:
LineContent = Line[0].strip()
if LineContent.find(DT.TAB_COMMENT_SPLIT) > -1:
LineContent = LineContent[:LineContent.find(DT.TAB_COMMENT_SPLIT)]
if LineContent:
DepexString = DepexString + LineContent + DT.END_OF_LINE
continue
if DepexString.endswith(DT.END_OF_LINE):
DepexString = DepexString[:-1]
if not DepexString.strip():
continue
#
# Get Help Text
#
for HelpLine in CommentList:
HelpString = HelpString + HelpLine + DT.END_OF_LINE
if HelpString.endswith(DT.END_OF_LINE):
HelpString = HelpString[:-1]
InfDepexItemIns.SetDepexConent(DepexString)
InfDepexItemIns.SetHelpString(HelpString)
self.Depex.append(InfDepexItemIns)
return True
def GetDepex(self):
return self.Depex
def GetAllContent(self):
return self.AllContent
|