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
|
#!/usr/bin/env python
# **********************************************************************
#
# Copyright (c) 2003-2014 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 os, sys, shutil, glob, fnmatch, string, re
from stat import *
#
# NOTE: See lib/DistUtils.py for default third-party locations and
# languages to be built on each platform.
#
version = "@ver@"
distDir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
sys.path.append(os.path.join(distDir, "lib"))
import DistUtils
from DistUtils import copy
make = "make"
#
# Defines which languages are to also be built in 64bits mode
#
# NOTE: makebindist.py doesn't currently support different third party locations
# for 32 and 64 bits. This is an issue on HP-UX for example where Bzip2 32bits is
# in /usr/local and in /opt for the 64bits version.
#
build_lp64 = { \
'SunOS' : ['cpp'], \
}
#
# Program usage.
#
def usage():
print "Usage: " + sys.argv[0] + " [options] tag"
print
print "Options:"
print "-c Clean previous build"
print "-n Don't build any language mapping"
print "-h Show this message."
print "-v Be verbose."
#
# Instantiate the gobal platform object with the given third-parties
#
thirdParties = [
"BerkeleyDB", \
"Expat", \
"OpenSSL", \
"Mcpp", \
"Iconv", \
"Proguard", \
"JavaApplicationBundler"
]
platform = DistUtils.getPlatform(thirdParties)
#
# Check arguments
#
verbose = 0
forceclean = 0
nobuild = 0
buildLanguages = [ ]
for x in sys.argv[1:]:
if x == "-h":
usage()
sys.exit(0)
elif x == "-v":
verbose = 1
elif x == "-c":
forceclean = 1
elif x == "-n":
nobuild = 1
elif x.startswith("-"):
print sys.argv[0] + ": unknown option `" + x + "'"
print
usage()
sys.exit(1)
else:
if not x in platform.languages:
print sys.argv[0] + ": language `" + x + "' not supported on this platform"
print
usage()
sys.exit(1)
buildLanguages.append(x)
if len(buildLanguages) == 0:
buildLanguages = platform.languages
if nobuild:
buildLanguages = []
if verbose:
quiet = "v"
else:
quiet = ""
#
# Ensure the script is being run from the dist-@ver@ directory.
#
cwd = os.getcwd()
if not os.path.exists(os.path.join(distDir, "src", "windows", "LICENSE.rtf")):
print sys.argv[0] + ": you must run makebindist.py from the dist-" + version + " directory created by makedist.py"
sys.exit(1)
print "Building Ice " + version + " binary distribution (" + platform.getPackageName("Ice", version) + ".tar.gz)"
print "Using the following third party libraries:"
if not platform.checkAndPrintThirdParties():
print "error: some required third party dependencies were not found"
sys.exit(1)
#
# Ensure that the source archive or directory exists and create the build directory.
#
buildRootDir = os.path.join(distDir, "..", os.path.join("build-" + platform.pkgPlatform + "-" + version))
srcDir = os.path.join(buildRootDir, "Ice-" + version + "-src")
buildDir = os.path.join(buildRootDir, "Ice-" + version)
if forceclean or not os.path.exists(srcDir) or not os.path.exists(buildDir):
if os.path.exists(buildRootDir):
print "Removing previous build from " + os.path.join("build-" + platform.pkgPlatform + "-" + version) + "...",
sys.stdout.flush()
shutil.rmtree(buildRootDir)
print "ok"
os.mkdir(buildRootDir)
#
# If we can't find the source archive in the current directory, ask its location
#
if not os.path.exists(os.path.join(cwd, "Ice-" + version + ".tar.gz")):
print
src = raw_input("Couldn't find Ice-" + version + ".tar.gz in current directory, please specify\n" + \
"where to download or copy the source distribution or hit enter to \n" + \
"download it from sun:/share/srcdists/" + version + ": ")
if src == "":
src = "sun:/share/srcdists/" + version + "/Ice-" + version + ".tar.gz"
elif not src.endswith("Ice-" + version + ".tar.gz"):
src = os.path.join(src, "Ice-" + version + ".tar.gz")
if os.system("scp " + src + " ."):
print sys.argv[0] + ": couldn't copy " + src
sys.exit(1)
print "Unpacking ./Ice-" + version + ".tar.gz ...",
sys.stdout.flush()
os.chdir(buildRootDir)
if os.system("gunzip -c " + os.path.join(cwd, "Ice-" + version + ".tar.gz") + " | tar x" + quiet + "f -"):
print sys.argv[0] + ": failed to unpack ./Ice-" + version + ".tar.gz"
sys.exit(1)
os.rename("Ice-" + version, srcDir)
if "cpp-64" in buildLanguages:
if os.system("gunzip -c " + os.path.join(cwd, "Ice-" + version + ".tar.gz") + " | tar x" + quiet + "f -"):
print sys.argv[0] + ": failed to unpack ./Ice-" + version + ".tar.gz"
sys.exit(1)
os.rename("Ice-" + version, srcDir + "-64")
if "cpp-11" in buildLanguages:
if os.system("gunzip -c " + os.path.join(cwd, "Ice-" + version + ".tar.gz") + " | tar x" + quiet + "f -"):
print sys.argv[0] + ": failed to unpack ./Ice-" + version + ".tar.gz"
sys.exit(1)
os.rename("Ice-" + version, srcDir + "-11")
os.chdir(cwd)
print "ok"
os.mkdir(buildDir)
#
# Build and install each language mappings supported by this platform in the build directory.
#
for l in buildLanguages:
print
print "============= Building " + l + " sources ============="
print
if l == "cpp-64":
os.chdir(os.path.join(srcDir + "-64", "cpp"))
elif l == "cpp-11":
os.chdir(os.path.join(srcDir + "-11", "cpp"))
else:
os.chdir(os.path.join(srcDir, l))
makeOptions = platform.getMakeOptions() + " " + platform.getMakeEnvs(version, l) + " prefix=" + buildDir
if l == "java":
buildCmd = (platform.getJavaEnv() + " " + make + " " + " prefix=" + buildDir +
" " + platform.getJavaBuildOptions() + " install")
else:
buildCmd = make + " " + makeOptions + " install"
print "Building with " + buildCmd
if os.system(buildCmd) != 0:
print sys.argv[0] + ": `" + l + "' build failed"
os.chdir(cwd)
sys.exit(1)
os.chdir(os.path.join(cwd))
print
print "============= Finished buiding " + l + " sources ============="
print
if os.path.exists(os.path.join(buildDir, "doc")):
shutil.rmtree(os.path.join(buildDir, "doc"))
#
# Copy platform third party dependencies.
#
print "Copying third party dependencies..."
sys.stdout.flush()
platform.copyThirdPartyDependencies(buildDir)
platform.completeDistribution(buildDir, version)
#
# Copy platform specific files (README, SOURCES, etc)
#
print "Copying distribution files (README, SOURCES, etc)...",
sys.stdout.flush()
platform.copyDistributionFiles(distDir, buildDir)
copy(os.path.join(srcDir, "CHANGES"), os.path.join(buildDir, "CHANGES"))
print "ok"
#
# Everything should be clean now, we can create the binary distribution archive
#
platform.createArchive(cwd, buildRootDir, distDir, version, quiet)
#
# Done.
#
if forceclean:
print "Cleaning up...",
sys.stdout.flush()
shutil.rmtree(buildRootDir)
print "ok"
os.chdir(cwd)
|