python build script: when getting modified time for a directory, also check contents' times

This commit is contained in:
Andrew Tonner 2017-01-19 05:13:01 -08:00
parent 21a6d39d4b
commit d8f5d43a9c
1 changed files with 8 additions and 2 deletions

View File

@ -534,14 +534,20 @@ class BuildDepTracker(object):
return rebuild_required
@staticmethod
def get_inputs_modified_time(input_filenames):
@classmethod
def get_inputs_modified_time(cls, input_filenames):
input_file_mtimes = []
for input_filename in input_filenames:
if os.path.isdir(input_filename):
subtime = cls.get_inputs_modified_time(os.path.join(input_filename, s) for s in os.listdir(input_filename))
if subtime is not None:
input_file_mtimes.append(subtime)
stat = os.stat(input_filename)
if stat is None:
assert False, "Missing input file %s" % input_filename
input_file_mtimes.append(stat.st_mtime)
if not input_file_mtimes:
return None
input_modified_time = max(input_file_mtimes)
return input_modified_time