release.py 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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_build_targets():
  21. map = {}
  22. for k, v in build.BUILDERS.iteritems():
  23. if not v in map:
  24. map[v] = []
  25. map[v].append(k)
  26. map[v].sort()
  27. return map
  28. def get_targets():
  29. if platform.system() == 'Windows':
  30. return ['msvc2013-win32', 'msvc2013-win64']
  31. elif platform.system() == 'Darwin':
  32. builders = ['osx']
  33. else:
  34. builders = ['source_tarball', 'linux_schroot', 'mingw64_cross']
  35. targets, map = [], get_build_targets()
  36. for builder in builders:
  37. targets.extend(map[builder])
  38. return targets
  39. def build_target(basedir, target):
  40. build.message('*************** building: %s\n\n' % target)
  41. build.mkdir_p(basedir)
  42. log = open(os.path.join(basedir, '%s.log' % target), 'w')
  43. proc = subprocess.Popen([sys.executable, 'scripts/build.py', target],
  44. stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
  45. bufsize=1, cwd=os.path.join(basedir, '..'))
  46. proc.stdin.close()
  47. for line in iter(proc.stdout.readline, ''):
  48. line = line.rstrip()+'\n'
  49. if '\r' in line:
  50. line = line[1+line.rindex('\r'):]
  51. build.message(line)
  52. log.write(line)
  53. log.flush()
  54. proc.stdout.close()
  55. return proc.wait() == 0
  56. def main():
  57. rootdir = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), '..'))
  58. basedir = os.path.join(rootdir, 'static-build')
  59. os.chdir(os.path.join(rootdir, 'qt'))
  60. build.shell('git clean -fdx')
  61. build.shell('git reset --hard HEAD')
  62. os.chdir(rootdir)
  63. build.shell('git clean -fdx')
  64. build.shell('git reset --hard HEAD')
  65. build.shell('git submodule update')
  66. status = {}
  67. for target in get_targets():
  68. if not build_target(basedir, target):
  69. status[target] = 'failed'
  70. continue
  71. status[target] = 'success'
  72. build.rmdir(os.path.join(basedir, target))
  73. build.message('\n\n\nSTATUS\n======\n')
  74. width = max([len(target) for target in status])
  75. for target in sorted(status.keys()):
  76. build.message('%s: %s\n' % (target.ljust(width), status[target]))
  77. if __name__ == '__main__':
  78. main()