1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
#!/usr/bin/env python
import argparse
import os
import shutil
import string
import subprocess
import sys
args = {}
src_dir = ''
build_dir = ''
package_dir = ''
archive_file = ''
target_path = ''
def parse_arguments():
global args
parser = argparse.ArgumentParser(description='Build installer for installer framework.')
parser.add_argument('--clean', dest='clean', action='store_true', help='delete all previous build artifacts')
parser.add_argument('--static-qmake', dest='qmake', required=True, help='path to qmake that will be used to build the tools')
parser.add_argument('--doc-qmake', dest='doc_qmake', required=True, help='path to qmake that will be used to generate the documentation')
parser.add_argument('--make', dest='make', required=True, help='make command')
parser.add_argument('--targetdir', dest='target_dir', required=True, help='directory the generated installer will be placed in')
if sys.platform == 'darwin':
parser.add_argument('--qt_menu_nib', dest='menu_nib', required=True, help='location of qt_menu.nib (usually src/gui/mac/qt_menu.nib)')
args = parser.parse_args()
def run(args):
print 'calling ' + string.join(args)
subprocess.check_call(args)
def init():
global src_dir
global build_dir
global package_dir
global target_path
src_dir = os.path.dirname(os.path.abspath(os.path.dirname(sys.argv[0])))
root_dir = os.path.dirname(src_dir)
basename = os.path.basename(src_dir)
build_dir = os.path.join(root_dir, basename + '_build')
package_dir = os.path.join(root_dir, basename + '_pkg')
target_path = os.path.join(args.target_dir, 'ifw')
print 'source dir: ' + src_dir
print 'build dir: ' + build_dir
print 'package dir: ' + package_dir
print 'target path: ' + target_path
if args.clean and os.path.exists(build_dir):
print 'delete existing build dir ...'
shutil.rmtree(build_dir)
if not os.path.exists(build_dir):
os.makedirs(build_dir)
if os.path.exists(args.target_dir):
print 'delete existing target dir ...'
shutil.rmtree(args.target_dir)
os.makedirs(args.target_dir)
if os.path.exists(package_dir):
print 'delete existing package dir ...'
shutil.rmtree(package_dir)
os.makedirs(package_dir)
def build_docs():
print 'building documentation ...'
os.chdir(build_dir)
run((args.doc_qmake, src_dir))
run((args.make, 'docs'))
print 'success!'
def build():
print 'building sources ...'
os.chdir(build_dir)
run((args.qmake, src_dir))
run((args.make))
def package():
global package_dir
print 'package ...'
os.chdir(package_dir)
shutil.copytree(os.path.join(build_dir, 'bin'), os.path.join(package_dir, 'bin'), ignore = shutil.ignore_patterns("*.exe.manifest"))
shutil.copytree(os.path.join(build_dir, 'doc'), os.path.join(package_dir, 'doc'))
shutil.copytree(os.path.join(src_dir, 'examples'), os.path.join(package_dir, 'examples'))
shutil.copy(os.path.join(src_dir, 'README'), package_dir)
# create 7z
archive_file = os.path.join(src_dir, 'dist', 'packages', 'org.qtproject.ifw.binaries', 'data', 'data.7z')
if not os.path.exists(os.path.dirname(archive_file)):
os.makedirs(os.path.dirname(archive_file))
run((os.path.join(package_dir, 'bin', 'archivegen'), archive_file, '*'))
# run installer
binary_creator = os.path.join(build_dir, 'bin', 'binarycreator')
config_file = os.path.join(src_dir, 'dist', 'config', 'config.xml')
package_dir = os.path.join(src_dir, 'dist', 'packages')
installer_path = os.path.join(src_dir, 'dist', 'packages')
run((binary_creator, '--offline-only', '-c', config_file, '-p', package_dir, target_path))
if sys.platform == 'darwin':
shutil.copytree(args.menu_nib, target_path + '.app/Contents/Resources/qt_menu.nib')
parse_arguments()
init()
build_docs()
build()
package()
print 'DONE, installer is at ' + target_path
|