source: wkhtmltox/trunk/fuentes/scripts/release.py @ 51

Last change on this file since 51 was 51, checked in by mabarracus, 4 years ago

wip

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