PageRenderTime 44ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/work-around-vs-dependency-tracking-bugs.py

https://bitbucket.org/zenoalbisser/webkit
Python | 66 lines | 35 code | 20 blank | 11 comment | 5 complexity | 812b9cdd9ceb1941351a7140d25d0a17 MD5 | raw file
  1. #!/usr/bin/env python
  2. import glob
  3. import os
  4. import re
  5. import sys
  6. # It's fragile to rely on the location of this script to find the top-level
  7. # source directory.
  8. TOP_LEVEL_DIRECTORY = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))))
  9. def main():
  10. react_to_vsprops_changes()
  11. react_to_webkit1_interface_changes()
  12. def react_to_vsprops_changes():
  13. vsprops_directory = os.path.join(TOP_LEVEL_DIRECTORY, 'WebKitLibraries', 'win', 'tools', 'vsprops')
  14. newest_vsprops_time = mtime_of_newest_file_matching_glob(os.path.join(vsprops_directory, '*.vsprops'))
  15. obj_directory = os.path.join(os.environ['CONFIGURATIONBUILDDIR'], 'obj')
  16. # Visual Studio isn't smart enough to figure out it needs to rebuild these file types when
  17. # .vsprops files change (even if we touch wtf/Platform.h below), so we delete them to force them
  18. # to be rebuilt.
  19. for extension in ('dep', 'manifest', 'pch', 'res'):
  20. for filepath in glob.iglob(os.path.join(obj_directory, '*', '*.%s' % extension)):
  21. delete_if_older_than(filepath, newest_vsprops_time)
  22. # Touch wtf/Platform.h so all files will be recompiled. This is necessary
  23. # to pick up changes to preprocessor macros (e.g., ENABLE_*).
  24. wtf_platform_h = os.path.join(TOP_LEVEL_DIRECTORY, 'Source', 'JavaScriptCore', 'wtf', 'Platform.h')
  25. touch_if_older_than(wtf_platform_h, newest_vsprops_time)
  26. def react_to_webkit1_interface_changes():
  27. interfaces_directory = os.path.join(TOP_LEVEL_DIRECTORY, 'Source', 'WebKit', 'win', 'Interfaces')
  28. newest_idl_time = mtime_of_newest_file_matching_glob(os.path.join(interfaces_directory, '*.idl'))
  29. # WebKit.idl includes all the other IDL files, so needs to be rebuilt if any IDL file changes.
  30. # But Visual Studio isn't smart enough to figure this out, so we touch WebKit.idl to ensure that
  31. # it gets rebuilt.
  32. touch_if_older_than(os.path.join(interfaces_directory, 'WebKit.idl'), newest_idl_time)
  33. def mtime_of_newest_file_matching_glob(glob_pattern):
  34. files = glob.glob(glob_pattern)
  35. assert len(files), "Couldn't find any files matching glob %s" % glob_pattern
  36. return max(map(os.path.getmtime, files))
  37. def delete_if_older_than(path, reference_time):
  38. if os.path.getmtime(path) < reference_time:
  39. print 'Deleting %s' % path
  40. os.remove(path)
  41. def touch_if_older_than(path, reference_time):
  42. if os.path.getmtime(path) < reference_time:
  43. print 'Touching %s' % path
  44. os.utime(path, None)
  45. if __name__ == '__main__':
  46. sys.exit(main())