Skip to content

Commit 1b6c59c

Browse files
committed
Simplified preprocessing code.
Files preprocessed with explicit an empty preprocessing list are no longer put into the preprocessing folder since no actual preprocessing occured. Updated a test in test_ui.py which asserted the undesirable behavior.
1 parent 877ed5b commit 1b6c59c

1 file changed

Lines changed: 8 additions & 14 deletions

File tree

vunit/ui.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def set_pli(self, value):
181181
" Globally set pli "
182182
self._configuration.set_generic(value, scope="")
183183

184-
def add_source_files(self, pattern, library_name, preprocessors = None):
184+
def add_source_files(self, pattern, library_name, preprocessors=None):
185185
"""
186186
Add source files matching wildcard pattern to library
187187
"""
@@ -195,23 +195,17 @@ def add_source_files(self, pattern, library_name, preprocessors = None):
195195
def _preprocess(self, library_name, file_name, preprocessors):
196196
# @TODO dependency checking etc...
197197

198-
global_preprocessors = self._external_preprocessors + self._internal_preprocessors
199-
if (len(global_preprocessors) == 0) and (preprocessors is None):
198+
if preprocessors is None:
199+
preprocessors = self._external_preprocessors + self._internal_preprocessors
200+
201+
if len(preprocessors) == 0:
200202
return file_name
201203

202204
code = ostools.read_file(file_name)
203-
if preprocessors is not None:
204-
enabled_preprocessors = []
205-
for p in preprocessors:
206-
if str(p) not in enabled_preprocessors:
207-
code = p.run(code, basename(file_name))
208-
enabled_preprocessors.append(str(p))
209-
else:
210-
for p in global_preprocessors:
211-
code = p.run(code, basename(file_name))
205+
for p in preprocessors:
206+
code = p.run(code, basename(file_name))
212207

213-
pp_file_name = join(self._preprocessed_path,
214-
library_name, basename(file_name))
208+
pp_file_name = join(self._preprocessed_path, library_name, basename(file_name))
215209

216210
idx = 1
217211
while ostools.file_exists(pp_file_name):

0 commit comments

Comments
 (0)