work-around-vs-dependency-tracking-bugs.py [plain text]
import glob
import os
import re
import sys
TOP_LEVEL_DIRECTORY = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))))
def main():
react_to_vsprops_changes()
react_to_webkit1_interface_changes()
def react_to_vsprops_changes():
vsprops_directory = os.path.join(TOP_LEVEL_DIRECTORY, 'WebKitLibraries', 'win', 'tools', 'vsprops')
newest_vsprops_time = mtime_of_newest_file_matching_glob(os.path.join(vsprops_directory, '*.vsprops'))
obj_directory = os.path.join(os.environ['CONFIGURATIONBUILDDIR'], 'obj')
for extension in ('dep', 'manifest', 'pch', 'res'):
for filepath in glob.iglob(os.path.join(obj_directory, '*', '*.%s' % extension)):
delete_if_older_than(filepath, newest_vsprops_time)
wtf_platform_h = os.path.join(TOP_LEVEL_DIRECTORY, 'Source', 'JavaScriptCore', 'wtf', 'Platform.h')
touch_if_older_than(wtf_platform_h, newest_vsprops_time)
def react_to_webkit1_interface_changes():
interfaces_directory = os.path.join(TOP_LEVEL_DIRECTORY, 'Source', 'WebKit', 'win', 'Interfaces')
newest_idl_time = mtime_of_newest_file_matching_glob(os.path.join(interfaces_directory, '*.idl'))
touch_if_older_than(os.path.join(interfaces_directory, 'WebKit.idl'), newest_idl_time)
def mtime_of_newest_file_matching_glob(glob_pattern):
files = glob.glob(glob_pattern)
assert len(files), "Couldn't find any files matching glob %s" % glob_pattern
return max(map(os.path.getmtime, files))
def delete_if_older_than(path, reference_time):
if os.path.getmtime(path) < reference_time:
print 'Deleting %s' % path
os.remove(path)
def touch_if_older_than(path, reference_time):
if os.path.getmtime(path) < reference_time:
print 'Touching %s' % path
os.utime(path, None)
if __name__ == '__main__':
sys.exit(main())