mibuild/generic_platform: add recursive parameter to add_source_dir

This commit is contained in:
Florent Kermarrec 2014-08-01 12:50:38 +02:00 committed by Sebastien Bourdeauducq
parent 8baa957539
commit a0d0742664

View file

@ -222,12 +222,20 @@ class GenericPlatform:
for f in filenames: for f in filenames:
self.add_source(os.path.join(path, f), language) self.add_source(os.path.join(path, f), language)
def add_source_dir(self, path): def add_source_dir(self, path, recursive=True):
for root, dirs, files in os.walk(path): dir_files = []
for filename in files: if recursive:
language = tools.language_by_filename(filename) for root, dirs, files in os.walk(path):
if language is not None: for filename in files:
self.add_source(os.path.join(root, filename), language) dir_files.append(os.path.join(root, filename))
else:
for item in os.listdir(path):
if os.path.isfile(os.path.join(path, item)):
dir_files.append(os.path.join(path, item))
for filename in dir_files:
language = tools.language_by_filename(filename)
if language is not None:
self.add_source(filename, language)
def add_verilog_include_path(self, path): def add_verilog_include_path(self, path):
self.verilog_include_paths.append(os.path.abspath(path)) self.verilog_include_paths.append(os.path.abspath(path))