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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
|
# **********************************************************************
#
# Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
#
# This copy of Ice is licensed to you under the terms described in the
# ICE_LICENSE file included in this distribution.
#
# **********************************************************************
import getopt, os, re, shutil, string, sys, zipfile
def prependEnvPath(name, path):
"""Prepend a path to an existing environment variable."""
os.environ[name] = path + os.pathsep + os.environ[name]
def prependEnvPathList(name, list):
"""Prepend a list of paths to an existing environment variable."""
for path in list:
prependEnvPath(name, path)
class ExtProgramError:
def __init__(self, msg):
self.msg = msg
def __str__(self):
return repr(self.msg)
def runprog(command, haltOnError = True):
result = os.system(command)
if not result == 0 and haltOnError:
raise ExtProgramError('Command %s failed with error code %d' % (command, result))
def usage():
"""Print usage/help information"""
print "Usage: " + sys.argv[0] + " [options]"
print
print "Options:"
print "-h, --help Show this message."
print " --skip-build Do not build any sources."
print " --clean Clean compiled or staged files."
print " --skip-installer Do not build any installers or merge modules."
def cleanIceDists(sourcesDir, sourcesVersion, installVersion):
"""Clean all Ice distributions."""
iceHome = os.environ['ICE_HOME']
if installVersion == "vc71":
#
# Ice for C++
#
os.chdir(iceHome)
print "Cleaning in " + os.getcwd() + "..."
runprog("devenv all.sln /useenv /clean Debug")
runprog("devenv all.sln /useenv /clean Release")
#
# Ice for Java
#
# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# Leave Ice for Java alone. Everything that is needed is already
# included in the source distribution.
# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#
#
# Ice for C#
#
os.chdir(os.path.join(sourcesDir, "IceCS-" + sourcesVersion))
print "Cleaning in " + os.getcwd() + "..."
runprog("devenv all.sln /useenv /clean Debug")
#
# Ice for PHP
#
os.chdir(os.path.join(sourcesDir, "IcePHP-" + sourcesVersion))
print "Cleaning in " + os.getcwd() + "..."
runprog("devenv icephp.sln /useenv /clean Release")
#
# Ice for Python
#
os.chdir(os.path.join(sourcesDir, "IcePy-" + sourcesVersion))
print "Cleaning in " + os.getcwd() + "..."
runprog("devenv all.sln /useenv /clean Release")
#
# Ice for Visual Basic
#
os.rename(os.path.join(sourcesDir, "IceCS-" + sourcesVersion), os.path.join(sourcesDir, "IceCS")) # XXX temp
os.chdir(os.path.join(sourcesDir, "IceVB-" + sourcesVersion))
print "Cleaning in " + os.getcwd() + "..."
runprog("devenv all.sln /useenv /clean Debug")
os.rename(os.path.join(sourcesDir, "IceCS"), os.path.join(sourcesDir, "IceCS-" + sourcesVersion)) # XXX temp
elif installVersion == "vc60":
os.chdir(iceHome)
print "Cleaning in " + os.getcwd() + "..."
runprog("msdev all.dsw /useenv /make all - Win32 Debug /clean")
runprog("msdev all.dsw /useenv /make all - Win32 Release /clean")
def buildIceDists(stageDir, sourcesDir, sourcesVersion, installVersion):
"""Build all Ice distributions."""
#
# Update PATH, LIB and INCLUDE environment variables required for
# building Ice for C++.
#
path = [
os.path.join(stageDir, "berkeley/dev/bin"),
os.path.join(stageDir, "berkeley/runtime/bin"),
os.path.join(stageDir, "berkeley/java/bin"),
os.path.join(stageDir, "expat/runtime/bin"),
os.path.join(stageDir, "openssl/runtime/bin")
]
if installVersion == "vc60":
path.append(os.path.join(stageDir, "stlport/dev/bin"))
path.append(os.path.join(stageDir, "stlport/runtime/bin"))
prependEnvPathList('PATH', path)
lib = [
os.path.join(stageDir, "berkeley/dev/lib"),
os.path.join(stageDir, "bzip2/dev/lib"),
os.path.join(stageDir, "expat/dev/lib"),
os.path.join(stageDir, "openssl/dev/lib")
]
if installVersion == "vc60":
lib.append(os.path.join(stageDir, "stlport/dev/lib"))
prependEnvPathList('LIB', lib)
include = [
os.path.join(stageDir, "berkeley/dev/include"),
os.path.join(stageDir, "bzip2/dev/include"),
os.path.join(stageDir, "expat/dev/include"),
os.path.join(stageDir, "openssl/dev/include")
]
if installVersion == "vc60":
include.append(os.path.join(stageDir, "stlport/dev/include/stlport"))
prependEnvPathList('INCLUDE', include)
iceHome = os.environ['ICE_HOME']
prependEnvPath('PATH', os.path.join(iceHome, "bin"))
prependEnvPath('LIB', os.path.join(iceHome, "lib"))
prependEnvPath('INCLUDE', os.path.join(iceHome, "include"))
if installVersion == "vc71":
#
# Ice for C++
#
os.chdir(iceHome)
print "Building in " + os.getcwd() + "..."
runprog("devenv all.sln /useenv /build Debug")
runprog("devenv all.sln /useenv /build Release")
#
# Ice for Java
#
# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# Leave Ice for Java alone. Everything that is needed is already
# included in the source distribution.
# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#
#
# Ice for C#
#
os.chdir(os.path.join(sourcesDir, "IceCS-" + sourcesVersion))
print "Building in " + os.getcwd() + "..."
runprog("devenv all.sln /useenv /build Debug")
#
# Ice for PHP
#
phpBinHome = os.environ['PHP_BIN_HOME']
phpLib = [
os.path.join(phpBinHome, "lib"),
os.path.join(phpBinHome, "dev")
]
prependEnvPathList('LIB', phpLib)
phpSrcHome = os.environ['PHP_SRC_HOME']
phpInc = [
phpSrcHome,
os.path.join(phpSrcHome, "main"),
os.path.join(phpSrcHome, "Zend"),
os.path.join(phpSrcHome, "TSRM")
]
prependEnvPathList('INCLUDE', phpInc)
os.chdir(os.path.join(sourcesDir, "IcePHP-" + sourcesVersion))
print "Building in " + os.getcwd() + "..."
runprog("devenv icephp.sln /useenv /build Release")
#
# Ice for Python
#
pythonHome = os.environ['PYTHON_HOME']
prependEnvPath('LIB', os.path.join(pythonHome, "libs"))
prependEnvPath('INCLUDE', os.path.join(pythonHome, "include"))
os.chdir(os.path.join(sourcesDir, "IcePy-" + sourcesVersion))
print "Building in " + os.getcwd() + "..."
runprog("devenv all.sln /useenv /build Release")
#
# Ice for Visual Basic
#
os.chdir(os.path.join(sourcesDir, "IceVB-" + sourcesVersion))
print "Building in " + os.getcwd() + "..."
runprog("devenv all.sln /useenv /build Debug")
elif installVersion == "vc60":
#
# Ice for C++
#
os.chdir(iceHome)
print "Building in " + os.getcwd() + "..."
runprog('msdev all.dsw /useenv /make "all - Win32 Debug"')
runprog('msdev all.dsw /useenv /make "all - Win32 Release"')
def buildMergeModules(startDir, stageDir, sourcesVersion, installVersion):
"""Build third party merge modules."""
modules = [
("BerkeleyDBDevKit", "BERKELEYDB_DEV_KIT"),
("BerkeleyDBRuntime", "BERKELEYDB_RUNTIME"),
("BerkeleyDBJava", "BERKELEYDB_JAVA"),
("BZip2DevKit", "BZIP2_DEV_KIT"),
("BZip2Runtime", "BZIP2_RUNTIME"),
("ExpatDevKit", "EXPAT_DEV_KIT"),
("ExpatRuntime", "EXPAT_RUNTIME"),
("OpenSSLDevKit", "OPENSSL_DEV_KIT"),
("OpenSSLRuntime", "OPENSSL_RUNTIME")
]
if installVersion == "vc60":
extras = [ ("STLPortDevKit", "STLPORT_DEV_KIT"), ("STLPortRuntime", "STLPORT_RUNTIME") ]
modules.extend(extras)
elif installVersion == "vc71":
extras = [ ("JGoodies", "JGOODIES_RUNTIME") ]
modules.extend(extras)
#
# Build modules.
#
os.chdir(startDir)
for project, release in modules:
runprog(os.environ['INSTALLSHIELD_HOME'] + "\IsCmdBld -c COMP -a ZEROC -p " + project + ".ism -r " + release)
#
# Archive modules in the stage directory root.
#
zipPath = "ThirdPartyMergeModules-" + sourcesVersion + "-" + installVersion.upper() + ".zip"
zip = zipfile.ZipFile(os.path.join(stageDir, zipPath), 'w')
for project, release in modules:
msm = project + "." + installVersion.upper() + ".msm"
msmPath = os.path.join(os.getcwd(), project, "ZEROC", release, "DiskImages/DISK1", msm)
zip.write(msmPath, os.path.basename(msmPath))
zip.close()
def buildInstallers(startDir, stageDir, sourcesVersion, installVersion):
"""Build MSI installers."""
installers = [("ThirdParty", "THIRD_PARTY_MSI"), ("Ice", "ICE_MSI")]
#
# Build and copy to the stage directory root.
#
os.chdir(startDir)
for project, release in installers:
runprog("ISCmdBld -c COMP -a ZEROC -p " + project + ".ism -r " + release)
msi = project + "-" + sourcesVersion + "-" + installVersion.upper() + ".msi"
msiPath = os.path.join(os.getcwd(), project, "ZEROC", release, "DiskImages/DISK1", msi)
shutil.copy(msiPath, stageDir)
def main():
#
# Save our start dir. This script expects that this will be
# <ice-cvs-root>/install/[vc60|vc71]
#
startDir = os.getcwd()
print "Start Directory: " + startDir
installDir = startDir[:startDir.rfind("\\")]
print "Install Directory: " + installDir
#
# Check the installer version string.
#
installVersion = startDir[startDir.rfind("\\")+1:].lower()
if installVersion != "vc60" and installVersion != "vc71":
print "Invalid install version."
sys.exit(2)
else:
print "Install Version: " + installVersion
#
# Where all the files will be staged so that the install projects
# can find them.
#
stageDir = os.path.join(startDir, "install")
print "Stage Directory: " + stageDir
#
# Process args.
#
try:
optionList, args = getopt.getopt(
sys.argv[1:], "h:", [ "help", "clean", "skip-build", "skip-installer" ])
except getopt.GetoptError:
usage()
sys.exit(2)
#
# Set a few defaults.
#
clean = False
build = True
installer = True
for o, a in optionList:
if o in ("-h", "--help"):
usage()
sys.exit()
elif o == "--clean":
clean = True
elif o == "--skip-build":
build = False
elif o == "--skip-installer":
installer = False
if clean:
print('You have indicated you want to ''clean'' files, starting from scratch.')
confirm = ''
while not confirm in ['y', 'n']:
confirm = raw_input('Are you sure? [y/N]')
if confirm == '':
confirm = 'n'
if confirm == 'n':
sys.exit()
else:
'Deleting intermediate files and rebuilding from scratch!'
#
# Check the environment for the required vars.
#
ok = True
required = ['ICE_HOME', 'BERKELEY_HOME', 'BZIP2_HOME', 'EXPAT_HOME', 'OPENSSL_HOME', 'JGOODIES_HOME']
if installVersion == "vc71":
required.extend(['PHP_BIN_HOME', 'PHP_SRC_HOME', 'PYTHON_HOME'])
elif installVersion == "vc60":
required.append('STLPORT_HOME')
for var in required:
path = os.environ[var]
if path == "":
print var + " is not set!"
ok = False
elif not os.path.isdir(path):
print var + " is invalid!"
ok = False
else:
print var + ": " + path
if not ok:
sys.exit(2)
iceHome = os.environ['ICE_HOME']
berkeleyHome = os.environ['BERKELEY_HOME']
bzip2Home = os.environ['BZIP2_HOME']
expatHome = os.environ['EXPAT_HOME']
opensslHome = os.environ['OPENSSL_HOME']
jgoodiesHome = os.environ['JGOODIES_HOME']
if installVersion == "vc71":
phpBinHome = os.environ['PHP_BIN_HOME']
phpSrcHome = os.environ['PHP_SRC_HOME']
pythonHome = os.environ['PYTHON_HOME']
stlportHome = ""
elif installVersion == "vc60":
phpBinHome = ""
phpSrcHome = ""
pythonHome = ""
stlportHome = os.environ['STLPORT_HOME']
#
# Extract the Ice source distributions directory.
#
sourcesDir = iceHome[:iceHome.rfind("\\Ice-")]
print "Ice Sources Directory: " + sourcesDir
#
# Extract the Ice distribution version.
#
sourcesVersion = iceHome[iceHome.rfind("-")+1:]
if not re.match("^\d\.\d\.\d$", sourcesVersion):
print "Invalid Version: " + sourcesVersion
sys.exit(2)
else:
print "Ice Sources Version: " + sourcesVersion
antOptions = " -buildfile " + os.path.join(installDir, "common/stage.xml") + \
" -Dinstall.dir=" + installDir + \
" -Dinstall.version=" + installVersion + \
" -Dsources.dir=" + sourcesDir + \
" -Dsources.version=" + sourcesVersion + \
" -Dstage.dir=" + stageDir
#
# This should be performed every time. The third party libraries are
# rebuilt 'out-of-band' so there is no way for the script to pickup
# changes in them.
#
runprog("ant" + antOptions + " clean")
if clean:
cleanIceDists(sourcesDir, sourcesVersion, installVersion)
#
# Stage the third party packages.
#
if installer:
runprog("ant" + antOptions + " packages-stage-" + installVersion)
#
# Build the Ice distributions.
#
if build:
buildIceDists(stageDir, sourcesDir, sourcesVersion, installVersion)
#
# Build the merge module and installer projects.
#
if installer:
runprog("ant" + antOptions + " ice-stage-" + installVersion)
buildMergeModules(startDir, stageDir, sourcesVersion, installVersion)
buildInstallers(startDir, stageDir, sourcesVersion, installVersion)
if __name__ == "__main__":
main()
|