Merge pull request #156 from theotherjimmy/mbedignore-fix

check for .mbedignore in root of source folders
Russ Butler 2016-05-27 15:36:25 -05:00
commit aa3c0deb70
1 changed files with 10 additions and 13 deletions

View File

@ -383,9 +383,18 @@ class mbedToolchain:
""" """
for root, dirs, files in walk(path, followlinks=True): for root, dirs, files in walk(path, followlinks=True):
# Remove ignored directories # Remove ignored directories
# Check if folder contains .mbedignore
if ".mbedignore" in files :
with open (join(root,".mbedignore"), "r") as f:
lines=f.readlines()
lines = [l.strip() for l in lines] # Strip whitespaces
lines = [l for l in lines if l != ""] # Strip empty lines
lines = [l for l in lines if not re.match("^#",l)] # Strip comment lines
# Append root path to glob patterns
# and append patterns to ignorepatterns
self.ignorepatterns.extend([join(root,line.strip()) for line in lines])
for d in copy(dirs): for d in copy(dirs):
dir_path = join(root, d) dir_path = join(root, d)
if d == '.hg': if d == '.hg':
resources.repo_dirs.append(dir_path) resources.repo_dirs.append(dir_path)
resources.repo_files.extend(self.scan_repository(dir_path)) resources.repo_files.extend(self.scan_repository(dir_path))
@ -396,18 +405,6 @@ class mbedToolchain:
(d == 'TESTS')): (d == 'TESTS')):
dirs.remove(d) dirs.remove(d)
# Check if folder contains .mbedignore
try:
with open (join(dir_path,".mbedignore"), "r") as f:
lines=f.readlines()
lines = [l.strip() for l in lines] # Strip whitespaces
lines = [l for l in lines if l != ""] # Strip empty lines
lines = [l for l in lines if not re.match("^#",l)] # Strip comment lines
# Append root path to glob patterns
# and append patterns to ignorepatterns
self.ignorepatterns.extend([join(dir_path,line.strip()) for line in lines])
except IOError:
pass
# Remove dirs that already match the ignorepatterns # Remove dirs that already match the ignorepatterns
# to avoid travelling into them and to prevent them # to avoid travelling into them and to prevent them