release.py 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. PLATFORM_TARGETS = {
  21. 'Windows': ['msvc2015-win64', 'msvc2015-win32'],
  22. 'Darwin': ['osx-cocoa-x86-64', 'osx-carbon-i386'],
  23. 'Linux': ['source-tarball', 'linux-generic-amd64', 'linux-generic-i386',
  24. 'mingw-w64-cross-win64', 'mingw-w64-cross-win32']
  25. }
  26. def build_target(basedir, target):
  27. build.message('*************** building: %s\n\n' % target)
  28. build.mkdir_p(basedir)
  29. log = open(os.path.join(basedir, '%s.log' % target), 'w')
  30. proc = subprocess.Popen([sys.executable, 'scripts/build.py', target],
  31. stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
  32. bufsize=1, cwd=os.path.join(basedir, '..'))
  33. proc.stdin.close()
  34. for line in iter(proc.stdout.readline, ''):
  35. line = line.rstrip()+'\n'
  36. if '\r' in line:
  37. line = line[1+line.rindex('\r'):]
  38. build.message(line)
  39. log.write(line)
  40. log.flush()
  41. proc.stdout.close()
  42. return proc.wait() == 0
  43. def main():
  44. rootdir = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), '..'))
  45. basedir = os.path.join(rootdir, 'static-build')
  46. os.chdir(os.path.join(rootdir, 'qt'))
  47. build.shell('git clean -fdx')
  48. build.shell('git reset --hard HEAD')
  49. os.chdir(rootdir)
  50. build.shell('git clean -fdx')
  51. build.shell('git reset --hard HEAD')
  52. build.shell('git submodule update')
  53. status = {}
  54. for target in PLATFORM_TARGETS.get(platform.system(), []):
  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()