9 # It's fragile to rely on the location of this script to find the top-level
11 TOP_LEVEL_DIRECTORY = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))))
15 react_to_vsprops_changes()
16 react_to_webkit1_interface_changes()
19 def react_to_vsprops_changes():
20 vsprops_directory = os.path.join(TOP_LEVEL_DIRECTORY, 'WebKitLibraries', 'win', 'tools', 'vsprops')
21 newest_vsprops_time = mtime_of_newest_file_matching_glob(os.path.join(vsprops_directory, '*.vsprops'))
23 obj_directory = os.path.join(os.environ['CONFIGURATIONBUILDDIR'], 'obj')
25 # Visual Studio isn't smart enough to figure out it needs to rebuild these file types when
26 # .vsprops files change (even if we touch wtf/Platform.h below), so we delete them to force them
28 for extension in ('dep', 'manifest', 'pch', 'res'):
29 for filepath in glob.iglob(os.path.join(obj_directory, '*', '*.%s' % extension)):
30 delete_if_older_than(filepath, newest_vsprops_time)
32 # Touch wtf/Platform.h so all files will be recompiled. This is necessary
33 # to pick up changes to preprocessor macros (e.g., ENABLE_*).
34 wtf_platform_h = os.path.join(TOP_LEVEL_DIRECTORY, 'Source', 'JavaScriptCore', 'wtf', 'Platform.h')
35 touch_if_older_than(wtf_platform_h, newest_vsprops_time)
38 def react_to_webkit1_interface_changes():
39 interfaces_directory = os.path.join(TOP_LEVEL_DIRECTORY, 'Source', 'WebKit', 'win', 'Interfaces')
40 newest_idl_time = mtime_of_newest_file_matching_glob(os.path.join(interfaces_directory, '*.idl'))
41 # WebKit.idl includes all the other IDL files, so needs to be rebuilt if any IDL file changes.
42 # But Visual Studio isn't smart enough to figure this out, so we touch WebKit.idl to ensure that
44 touch_if_older_than(os.path.join(interfaces_directory, 'WebKit.idl'), newest_idl_time)
47 def mtime_of_newest_file_matching_glob(glob_pattern):
48 files = glob.glob(glob_pattern)
49 assert len(files), "Couldn't find any files matching glob %s" % glob_pattern
50 return max(map(os.path.getmtime, files))
53 def delete_if_older_than(path, reference_time):
54 if os.path.getmtime(path) < reference_time:
55 print 'Deleting %s' % path
59 def touch_if_older_than(path, reference_time):
60 if os.path.getmtime(path) < reference_time:
61 print 'Touching %s' % path
65 if __name__ == '__main__':