-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.py
More file actions
251 lines (212 loc) · 7.84 KB
/
build.py
File metadata and controls
251 lines (212 loc) · 7.84 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
import os, time, shutil
from subprocess import Popen, PIPE
from script import Script
import tools, setup
def s2m(s):
m = int((s * 10)/60)/10
return m if m <= 10 else int(m)
def build_combo(fn, config, platform):
print('building {0} {1} {2}...'.format(fn.__name__, config, platform))
bat = Script(True, fn.__name__, config, platform) #build script
fn(bat)
bat.run()
print('installing {0} {1} {2}...'.format(fn.__name__, config, platform))
bat = Script(False, fn.__name__, config, platform) #istallation script
fn(bat)
bat.run()
def build_all(fn):
print('=' * 60)
print('Building {0}...'.format(fn.__name__))
print('=' * 60)
start = time.time()
if setup.BUILD_DEBUG and setup.BUILD_X86:
build_combo(fn, 'debug', 'x86')
if setup.BUILD_RELEASE and setup.BUILD_X86:
build_combo(fn, 'release', 'x86')
if setup.BUILD_DEBUG and setup.BUILD_X64:
build_combo(fn, 'debug', 'x64')
if setup.BUILD_RELEASE and setup.BUILD_X64:
build_combo(fn, 'release', 'x64')
print('-' * 60)
print('{0} complete: {1} min'.format(fn.__name__, s2m(time.time() - start)))
def ICU(bat):
if bat.build:
tools.extract('icu')
bat.command('cd icu\\source\\allinone')
bat.devenv('allinone.sln')
else:
bat.validate_devenv()
bat.include('icu\\include')
bat.bin('icu\\bin\\*.exe')
bat.bin('icu\\bin\\*.dll', 'icu\\bin64\\*.dll')
bat.lib('icu\\lib\\*.lib', 'icu\\lib64\\*.lib')
def BerkeleyDB(bat):
if bat.build:
tools.extract('bdb')
bat.command('cd bdb\\build_windows')
# building the .NET solution also builds native DLLs
bat.devenv('BDB_dotNet_vs2010.sln')
else:
bat.validate_devenv()
bat.include('bdb\\build_windows\\*.h')
bat.bin('bdb\\build_windows\\AnyCPU\\{0}\\*.dll'.format(bat.config))
bat.bin('bdb\\build_windows\\win32\\{0}\\*.dll'.format(bat.config),
'bdb\\build_windows\\x64\\{0}\\*.dll'.format(bat.config))
bat.lib('bdb\\build_windows\\win32\\{0}\\*.lib'.format(bat.config),
'bdb\\build_windows\\x64\\{0}\\*.lib'.format(bat.config))
def bjam(bat):
if bat.build:
tools.extract('boost')
bat.command('cd boost')
bat.command('bootstrap.bat >bjam.log')
def Boost(bat):
def param(config, platform):
p = ' --hash --without-mpi toolset=msvc-{0}'.format(setup.VC_VERSION)
p += ' -sICU_PATH={0}\\{1}'.format(setup.INSTALL, platform)
p += ' -sZLIB_SOURCE={0}\\zlib'.format(os.getcwd())
p += ' variant={0} link=static runtime-link=static runtime-link=shared threading=multi'.format(config)
p += ' --prefix={0}\\{1}'.format(setup.INSTALL, platform)
p += ' address-model={0}'.format(64 if platform=='x64' else 32)
return p
if bat.build:
tools.extract('boost')
tools.extract('zlib')
bat.command('cd boost')
bat.command('b2 -a {0} install'.format(param(bat.config, bat.platform)))
def clean_boost(platform):
tools.rename('{0}\\{1}\\include\\{2}\\boost'.format(setup.INSTALL, platform, setup.BOOST_INCLUDE),
'{0}\\{1}\\include\\boost'.format(setup.INSTALL, platform))
def FreeType(bat):
if bat.build:
tools.extract('freetype')
# add missing x64 support
bat.command('copy /y archives\\freetype-project\\* freetype\\builds\\win32\\vc2010')
bat.command('cd freetype\\builds\\win32\\vc2010')
bat.devenv('freetype.sln')
else:
bat.validate_devenv()
bat.command('pushd freetype\\objs\\win32\\vc2010')
if bat.config == 'release':
bat.command('copy /y freetype246.lib freetype.lib')
bat.command('del freetype246.lib')
else:
bat.command('copy /y freetype246_d.lib freetyped.lib')
bat.command('del freetype246_d.lib')
bat.command('popd')
bat.include('freetype\\include')
bat.lib('freetype\\objs\\win32\\vc2010\\*.lib')
def libjpeg(bat):
if bat.build:
tools.extract('libjpeg')
# add missing x64 support
bat.command('copy /y archives\\jpeg-project\\* libjpeg')
bat.command('cd libjpeg')
bat.command('copy /y jconfig.vc jconfig.h')
bat.devenv('jpeg.sln')
else:
bat.validate_devenv()
bat.include('libjpeg\\*.h')
bat.lib('libjpeg\\{0}\\*.lib'.format(bat.config), 'libjpeg\\x64\\{0}\\*.lib'.format(bat.config))
def zlib(bat):
if bat.build:
tools.extract('zlib')
bat.command('cd zlib')
bat.cmake()
else:
bat.validate_cmake()
def libpng(bat):
if bat.build:
tools.extract('libpng')
bat.command('cd libpng')
bat.cmake()
else:
bat.validate_cmake()
def OpenSSL(bat):
if bat.build:
tools.extract('openssl')
else:
bat.include('openssl\\include64')
bat.lib('openssl\\lib64')
bat.bin('openssl\\bin64')
def PoDoFo(bat):
if bat.build:
if not os.path.isdir('podofo'):
os.system('svn export -r {0} {1} podofo >scripts\\svn-export.log'.format(setup.PODOFO_REV, setup.PODOFO_SVN))
bat.command('cd podofo')
bat.cmake({
'target': 'podofo_static',
'params': '-DLIBCRYPTO_LIBRARY_NAMES=libcryptoMT{0} -DPODOFO_BUILD_STATIC:TYPE=BOOL=ON'
.format('d' if bat.config == 'debug' else ''),
})
else:
bat.validate_cmake()
bat.include('podofo\\src\\*.h', '\\podofo')
bat.include('podofo\\podofo_config.h', '\\podofo')
if bat.config == 'debug':
bat.command("copy /y podofo\\src\\podofo\\podofo.lib podofo\\src\\podofo\\podofod.lib")
bat.lib("podofo\\src\\podofo\\podofod.lib")
else:
bat.lib("podofo\\src\\podofo\\podofo.lib")
def need(program):
(out, err) = Popen(['where', program], stdout=PIPE, shell=True).communicate()
if len(out) == 0:
raise Exception('{0} is required.'.format(program))
def main():
need('7z')
need('svn')
need('perl')
need('cmake')
need('sed')
start = time.time()
tools.kill('scripts')
os.mkdir('scripts')
print('Setting up {0}...'.format(setup.INSTALL))
if setup.CLEAN:
tools.kill(setup.INSTALL)
try:
os.mkdir(setup.INSTALL)
os.mkdir('{0}/x86'.format(setup.INSTALL))
os.mkdir('{0}/x86/include'.format(setup.INSTALL))
os.mkdir('{0}/x86/lib'.format(setup.INSTALL))
os.mkdir('{0}/x86/bin'.format(setup.INSTALL))
os.mkdir('{0}/x64'.format(setup.INSTALL))
os.mkdir('{0}/x64/include'.format(setup.INSTALL))
os.mkdir('{0}/x64/lib'.format(setup.INSTALL))
os.mkdir('{0}/x64/bin'.format(setup.INSTALL))
except OSError as e:
print('warning: {0} ({1})'.format(e.strerror, e.filename))
if setup.FRESH:
print('Forcing a fresh rebuild...')
tools.kill('bdb')
tools.kill('boost')
tools.kill('freetype')
tools.kill('icu')
tools.kill('libjpeg')
tools.kill('libpng')
tools.kill('openssl')
tools.kill('podofo')
tools.kill('turtle')
tools.kill('zlib')
if setup.BUILD_ICU:
build_all(ICU)
if setup.BUILD_BOOST:
build_combo(bjam, 'release', 'x86')
build_all(Boost)
if setup.BUILD_X86:
clean_boost('x86')
if setup.BUILD_X64:
clean_boost('x64')
if setup.BUILD_PODOFO:
build_all(zlib)
build_all(libjpeg)
build_all(libpng) # depends on zlib
build_all(FreeType)
build_all(OpenSSL)
build_all(PoDoFo) # depends on zlib, libjpeg, libpng, FreeType and OpenSSL
if setup.BUILD_BDB:
build_all(BerkeleyDB)
print('=' * 60)
print('build complete: {0} min'.format(s2m(time.time() - start)))
print('=' * 60)
if __name__ == '__main__':
main()