@@ -113,13 +113,8 @@ def __ParseLine(self, Line, file_name=None, lineno=None):
113
113
p = self .ParseInfPathLib (line_resolved )
114
114
self .Libs .append (p )
115
115
self .Logger .debug ("Found Library in a 64bit BuildOptions Section: %s" % p )
116
- elif "tokenspaceguid" in line_resolved .lower () and \
117
- line_resolved .count ('|' ) > 0 and line_resolved .count ('.' ) > 0 :
118
- # should be a pcd statement
119
- p = line_resolved .partition ('|' )
120
- self .Pcds .append (p [0 ].strip ())
121
- self .PcdValueDict [p [0 ].strip ()] = p [2 ].strip ()
122
- self .Logger .debug ("Found a Pcd in a 64bit Module Override section: %s" % p [0 ].strip ())
116
+ elif self .RegisterPcds (line_resolved ):
117
+ self .Logger .debug ("Found a Pcd in a 64bit Module Override section" )
123
118
else :
124
119
if (".inf" in line_resolved .lower ()):
125
120
p = self .ParseInfPathMod (line_resolved )
@@ -141,13 +136,8 @@ def __ParseLine(self, Line, file_name=None, lineno=None):
141
136
if file_name is not None and lineno is not None :
142
137
self .LibsEnhanced .append ({'file' : os .path .normpath (file_name ), 'lineno' : lineno , 'data' : p })
143
138
self .Logger .debug ("Found Library in a 32bit BuildOptions Section: %s" % p )
144
- elif "tokenspaceguid" in line_resolved .lower () and \
145
- line_resolved .count ('|' ) > 0 and line_resolved .count ('.' ) > 0 :
146
- # should be a pcd statement
147
- p = line_resolved .partition ('|' )
148
- self .Pcds .append (p [0 ].strip ())
149
- self .PcdValueDict [p [0 ].strip ()] = p [2 ].strip ()
150
- self .Logger .debug ("Found a Pcd in a 32bit Module Override section: %s" % p [0 ].strip ())
139
+ elif self .RegisterPcds (line_resolved ):
140
+ self .Logger .debug ("Found a Pcd in a 32bit Module Override section" )
151
141
152
142
else :
153
143
if (".inf" in line_resolved .lower ()):
@@ -169,13 +159,8 @@ def __ParseLine(self, Line, file_name=None, lineno=None):
169
159
p = self .ParseInfPathLib (line_resolved )
170
160
self .Libs .append (p )
171
161
self .Logger .debug ("Found Library in a BuildOptions Section: %s" % p )
172
- elif "tokenspaceguid" in line_resolved .lower () and \
173
- line_resolved .count ('|' ) > 0 and line_resolved .count ('.' ) > 0 :
174
- # should be a pcd statement
175
- p = line_resolved .partition ('|' )
176
- self .Pcds .append (p [0 ].strip ())
177
- self .PcdValueDict [p [0 ].strip ()] = p [2 ].strip ()
178
- self .Logger .debug ("Found a Pcd in a Module Override section: %s" % p [0 ].strip ())
162
+ elif self .RegisterPcds (line_resolved ):
163
+ self .Logger .debug ("Found a Pcd in a Module Override section" )
179
164
180
165
else :
181
166
if (".inf" in line_resolved .lower ()):
@@ -196,13 +181,8 @@ def __ParseLine(self, Line, file_name=None, lineno=None):
196
181
return (line_resolved , [], None )
197
182
# process line in PCD section
198
183
elif (self .CurrentSection .upper ().startswith ("PCDS" )):
199
- if "tokenspaceguid" in line_resolved .lower () and \
200
- line_resolved .count ('|' ) > 0 and line_resolved .count ('.' ) > 0 :
201
- # should be a pcd statement
202
- p = line_resolved .partition ('|' )
203
- self .Pcds .append (p [0 ].strip ())
204
- self .PcdValueDict [p [0 ].strip ()] = p [2 ].strip ()
205
- self .Logger .debug ("Found a Pcd in a PCD section: %s" % p [0 ].strip ())
184
+ if self .RegisterPcds (line_resolved ):
185
+ self .Logger .debug ("Found a Pcd in a PCD section" )
206
186
return (line_resolved , [], None )
207
187
else :
208
188
return (line_resolved , [], None )
@@ -213,6 +193,8 @@ def __ParseDefineLine(self, Line):
213
193
return ("" , [])
214
194
215
195
# this line needs to be here to resolve any symbols inside the !include lines, if any
196
+ self .RegisterPcds (line_stripped )
197
+ line_stripped = self .ReplacePcds (line_stripped )
216
198
line_resolved = self .ReplaceVariables (line_stripped )
217
199
if (self .ProcessConditional (line_resolved )):
218
200
# was a conditional
@@ -333,6 +315,8 @@ def __ProcessDefines(self, lines):
333
315
# otherwise, raise the exception and act normally
334
316
if not self ._no_fail_mode :
335
317
raise
318
+ # Reset the PcdValueDict as this was just to find any Defines.
319
+ self .PcdValueDict = {}
336
320
337
321
def _parse_libraries (self ):
338
322
"""Builds a lookup table of all possible library instances depending on scope.
@@ -535,3 +519,17 @@ def GetAllDscPaths(self):
535
519
They are not all guaranteed to be DSC files
536
520
"""
537
521
return self ._dsc_file_paths
522
+
523
+ def RegisterPcds (self , line ):
524
+ """Reads the line and registers any PCDs found."""
525
+ if ("tokenspaceguid" in line .lower () and
526
+ line .count ('|' ) > 0 and
527
+ line .count ('.' ) > 0 ):
528
+
529
+ # should be a pcd statement
530
+ p = line .partition ('|' )
531
+ self .Pcds .append (p [0 ].strip ())
532
+ self .PcdValueDict [p [0 ].strip ()] = p [2 ].strip ()
533
+ self .Logger .debug ("Found a Pcd: %s" % p [0 ].strip ())
534
+ return True
535
+ return False
0 commit comments