milestone.py 989 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env python
  2. # Copyright 2016 Google Inc.
  3. #
  4. # Use of this source code is governed by a BSD-style license that can be
  5. # found in the LICENSE file.
  6. import os
  7. import sys
  8. milestone_file = 'include/core/SkMilestone.h'
  9. usage = '''
  10. usage:
  11. git fetch
  12. git checkout -b change_milestone origin/master
  13. python %s MILESTONE_NUMBER
  14. git add %s
  15. git commit -m "Update Skia milestone."
  16. git cl land
  17. '''
  18. try:
  19. milestone = int(sys.argv[1])
  20. assert milestone > 0
  21. except (IndexError, ValueError, AssertionError):
  22. sys.stderr.write(usage % (sys.argv[0], milestone_file))
  23. exit(1)
  24. text = '''/*
  25. * Copyright 2016 Google Inc.
  26. *
  27. * Use of this source code is governed by a BSD-style license that can be
  28. * found in the LICENSE file.
  29. */
  30. #ifndef SK_MILESTONE
  31. #define SK_MILESTONE %d
  32. #endif
  33. '''
  34. os.chdir(os.path.join(os.path.dirname(__file__), os.pardir))
  35. with open(milestone_file, 'w') as o:
  36. o.write(text % milestone)
  37. with open(milestone_file, 'r') as f:
  38. sys.stdout.write(f.read())