Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 1d2ead4977a4ecef6a9e9dc6c2aa5879a8963d44 (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
<!--
    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="gitTag" value="master" />
	
	<target name="init_keyfile">
		<condition property="keyfile" value="C:\BUILD\ssh\swtbuild_dsa_private" else="/var/lib/hudson/swt/swtbuild_dsa_private">
			<os family="windows"/>
		</condition>
	</target>
	
	<available file="${basedir}/launcher.properties" property="launcherProperties" value="${basedir}/launcher.properties" />
	
	<!-- 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="win32.ia64" arg2="${ws}.${arch}" />
			</or>
		</condition>
	</target>
	
	<target name="init_fragment" >
		<!-- mac only has arch in fragment name for x86_64 -->
		<condition property="fragmentFolder" value="org.eclipse.equinox.launcher.${ws}.${os}.${arch}" 
											 else="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="copyMacPPC" if="copyMacPPC" >
		<scp file="${userName}@${machine}:${lib_dir}/eclipse"
			todir="${localGit}/rt.equinox.binaries/org.eclipse.equinox.executable/${exeFolder}/${ws}/${os}/ppc${mac_suffix}"
			keyfile="${keyfile}"
			trust="true"/>
	</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}" />
		<property name="userName" value="swtbuild" />
		<property name="localGit" value="../../.." />
		
		<!-- windows is built locally, everything else is remote -->
		<!-- Building every thing remote now
		condition property="local" >
			<equals arg1="${os}" arg2="win32"/>
		</condition-->
		<condition property="remote" >
			<not> <isset property="local"/> </not>
		</condition>
	</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,init_exeFolder,init_fragment">
		<echo message="Building for ${os}, ${ws}, ${arch}"/>
		<antcall target="buildLocal" />
		<antcall target="buildRemote" />
	</target>
	
	<target name="buildLocal" if="local" >
		<property name="tmpdir" value="${basedir}/${fragmentFolder}.${gitTag}"/>
		<property file="${localGit}/rt.equinox.framework/features/org.eclipse.equinox.executable.feature/library/make_version.mak" />
		<mkdir dir="${tmpdir}" />
		<copy todir="${tmpdir}">
			<fileset dir="${localGit}/rt.equinox.framework/features/org.eclipse.equinox.executable.feature/library" includes="**" />
		</copy>
		<exec dir="${tmpdir}/${ws}" executable="${tmpdir}/${ws}/build.bat" failonerror="true">
			<arg line="${arch}"/>
			<arg line="clean all" />
		</exec>
		<copy todir="${localGit}/rt.equinox.binaries/org.eclipse.equinox.executable/${exeFolder}/${ws}/${os}/${arch}">
			<fileset dir="${tmpdir}/${ws}" includes="*.exe"/>
		</copy>
		<copy todir="${localGit}/rt.equinox.binaries/${fragmentFolder}">
			<fileset dir="${tmpdir}/${ws}" includes="eclipse_${maj_ver}${min_ver}.dll"/>
		</copy>
		<delete dir="${tmpdir}"/>
	</target>
	
	<target name="buildRemote" if="remote" depends="init_keyfile">
		<echo message="Machine: ${machine}" />
		<condition property="remotebuilddir" value="c:/build" else="~/build/">
			<or>
				<equals arg1="${os}" arg2="win32"/>
			</or>
		</condition>
		<property name="remotetmpdir" value="${remotebuilddir}/${fragmentFolder}.${gitTag}"/>
		<property name="zip_file" value="${fragmentFolder}.${gitTag}.library.zip"/>
		<property file="${localGit}/rt.equinox.framework/features/org.eclipse.equinox.executable.feature/library/make_version.mak" />
		<zip basedir="${localGit}/rt.equinox.framework/features/org.eclipse.equinox.executable.feature/library" includes="**" destfile="${basedir}/${zip_file}"/>
		<scp file="${basedir}/${zip_file}"
			todir="${userName}@${machine}:${remotebuilddir}" 
			keyfile="${keyfile}"
			trust="true"/>
		<condition property="lib_dir" value="${remotetmpdir}/cocoa" else="${remotetmpdir}/${ws}" >
			<equals arg1="cocoa" arg2="${ws}" />
		</condition>
		<condition property="javaParam" value="" else="-java ${javaArg}" >
			<or>
				<equals arg1="macosx" arg2="${os}" />
				<not>
					<isset property="javaArg"/>
				</not>
			</or>
		</condition>
		<condition property="build_cmd" value="unix2dos *; unix2dos ${remotetmpdir}/win32/*; if cmd /c build.bat ${arch} clean all" else="if sh build.sh -os ${os} -ws ${ws} -arch ${arch} ${javaParam} all">
			<equals arg1="${os}" arg2="win32"/>
		</condition>
		<condition property="exit_cmd" value="exit;" else="">
			<or>
				<equals arg1="${os}" arg2="win32"/>
			</or>
		</condition>
                <condition property="unzip_options" value="" else="-aa">
                        <or>
                                <equals arg1="${os}" arg2="win32"/>
                        </or>
                </condition>
		<sshexec host="${machine}" 
			username="${userName}" 
			keyfile="${keyfile}" 
			trust="true"
	 		command="rm -rf ${remotetmpdir}; mkdir ${remotetmpdir}; cd ${remotetmpdir}; unzip ${unzip_options} ${remotebuilddir}/${zip_file}; cd ${lib_dir}; ${build_cmd}; then ${exit_cmd} cd; ${exit_cmd} else cd; rm -rf ${remotetmpdir}; rm ${remotebuilddir}/${zip_file}; exit 1; fi"/>
		<condition property="mac_suffix" value="/Eclipse.app/Contents/MacOS" else="">
			<equals arg1="macosx" arg2="${os}" />
		</condition>
		<condition property="exe" value="eclipse*.exe" else="eclipse">
			<or>
				<equals arg1="${os}" arg2="win32"/>
			</or>
		</condition>
		<scp file="${userName}@${machine}:${lib_dir}/${exe}"
			todir="${localGit}/rt.equinox.binaries/org.eclipse.equinox.executable/${exeFolder}/${ws}/${os}/${arch}${mac_suffix}"
			keyfile="${keyfile}"
			trust="true"/>
		<condition property="lib" value="eclipse_${maj_ver}${min_ver}.dll" else="eclipse_${maj_ver}${min_ver}.*">
			<or>
				<equals arg1="${os}" arg2="win32"/>
			</or>
		</condition>
		<scp file="${userName}@${machine}:${lib_dir}/${lib}"
			todir="${localGit}/rt.equinox.binaries/${fragmentFolder}"
			keyfile="${keyfile}"
			trust="true"/>
		<!-- x86 and ppc are the same universal binary, copy to both under the executable feature -->
		<condition property="copyMacPPC">
			<and>
				<equals arg1="${arch}" arg2="x86" />
				<equals arg1="${os}" arg2="macosx" />
			</and>
		</condition>
		<antcall target="copyMacPPC" />
		<sshexec host="${machine}" 
			username="${userName}" 
			keyfile="${keyfile}" 
			trust="true"
	 		command="rm -rf ${remotetmpdir}; rm ${remotebuilddir}/${zip_file}"/>
		<delete file="${basedir}/${zip_file}"/>
	</target>
	
	<target name="commitBinaries" depends="initProperties">
		<tstamp/>
		<property name="tag" value="v${DSTAMP}-${TSTAMP}"/>
		<property name="commitMsg" value="" />
		
		<git dir="${localGit}/rt.equinox.binaries" command="commit" arguments="-a -m &quot;Recompiled binaries ${commitMsg}&quot;" />
		<git dir="${localGit}/rt.equinox.binaries" command="tag" arguments="${tag}" />

		<replaceregexp match="binaryTag=(.*)" replace="binaryTag=${tag}" >
			<fileset dir="${localGit}/rt.equinox.framework" includes="**/build.properties" />
		</replaceregexp>
		<git dir="${localGit}/rt.equinox.framework" command="commit" arguments="-a -m &quot;Binaries ${tag} ${commitMsg}&quot;" />
	</target>
</project>

Back to the top