Error if any scanignore/delete paths are useless

This commit is contained in:
Daniel Martí 2015-01-06 14:37:13 +01:00
parent 0ffc53fa9a
commit 347ff7b876

View file

@ -1449,6 +1449,9 @@ def scan_source(build_dir, root_dir, thisbuild):
scanignore = getpaths(build_dir, thisbuild, 'scanignore') scanignore = getpaths(build_dir, thisbuild, 'scanignore')
scandelete = getpaths(build_dir, thisbuild, 'scandelete') scandelete = getpaths(build_dir, thisbuild, 'scandelete')
scanignore_worked = set()
scandelete_worked = set()
try: try:
ms = magic.open(magic.MIME_TYPE) ms = magic.open(magic.MIME_TYPE)
ms.load() ms.load()
@ -1456,33 +1459,38 @@ def scan_source(build_dir, root_dir, thisbuild):
ms = None ms = None
def toignore(fd): def toignore(fd):
for i in scanignore: for p in scanignore:
if fd.startswith(i): if fd.startswith(p):
scanignore_worked.add(p)
return True return True
return False return False
def todelete(fd): def todelete(fd):
for i in scandelete: for p in scandelete:
if fd.startswith(i): if fd.startswith(p):
scandelete_worked.add(p)
return True return True
return False return False
def ignoreproblem(what, fd, fp):
logging.info('Ignoring %s at %s' % (what, fd))
return 0
def removeproblem(what, fd, fp): def removeproblem(what, fd, fp):
logging.info('Removing %s at %s' % (what, fd)) logging.info('Removing %s at %s' % (what, fd))
os.remove(fp) os.remove(fp)
return 0
def warnproblem(what, fd): def warnproblem(what, fd):
logging.warn('Found %s at %s' % (what, fd)) logging.warn('Found %s at %s' % (what, fd))
def handleproblem(what, fd, fp): def handleproblem(what, fd, fp):
if toignore(fd): if toignore(fd):
logging.info('Ignoring %s at %s' % (what, fd)) return ignoreproblem(what, fd, fp)
elif todelete(fd): if todelete(fd):
removeproblem(what, fd, fp) return removeproblem(what, fd, fp)
else: logging.error('Found %s at %s' % (what, fd))
logging.error('Found %s at %s' % (what, fd)) return 1
return True
return False
# Iterate through all files in the source code # Iterate through all files in the source code
for r, d, f in os.walk(build_dir, topdown=True): for r, d, f in os.walk(build_dir, topdown=True):
@ -1547,6 +1555,16 @@ def scan_source(build_dir, root_dir, thisbuild):
if ms is not None: if ms is not None:
ms.close() ms.close()
for p in scanignore:
if p not in scanignore_worked:
logging.error('Unused scanignore path: %s' % p)
count += 1
for p in scandelete:
if p not in scandelete_worked:
logging.error('Unused scandelete path: %s' % p)
count += 1
# Presence of a jni directory without buildjni=yes might # Presence of a jni directory without buildjni=yes might
# indicate a problem (if it's not a problem, explicitly use # indicate a problem (if it's not a problem, explicitly use
# buildjni=no to bypass this check) # buildjni=no to bypass this check)