release.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/usr/bin/env python
  2. #
  3. # Copyright 2014 wkhtmltopdf authors
  4. #
  5. # This file is part of wkhtmltopdf.
  6. #
  7. # wkhtmltopdf is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU Lesser General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # wkhtmltopdf is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Lesser General Public License
  18. # along with wkhtmltopdf. If not, see <http:#www.gnu.org/licenses/>.
  19. import os, sys, platform, subprocess, build
  20. def get_targets():
  21. if platform.system() == 'Windows':
  22. return ['msvc2013-win32', 'msvc2013-win64']
  23. elif platform.system() == 'Darwin':
  24. builder = 'osx'
  25. else:
  26. builder = 'linux_schroot'
  27. return [name for name in build.BUILDERS if build.BUILDERS[name] == builder]
  28. def build_target(basedir, target):
  29. build.message('*************** building: %s\n\n' % target)
  30. log = open(os.path.join(basedir, '%s.log' % target), 'w')
  31. proc = subprocess.Popen([sys.executable, 'scripts/build.py', target],
  32. stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
  33. bufsize=1, cwd=os.path.join(basedir, '..'))
  34. proc.stdin.close()
  35. for line in iter(proc.stdout.readline, ''):
  36. line = line.rstrip()+'\n'
  37. build.message(line)
  38. log.write(line)
  39. log.flush()
  40. proc.stdout.close()
  41. return proc.wait() == 0
  42. def main():
  43. rootdir = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), '..'))
  44. basedir = os.path.join(rootdir, 'static-build')
  45. os.chdir(os.path.join(rootdir, 'qt'))
  46. build.shell('git clean -fdx')
  47. build.shell('git reset --hard HEAD')
  48. os.chdir(rootdir)
  49. build.shell('git clean -fdx')
  50. build.shell('git reset --hard HEAD')
  51. build.shell('git submodule update')
  52. build.mkdir_p(basedir)
  53. status = {}
  54. for target in get_targets():
  55. if not build_target(basedir, target):
  56. status[target] = 'failed'
  57. continue
  58. status[target] = 'success'
  59. build.rmdir(os.path.join(basedir, target))
  60. build.message('\n\n\nSTATUS\n======\n')
  61. width = max([len(target) for target in status])
  62. for target in sorted(status.keys()):
  63. build.message('%s: %s\n' % (target.ljust(width), status[target]))
  64. if __name__ == '__main__':
  65. main()