Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: e4547e7ee18f5a0077091bdbf0ed08a3e894b184 (plain) (blame)
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
<!--
    Copyright (c) 2009, 2011 IBM Corporation and others. 
    All rights reserved. This program and the accompanying materials
    are made available under the terms of the Eclipse Public License v1.0
    which accompanies this distribution, and is available at
    http://www.eclipse.org/legal/epl-v10.html
   
    Contributors:
        IBM Corporation - initial API and implementation
 -->
<project name="Launcher Build" basedir="." default="build">
	<property name="gitFrameworkRepo" value="git.eclipse.org/gitroot/equinox/rt.equinox.framework.git" />
	<property name="gitBinaryRepo" value="git.eclipse.org/gitroot/equinox/rt.equinox.binaries.git" />
	<property name="gitTag" value="master" />
	
	<available file="${basedir}/launcher.properties" property="launcherProperties" value="${basedir}/launcher.properties" />
	
	<!-- Macro for execing scp -->
	<macrodef name="SCP">
		<attribute name="dir" />
		<attribute name="source"/>
		<attribute name="destination" />
		<attribute name="flag" default="" />
		<attribute name="failonerror" default="true" />
		<sequential>
			<echo message="Copying @{source} to @{destination}."/>
			<exec dir="@{dir}" executable="scp" failonerror="@{failonerror}">
				<arg value="-q@{flag}"/>
				<arg line="@{source}" />
				<arg value="@{destination}" />
			</exec>
		</sequential>
	</macrodef>
	
	<!-- remote mkdir -->
	<macrodef name="mkremote">
		<attribute name="dir" />
		<sequential>
			<echo message="mkdir @{dir}" />
			<loadresource property="@{dir}_machine" >
				<string value="@{dir}" />
				<filterchain>
					<replaceregex pattern="^(([^@]*@)?([^:]*)):.*$" replace="\1" flags="g"/>
				</filterchain>
			</loadresource>
			<loadresource property="@{dir}_folder" >
				<string value="@{dir}" />
				<filterchain>
					<replaceregex pattern="^([^@]*@)?[^:]*:(.*)$" replace="\2" flags="g"/>
				</filterchain>
			</loadresource>	

			<exec executable="ssh" >
				<arg value="${@{dir}_machine}" />
				<arg line="mkdir -p ${@{dir}_folder}" />
			</exec>
		</sequential>
	</macrodef>

	<!-- macro to resolve properties because we can't do ${${prop}} -->
	<macrodef name="resolveProperty">
		<attribute name="name" />
		<attribute name="value" />
		<sequential>
			<condition property="@{name}" value="${@{value}}" >
				<isset property="@{value}"/>
			</condition>
		</sequential>
	</macrodef>
	
	<!-- macro for invoking git -->
	<macrodef name="git">
		<attribute name="dir" />
		<attribute name="command" />
		<attribute name="arguments" default="" />
		<sequential>
			<exec dir="@{dir}" executable="git" >
				<arg value="@{command}"/>
				<arg line="@{arguments}"/>
			</exec>
		</sequential>
	</macrodef>
	
	<target name="init_exeFolder" >
		<!-- set to "bin" or "contributed" according to which folder under org.eclipse.equinox.executable to store the built eclipse -->
		<condition property="exeFolder" value="contributed" else="bin">
			<or>
				<equals arg1="s390" arg2="${arch}" />
				<equals arg1="s390x" arg2="${arch}" />
				<equals arg1="motif.sparc" arg2="${ws}.${arch}" />
				<equals arg1="win32.ia64" arg2="${ws}.${arch}" />
			</or>
		</condition>
	</target>
	
	<target name="init_fragment" >
		<!-- set to "contributed" or "fragments" according to which folder under org.eclipse.equinox.launcher to find the fragment -->
		<condition property="subFolder" value="contributed" else="fragments">
			<or>
				<equals arg1="s390" arg2="${arch}" />
				<equals arg1="s390x" arg2="${arch}" />
				<equals arg1="solaris.x86" arg2="${os}.${arch}" />
			</or>
		</condition>
		<!-- mac only has arch in fragment name for x86_64 -->
		<condition property="fragmentFolder" value="${subFolder}/org.eclipse.equinox.launcher.${ws}.${os}.${arch}" 
											 else="${subFolder}/org.eclipse.equinox.launcher.${ws}.${os}" >
			<not>
				<and>
					<equals arg1="macosx" arg2="${os}"/>
					<not> <equals arg1="x86_64" arg2="${arch}"/> </not>
				</and>
			</not>
		</condition>
	</target>

	<target name="fetchExecutableSource" >
		<!-- fetch the source and put it in a folder unique to this platform so we don't interfere with other
		     compiles if the working folder is shared accross multiple machines -->
		<mkdir dir="${basedir}/${os}.${ws}.${arch}" />
		<delete dir="${basedir}/${os}.${ws}.${arch}/library" failonerror="false"/> 
		
		<git dir="${basedir}/${os}.${ws}.${arch}" command="clone" arguments="http://${gitFrameworkRepo}" />
		<git dir="${basedir}/${os}.${ws}.${arch}/rt.equinox.framework" command="checkout" arguments="${gitTag}" />
		<git dir="${basedir}/${os}.${ws}.${arch}/rt.equinox.framework" command="pull" />
		
		<copy todir="${basedir}/${os}.${ws}.${arch}/library" >
			<fileset dir="${basedir}/${os}.${ws}.${arch}/rt.equinox.framework/bundles/org.eclipse.equinox.executable/library" includes="**" />
		</copy>
	</target>
	
	<target name="buildNix" if="buildNix">
		<!-- exec the build.sh for flavors of unix -->
		<exec dir="${libraryFolder}/${ws}" executable="sh" failonerror="true">
				<arg value="build.sh"/>
				<arg line="-ws ${ws} -os ${os} -arch ${arch}"/>
				<arg line="-java ${javaHome}"/>
				<arg value="clean all" />
				<env key="PATH" value="/bin:/usr/bin:/usr/local/bin:/usr/sbin:/usr/X11R6/bin" />
		</exec>	
		
		<mkremote dir="${resultsBaseFolder}/org.eclipse.equinox.executable/${exeFolder}/${ws}/${os}/${arch}" />
		<mkremote dir="${resultsBaseFolder}/org.eclipse.equinox.launcher/${fragmentFolder}" />
		
		<!-- copy the resulting executable and .so -->
		<SCP dir="${libraryFolder}/${ws}" source="eclipse" destination="${resultsBaseFolder}/org.eclipse.equinox.executable/${exeFolder}/${ws}/${os}/${arch}" />
		<SCP dir="${libraryFolder}/${ws}" source="eclipse_${maj_ver}${min_ver}.so" destination="${resultsBaseFolder}/org.eclipse.equinox.launcher/${fragmentFolder}" />
		
		<condition property="copyMotifLib" >
			<equals arg1="aix.motif" arg2="${os}.${ws}" />
		</condition>
		<antcall target="copyMotifLib" />
	</target>
			
	<target name="copyMotifLib" if="copyMotifLib" >
		<SCP dir="${libraryFolder}/${ws}" source="libeclipse-motif.so" destination="${resultsBaseFolder}/org.eclipse.equinox.launcher/${fragmentFolder}" failonerror="false" />
	</target>
	
	<target name="buildS390" if="buildS390">
		<condition property="remoteHost" value="${host_s390}" else="${host_s390x}" >
			<equals arg1="${arch}" arg2="s390"/>
		</condition>
		
		<SCP dir="${basedir}" source="library.zip" destination="${remoteHost}:~/equinox" />
		
		<exec dir="${basedir}" executable="ssh" failonerror="true">
			<arg value="${remoteHost}"/>
			<arg value="cd equinox; rm -rf library; unzip -q library.zip; library/gtk/build.sh"/>
		</exec>	
		
		<mkremote dir="${resultsBaseFolder}/org.eclipse.equinox.executable/${exeFolder}/${ws}/${os}/${arch}" />
		<mkremote dir="${resultsBaseFolder}/org.eclipse.equinox.launcher/${fragmentFolder}" />
		
		<!-- copy the resulting executable and .so -->
		<SCP dir="${basedir}" source="${remoteHost}:~/equinox/library/gtk/eclipse" destination="${resultsBaseFolder}/org.eclipse.equinox.executable/${exeFolder}/${ws}/${os}/${arch}" />
		<SCP dir="${basedir}" source="${remoteHost}:~/equinox/library/gtk/eclipse_*.so" destination="${resultsBaseFolder}/org.eclipse.equinox.launcher/${fragmentFolder}" />
	</target>
				
	<target name="buildWindows" if="buildWindows">
		<!-- exec the batch file to build on windows -->
		<exec dir="${libraryFolder}/${ws}" executable="cmd" failonerror="true">
			<arg value="/c" />
			<arg value="build.bat" />
			<arg line="${arch}"/>
			<arg value="-java"/>
			<arg value="${javaHome}"/>
			<arg line="clean all" />
		</exec>
		
		<mkremote dir="${resultsBaseFolder}/org.eclipse.equinox.executable/${exeFolder}/${ws}/${os}/${arch}" />
		<mkremote dir="${resultsBaseFolder}/org.eclipse.equinox.launcher/${fragmentFolder}" />
		
		<SCP dir="${libraryFolder}/${ws}" source="eclipse.exe eclipsec.exe" destination="${resultsBaseFolder}/org.eclipse.equinox.executable/${exeFolder}/${ws}/${os}/${arch}" />
		<SCP dir="${libraryFolder}/${ws}" source="eclipse_${maj_ver}${min_ver}.dll" destination="${resultsBaseFolder}/org.eclipse.equinox.launcher/${fragmentFolder}" />
		<condition property="copyWPF">
			<equals arg1="${ws}" arg2="wpf" />
		</condition>
		<antcall target="copyWPF" />
	</target>
	
	<target name="copyWPF" if="copyWPF" >
		<mkremote dir="${resultsBaseFolder}/org.eclipse.equinox.launcher/${fragmentFolder}" />
		<SCP dir="${libraryFolder}/${ws}" source="com_${maj_ver}${min_ver}.dll" destination="${resultsBaseFolder}/org.eclipse.equinox.launcher/${fragmentFolder}" failonerror="false" />
	</target>
	
	<target name="buildMac" if="buildMac">
		<exec dir="${libraryFolder}/carbon" executable="sh" failonerror="true">
			<arg value="build.sh"/>
			<arg line="-ws ${ws} -arch ${arch}"/>
			<arg value="clean all" />
			<env key="PATH" value="/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:${extraPath}" />
		</exec>	

		<mkremote dir="${resultsBaseFolder}/org.eclipse.equinox.executable/${exeFolder}/${ws}/${os}/${arch}/Eclipse.app/Contents/MacOS"/>
		<mkremote dir="${resultsBaseFolder}/org.eclipse.equinox.launcher/${fragmentFolder}" />
		<SCP dir="${libraryFolder}/carbon" source="eclipse" destination="${resultsBaseFolder}/org.eclipse.equinox.executable/${exeFolder}/${ws}/${os}/${arch}/Eclipse.app/Contents/MacOS" />
		<SCP dir="${libraryFolder}/carbon" source="eclipse_${maj_ver}${min_ver}.so" destination="${resultsBaseFolder}/org.eclipse.equinox.launcher/${fragmentFolder}" />
		<!-- x86 and ppc are the same universal binary, copy to both under the executable feature -->
		<condition property="copyMacPPC">
			<equals arg1="${arch}" arg2="x86" />
		</condition>
		<antcall target="copyMacPPC" />
	</target>
	
	<target name="copyMacPPC" if="copyMacPPC" >
		<mkremote dir="${resultsBaseFolder}/org.eclipse.equinox.executable/${exeFolder}/${ws}/${os}/ppc/Eclipse.app/Contents/MacOS" />
		<SCP dir="${libraryFolder}/carbon" source="eclipse" destination="${resultsBaseFolder}/org.eclipse.equinox.executable/${exeFolder}/${ws}/${os}/ppc/Eclipse.app/Contents/MacOS" />
	</target>
	
	<target name="determineBuild" >
		<condition property="buildWindows" >
			<equals arg1="${os}" arg2="win32"/>
		</condition>
		<condition property="buildMac" >
			<equals arg1="${os}" arg2="macosx" />
		</condition>
		<condition property="buildS390" >
			<contains string="${arch}" substring="s390" />
		</condition>
		<condition property="buildNix" >
			<not><or>
				<isset property="buildWindows" />
				<isset property="buildMac" />
				<isset property="buildS390" />
			</or></not>
		</condition>
	</target>
	
	<target name="loadProperties" if="launcherProperties" >
		<property file="${launcherProperties}" />
	</target>
	
	<target name="initProperties" depends="loadProperties" >
		<property name="ws" value="${env.ws}"/>
		<property name="os" value="${env.os}" />	
		<property name="arch" value="${env.arch}" />
		
		<resolveProperty name="machine" value="m_${os}.${arch}" />
		<resolveProperty name="javaArg" value="j_${os}.${arch}" />
		<resolveProperty name="userName" value="u_${os}.${arch}" />
		
		<!-- windows is built locally, everything else is remote -->
		<condition property="local" >
			<equals arg1="${os}" arg2="win32"/>
		</condition>
		<condition property="remote" >
			<not> <isset property="local"/> </not>
		</condition>
		
		<!-- working directory defaults for our machines.  Others should
		     pass in workspace as a property on the command line  -->
		<condition property="workspace" value="/Users/swtbuild/build/equinox" >
			<equals arg1="${os}" arg2="macosx"/>
		</condition>
		<condition property="workspace" value="~/equinox" >
			<equals arg1="${os}.${arch}" arg2="solaris.x86" />
		</condition>
		<property name="workspace" value="/bluebird/teamswt/equinox" />
	</target>
	
	
	<!-- 
		Main entry point.  We expect the following properties:
			 os, ws, arch  - to be passed as ant properties or set as environment variables.
			 resultsBaseFolder - location to scp the resulting binaries to, usually a workspace containing the executable & launcher projects (eg: user@machine:~/workspace)
			 m_<os>.<arch> - name of a machine to ssh to for this os & arch
			 u_<os>.<arch> - optional user on the machine for this platform
			 j_<os>.<arch> - location of a jdk we can compile against
		We expect ssh keys to be set up so that we don't need passwords
		
		The j_<os>.<arch> properties work together with remote.sh, and are either
		   -javaHome /path/to/jdk
		or -java relative/path/to/jdk
	-->
	<target name="build" depends="initProperties">
		<echo message="Building for ${os}, ${ws}, ${arch}"/>
		<antcall target="buildLocal" />
		<antcall target="buildRemote" />
	</target>
	
	<target name="cloneGitRepos" unless="gitRepoExists" >
		<git dir="${staging}" command="clone" arguments="ssh://${gitBinaryRepo}"  />
		<git dir="${staging}" command="clone" arguments="ssh://${gitFrameworkRepo}" />
	</target>
	
	
	<target name="stageBinaries" depends="initProperties">
		<tstamp/>
		<property name="tag" value="v${DSTAMP}-${TSTAMP}"/>
		<property name="staging" value="${basedir}/staging" />
		<property name="commitMsg" value="" />
		
		<available file="${staging}/rt.equinox.binaries" type="dir" property="gitRepoExists" />
		<antcall target="cloneGitRepos" />
		
		<git dir="${staging}/rt.equinox.binaries" command="checkout" arguments="${gitTag}" />
		<git dir="${staging}/rt.equinox.framework" command="checkout" arguments="${gitTag}" />
		
		<git dir="${staging}/rt.equinox.binaries" command="pull" />
		<git dir="${staging}/rt.equinox.framework" command="pull" />
		
		<SCP dir="${staging}" flag="r" source="${resultsBaseFolder}/org.eclipse.equinox.executable/*" destination="${staging}/rt.equinox.binaries/org.eclipse.equinox.executable" />
		<SCP dir="${staging}" flag="r" source="${resultsBaseFolder}/org.eclipse.equinox.launcher/fragments/*"     destination="${staging}/rt.equinox.binaries" />
		<SCP dir="${staging}" flag="r" source="${resultsBaseFolder}/org.eclipse.equinox.launcher/contributed/*"   destination="${staging}/rt.equinox.binaries" />

		<git dir="${staging}/rt.equinox.binaries" command="commit" arguments="-a -m &quot;Recompiled binaries ${commitMsg}&quot;" />
		<git dir="${staging}/rt.equinox.binaries" command="tag" arguments="${tag}" />
		<git dir="${staging}/rt.equinox.binaries" command="push" />
		<git dir="${staging}/rt.equinox.binaries" command="push" arguments="--tags" />

		<replaceregexp match="binaryTag=(.*)" replace="binaryTag=${tag}" >
			<fileset dir="${staging}/rt.equinox.framework" includes="**/build.properties" />
		</replaceregexp>
		<git dir="${staging}/rt.equinox.framework" command="commit" arguments="-a -m &quot;Binaries ${tag} ${commitMsg}&quot;" />
		<git dir="${staging}/rt.equinox.framework" command="push" />
		
	</target>
		
	<target name="buildLocal" if="local" >
		<condition property="javaHome" value="${j_win32}" else="${java.home}" >
			<isset property="j_win32"/>
		</condition>
		
		<mkdir dir="${basedir}/${os}.${ws}.${arch}/library" />
		<copy todir="${basedir}/${os}.${ws}.${arch}/library" >
			<fileset dir="${localGitClone}/bundles/org.eclipse.equinox.executable/library" includes="**" />
		</copy>
		
		<antcall target="buildConfig" />
	</target>
	
	<target name="buildRemote" if="remote">
		<echo message="Machine: ${machine}" />
		<condition property="scpDest" value="${userName}@${machine}" else="${machine}" >
			<isset property="userName" />
		</condition>
		<condition property="sshUser" value="-l ${userName}" else="" >
			<isset property="userName" />
		</condition>
		
		<zip basedir="${localGitClone}/bundles/org.eclipse.equinox.executable/library" includes="**" destfile="${basedir}/library.zip" />
		<mkremote dir="${scpDest}:${workspace}/${os}.${ws}.${arch}"/>
		<SCP dir="${basedir}" source="remote.sh build.xml library.zip" destination="${scpDest}:${workspace}/${os}.${ws}.${arch}" />
		<echo message="Execing ssh ${machine}" />
		<exec executable="ssh" failonerror="true" >
			<arg line="${sshUser} ${machine}" />
			<arg line="sh ${workspace}/${os}.${ws}.${arch}/remote.sh" />
			<arg line="${javaArg}" />
			<arg line="-Dos=${os} -Dws=${ws} -Darch=${arch} -DgitTag=${gitTag}" />
			<arg value="-DresultsBaseFolder=${resultsBaseFolder}" />
		</exec>
	</target>

	<target name="buildConfig" depends="init_exeFolder,init_fragment,determineBuild" >
		<!--<antcall target="fetchExecutableSource" />-->
		<property name="javaHome" value="${java.home}/.." />
		<property name="libraryFolder" value="${basedir}/library" />
		
		<delete dir="${libraryFolder}" failonerror="false" />
		<mkdir dir="${libraryFolder}" />
		<unzip src="${basedir}/library.zip" dest="${libraryFolder}" />
		
		<property file="${libraryFolder}/make_version.mak" />
		
		<antcall target="buildNix" />
		<antcall target="buildWindows" />
		<antcall target="buildMac" />
		<antcall target="buildS390" />
	</target>
	
</project>




Back to the top