Fix compile.
[cyberduck.git] / build-mac.xml
blob7d376a20ab3da26ecf1d8b114c1c23aec4b8ba20
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3  *      Simple Ant (http://jakarta.apache.org/ant) build script for Cyberduck
4  *
5  *      $Revision: 6757 $
6  *      $Date: 2010-08-25 13:25:44 +0200 (Mi, 25 Aug 2010) $
7  *
8  *  Copyright (c) 2005-2012 David Kocher. All rights reserved.
9  *  http://cyberduck.io/
10  *
11  *      This program is free software; you can redistribute it and/or modify
12  *      it under the terms of the GNU General Public License as published by
13  *      the Free Software Foundation; either version 2 of the License, or
14  *      (at your option) any later version.package
15  *
16  *      This program is distributed in the hope that it will be useful,
17  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
18  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  *      GNU General Public License for more details.
20  *
21  *      Bug fixes, suggestions and comments should be sent to:
22  *      dkocher@cyberduck.io
23  -->
24 <project name="Cyberduck for Mac" basedir=".">
26     <import file="build.xml"/>
28     <property name="app.bundle" value="${build}/${app.name}.app"/>
29     <property name="cli.bundle" value="${build}/duck.bundle"/>
31     <property name="bundle.contents" value="Contents"/>
32     <property name="bundle.home" value="${bundle.contents}/Home"/>
33     <property name="bundle.macos" value="${bundle.contents}/MacOS"/>
34     <property name="bundle.library" value="${bundle.contents}/Library"/>
35     <property name="bundle.frameworks" value="${bundle.contents}/Frameworks"/>
36     <property name="bundle.resources" value="${bundle.contents}/Resources"/>
37     <property name="bundle.spotlight" value="${bundle.library}/Spotlight"/>
38     <property name="bundle.profiles" value="${bundle.resources}/Profiles"/>
39     <property name="bundle.bookmarks" value="${bundle.resources}/Bookmarks"/>
40     <property name="bundle.runtime" value="${bundle.macos}/Runtime.jre"/>
41     <property name="bundle.runtime.lib"
42               value="@executable_path/../MacOS/Runtime.jre/Contents/Home/lib/server/libjvm.dylib"/>
44     <property name="app.runtime.system.min" value="10.6"/>
46     <property name="jvm.runtime.home" value="${lib}/1.7.0-u40-b30.jre"/>
47     <property name="jvm.runtime.bin" value="${jvm.runtime.home}/${bundle.home}/bin"/>
49     <property name="codesign.certificate" value="Developer ID Application: David Kocher"/>
50     <property name="codesign.keychain" value="${user.home}/Library/Keychains/codesign.keychain"/>
51     <property name="codesign.entitlements" value="${home}/sandbox.plist"/>
52     <!-- Designated requirement -->
53     <property name="codesign.requirement.source" value="${home}/codesign-requirement.txt"/>
54     <property name="codesign.requirement" value="${home}/codesign-requirement.bin"/>
55     <property name="codesign.options" value="--timestamp=none --force"/>
56     <property name="codesign.arg"
57               value="--entitlements ${codesign.entitlements} --requirements ${codesign.requirement}"/>
59     <property name="keychain.password" value=""/>
61     <property name="installer.certificate" value="3rd Party Mac Developer Installer: David Kocher (G69SCX94XU)"/>
62     <property name="installer.keychain" value="${user.home}/Library/Keychains/codesign.keychain"/>
64     <property name="sparkle.feed" value="/dev/null"/>
66     <property name="spotlight" value="${home}/Spotlight Importer"/>
67     <property name="build.spotlight" value="${spotlight}/build/${configuration}"/>
69     <property name="build.xcodeoptions" value="SDKROOT=macosx10.9 MACOSX_DEPLOYMENT_TARGET=${app.runtime.system.min}"/>
71     <property name="build.lipo.binaries" value="**/Contents/MacOS/*,**/*.framework/Versions/Current/*,**/*.dylib"/>
72     <property name="build.lipo.arch.remove" value=""/>
74     <target name="spotlight">
75         <property name="build.settings"
76                   value="${build.xcodeoptions} VERSION=${version} REVISION=${revision} SPARKLEFEED=${sparkle.feed} COPYRIGHT='${copyright}'"/>
77         <exec dir="${spotlight}" executable="/usr/bin/xcrun" spawn="false" failonerror="true">
78             <arg line="--verbose xcodebuild -project 'Spotlight Importer.xcodeproj' -configuration Release ${build.settings}"/>
79         </exec>
80         <copy todir="${app.bundle}/${bundle.spotlight}">
81             <fileset dir="${build.spotlight}">
82                 <include name="*.mdimporter/**"/>
83             </fileset>
84         </copy>
85         <chmod perm="a+x" type="file">
86             <fileset dir="${app.bundle}/${bundle.spotlight}">
87                 <include name="**/MacOS/*"/>
88             </fileset>
89         </chmod>
90         <apply executable="/usr/bin/codesign" failonerror="true"
91                type="both"
92                parallel="false" spawn="false" force="true">
93             <arg line="${codesign.options} --sign '${codesign.certificate}' --keychain ${codesign.keychain} -v"/>
94             <fileset dir="${app.bundle}/${bundle.spotlight}">
95                 <include name="*.mdimporter"/>
96             </fileset>
97             <srcfile/>
98         </apply>
99     </target>
101     <target name="_build" depends="spotlight">
102         <echo message="Building ${app.bundle}"/>
103         <property name="build.settings"
104                   value="${build.xcodeoptions} VERSION=${version} REVISION=${revision} SPARKLEFEED=${sparkle.feed} COPYRIGHT='${copyright}'"/>
105         <exec dir="${home}" executable="/usr/bin/xcrun" spawn="false" failonerror="true">
106             <arg line="--verbose xcodebuild -project ${app.name}.xcodeproj -configuration Release -target app ${build.settings}"/>
107         </exec>
108         <copy todir="${app.bundle}/${bundle.frameworks}">
109             <!-- Dynamic libraries built with xcodebuild -->
110             <fileset dir="${build}">
111                 <include name="*.dylib"/>
112             </fileset>
113             <fileset dir="${lib}">
114                 <!-- Include libjnidispatch.dylib -->
115                 <include name="*.dylib"/>
116             </fileset>
117         </copy>
118         <copy todir="${app.bundle}/${bundle.resources}">
119             <fileset dir="${build}">
120                 <include name="*.jar"/>
121             </fileset>
122             <fileset dir="${lib}">
123                 <include name="*.jar"/>
124             </fileset>
125         </copy>
126         <mkdir dir="${app.bundle}/${bundle.runtime}/${bundle.home}"/>
127         <!-- Copy runtime -->
128         <echo message="Copy runtime from ${jvm.runtime.home} to ${app.bundle}/${bundle.runtime}..."/>
129         <copy todir="${app.bundle}/${bundle.runtime}" preservelastmodified="true">
130             <fileset followsymlinks="false" dir="${jvm.runtime.home}" excludesfile="runtime-excludes.properties"/>
131         </copy>
132         <antcall target="shared-library-install-name">
133             <param name="oldname" value="/System/Library/Frameworks/JavaVM.framework/Versions/A/JavaVM"/>
134             <param name="newname" value="${bundle.runtime.lib}"/>
135             <param name="directory" value="${app.bundle}/${bundle.frameworks}"/>
136         </antcall>
137         <!-- Remove architectures -->
138         <foreach target="lipo" param="arch" list="${build.lipo.arch.remove}">
139             <param name="directory" value="${app.bundle}"/>
140         </foreach>
141     </target>
143     <target name="_cli">
144         <echo message="Building ${cli.bundle}"/>
145         <property name="build.settings"
146                   value="MACOSX_DEPLOYMENT_TARGET=${app.runtime.system.min} VERSION=${version} REVISION=${revision} COPYRIGHT='${copyright}'"/>
147         <exec dir="${home}" executable="/usr/bin/xcrun" spawn="false" failonerror="true">
148             <arg line="--verbose xcodebuild -project ${app.name}.xcodeproj -configuration Release -target cli ${build.settings}"/>
149         </exec>
150         <copy todir="${cli.bundle}/${bundle.frameworks}">
151             <!-- Dynamic libraries built with xcodebuild -->
152             <fileset dir="${build}">
153                 <include name="*.dylib"/>
154             </fileset>
155             <fileset dir="${lib}">
156                 <!-- Include libjnidispatch.dylib -->
157                 <include name="*.dylib"/>
158             </fileset>
159         </copy>
160         <copy todir="${cli.bundle}/${bundle.resources}">
161             <fileset dir="${build}">
162                 <include name="*.jar"/>
163             </fileset>
164             <fileset dir="${lib}">
165                 <include name="*.jar"/>
166             </fileset>
167         </copy>
168         <mkdir dir="${app.bundle}/${bundle.runtime}/${bundle.home}"/>
169         <!-- Copy runtime -->
170         <echo message="Copy runtime from ${jvm.runtime.home} to ${cli.bundle}/${bundle.runtime}..."/>
171         <copy todir="${cli.bundle}/${bundle.runtime}" preservelastmodified="true">
172             <fileset followsymlinks="false" dir="${jvm.runtime.home}" excludesfile="runtime-excludes.properties"/>
173         </copy>
174         <symlink link="${cli.bundle}/${bundle.runtime}/Contents/MacOS/libjli.dylib" resource="../Home/lib/jli/libjli.dylib"
175                  overwrite="true"/>
176         <antcall target="shared-library-install-name">
177             <param name="oldname" value="/System/Library/Frameworks/JavaVM.framework/Versions/A/JavaVM"/>
178             <param name="newname" value="${bundle.runtime.lib}"/>
179             <param name="directory" value="${cli.bundle}/${bundle.frameworks}"/>
180         </antcall>
181         <!-- Remove architectures -->
182         <foreach target="lipo" param="arch" list="${build.lipo.arch.remove}">
183             <param name="directory" value="${cli.bundle}"/>
184         </foreach>
185         <antcall target="codesign">
186             <param name="bundle" value="${cli.bundle}"/>
187             <param name="codesign.options" value="--force"/>
188             <!-- No sandboxing enabled -->
189             <param name="codesign.arg"
190                    value="--requirements ${codesign.requirement}"/>
191             <param name="codesign.certificate" value="Developer ID Application: David Kocher"/>
192         </antcall>
193         <antcall target="verify-spctl">
194             <param name="bundle" value="${cli.bundle}"/>
195         </antcall>
196         <antcall target="tar">
197             <param name="directory" value="${build}"/>
198             <param name="source" value="duck.bundle"/>
199             <param name="target" value="duck-${svn.revision}.tar.gz"/>
200         </antcall>
201         <checksum file="${build.deploy}/duck-${svn.revision}.tar.gz"
202                   algorithm="sha1" property="sha1"/>
203         <copy todir="${build.deploy}" overwrite="true">
204             <fileset dir="${www.update}">
205                 <include name="duck.rb"/>
206             </fileset>
207         </copy>
208         <replace dir="${build.deploy}" summary="true" encoding="UTF-8">
209             <include name="duck.rb"/>
210             <replacefilter token="${SHA1}" value="${sha1}"/>
211             <replacefilter token="${REVISION}" value="${svn.revision}"/>
212             <replacefilter token="${VERSION}" value="${version}"/>
213         </replace>
214     </target>
216     <target name="deploy-sparkle" depends="timestamp, revision">
217         <antcall target="codesign">
218             <param name="bundle" value="${app.bundle}"/>
219             <param name="codesign.options" value="--force"/>
220             <!-- No sandboxing enabled -->
221             <param name="codesign.arg"
222                    value="--requirements ${codesign.requirement}"/>
223             <param name="codesign.certificate" value="Developer ID Application: David Kocher"/>
224         </antcall>
225         <antcall target="verify-spctl">
226             <param name="bundle" value="${app.bundle}"/>
227         </antcall>
228         <antcall target="tar">
229             <param name="directory" value="${build}"/>
230             <param name="target" value="${app.name}-${revision}.tar.gz"/>
231             <param name="source" value="${app.name}.app"/>
232         </antcall>
233         <antcall target="zip">
234             <param name="directory" value="${build}"/>
235             <param name="target" value="${app.name}-${version}.zip"/>
236             <param name="source" value="${app.name}.app"/>
237         </antcall>
238         <checksum file="${build.deploy}/${app.name}-${revision}.tar.gz"
239                   algorithm="md5" property="md5sum"/>
240         <echo message="Calculating DSA signature..."/>
241         <exec dir="${home}" executable="sh" outputproperty="signature.dsa" failonerror="true">
242             <arg value="-o"/>
243             <arg value="pipefail"/>
244             <arg value="-c"/>
245             <arg value="openssl dgst -sha1 -binary '${build.deploy}/${app.name}-${revision}.tar.gz' | openssl dgst -dss1 -sign ${www.update}/private.pem | openssl enc -base64"/>
246         </exec>
247         <echo message="DSASIGNATURE=${signature.dsa}"/>
248         <echo message="MD5SUM=${md5sum}"/>
249         <copy todir="${build.deploy}" overwrite="true">
250             <fileset dir="${www.update}">
251                 <include name="changelog.rss"/>
252                 <include name="changelog.html"/>
253             </fileset>
254         </copy>
255         <replace dir="${build.deploy}" summary="true" encoding="UTF-8">
256             <include name="changelog.rss"/>
257             <replacefilter token="${TIMESTAMP}" value="${touch.time}"/>
258             <replacefilter token="${ARCHIVE}" value="${url.archive}"/>
259             <replacefilter token="${CHANGELOG}" value="${url.changelog}"/>
260             <replacefilter token="${REVISION}" value="${revision}"/>
261             <replacefilter token="${VERSION}" value="${version}"/>
262             <replacefilter token="${DSASIGNATURE}" value="${signature.dsa}"/>
263             <replacefilter token="${COPYRIGHT}" value="'${copyright}"/>
264             <replacefilter token="${MACOSX_DEPLOYMENT_TARGET}" value="${app.runtime.system.min}"/>
265         </replace>
266     </target>
268     <target name="deploy-mas">
269         <replace dir="${app.bundle}/${bundle.contents}" summary="true" encoding="UTF-8">
270             <include name="Info.plist"/>
271             <!-- Disable Sparkle Keys -->
272             <replacefilter token="SU" value="None"/>
273         </replace>
274         <delete dir="${app.bundle}/${bundle.frameworks}/Sparkle.framework"/>
275         <antcall target="codesign">
276             <param name="bundle" value="${app.bundle}"/>
277             <param name="codesign.options" value="--force"/>
278             <param name="codesign.arg"
279                    value="--entitlements ${codesign.entitlements}"/>
280             <param name="codesign.certificate" value="3rd Party Mac Developer Application: David Kocher (G69SCX94XU)"/>
281         </antcall>
282         <echo message="Building ${build.deploy}/${app.name}-${version}.pkg"/>
283         <exec dir="${build.deploy}" executable="/usr/bin/productbuild" spawn="false" failonerror="true">
284             <arg line="--component ${app.bundle} /Applications --version ${version} --sign '${installer.certificate}' --keychain ${installer.keychain} ${build.deploy}/${app.name}-${version}.pkg"/>
285         </exec>
286         <checksum file="${build.deploy}/${app.name}-${version}.pkg"
287                   algorithm="md5"/>
288     </target>
290     <target name="lipo">
291         <echo message="Remove ${arch} slice from ${build.lipo.binaries}"/>
292         <apply executable="/usr/bin/lipo" failonerror="false" dest="${directory}"
293                parallel="false" spawn="false" force="true">
294             <!--Remove from executables-->
295             <!--Remove from frameworks-->
296             <!--Remove from shared libraries-->
297             <fileset dir="${directory}" includes="${build.lipo.binaries}"/>
298             <arg line="-remove ${arch} -output"/>
299             <srcfile/>
300             <targetfile/>
301             <identitymapper/>
302         </apply>
303     </target>
305     <target name="shared-library-install-name">
306         <echo message="Change dynamic shared library install names to ${newname}"/>
307         <apply executable="/usr/bin/install_name_tool" failonerror="true"
308                type="file"
309                parallel="false" spawn="false" force="true">
310             <arg line="-change ${oldname} ${newname}"/>
311             <fileset dir="${directory}">
312                 <include name="*.dylib"/>
313             </fileset>
314             <srcfile/>
315         </apply>
316     </target>
318     <target name="codesign" depends="unlock-keychain, compile-codesign-requirement">
319         <echo message="Code signing ${bundle} with certificate ${codesign.certificate} and entitlements ${codesign.arg}..."/>
320         <apply executable="/usr/bin/codesign" failonerror="true"
321                type="both"
322                parallel="false" spawn="false" force="true">
323             <arg line="${codesign.options} --identifier ch.sudo.cyberduck --sign '${codesign.certificate}' --keychain ${codesign.keychain} ${codesign.arg} -v"/>
324             <fileset dir="${bundle}/${bundle.frameworks}">
325                 <include name="*.dylib"/>
326                 <include name="*.jar"/>
327             </fileset>
328             <srcfile/>
329         </apply>
330         <apply executable="/usr/bin/codesign" failonerror="true"
331                type="both"
332                parallel="false" spawn="false" force="true">
333             <arg line="${codesign.options} --identifier net.java.openjdk.jre --sign '${codesign.certificate}' --keychain ${codesign.keychain} -v"/>
334             <fileset dir="${bundle}/${bundle.runtime}" erroronmissingdir="false">
335                 <include name="**/*.dylib"/>
336                 <include name="**/*.jar"/>
337             </fileset>
338             <fileset dir="${bundle}/${bundle.macos}">
339                 <include name="*.jre"/>
340             </fileset>
341             <srcfile/>
342         </apply>
343         <apply executable="/usr/bin/codesign" failonerror="true"
344                type="both"
345                parallel="false" spawn="false" force="true">
346             <arg line="${codesign.options} --sign '${codesign.certificate}' --keychain ${codesign.keychain} -v"/>
347             <fileset dir="${bundle}/${bundle.frameworks}">
348                 <include name="*.framework/Versions/A"/>
349             </fileset>
350             <srcfile/>
351         </apply>
352         <apply executable="/usr/bin/codesign" failonerror="true"
353                type="both"
354                parallel="false" spawn="false" force="true">
355             <arg line="${codesign.options} --sign '${codesign.certificate}' --keychain ${codesign.keychain} ${codesign.arg} -v"/>
356             <file name="${bundle}"/>
357             <srcfile/>
358         </apply>
359         <antcall target="verify-signature">
360             <param name="bundle" value="${bundle}"/>
361         </antcall>
362     </target>
364     <target name="unlock-keychain">
365         <exec executable="/usr/bin/security" failonerror="true">
366             <arg line="unlock-keychain -p ${keychain.password} ${codesign.keychain}"/>
367         </exec>
368     </target>
370     <target name="compile-codesign-requirement">
371         <echo message="Compile codesign requirement ${codesign.requirement}..."/>
372         <exec executable="/usr/bin/csreq" failonerror="true">
373             <arg line="-r ${codesign.requirement.source} -b ${codesign.requirement}"/>
374         </exec>
375     </target>
377     <target name="verify-signature">
378         <echo message="Print codesign requirement for ${bundle}..."/>
379         <exec executable="/usr/bin/codesign" failonerror="true">
380             <arg line="-d -r- --deep-verify ${bundle}"/>
381         </exec>
382     </target>
384     <target name="verify-spctl">
385         <echo message="Print system policy verification for ${bundle}..."/>
386         <exec executable="/usr/sbin/spctl" failonerror="true">
387             <arg line="-v --assess --type execute ${bundle}"/>
388         </exec>
389     </target>
391     <target name="tar">
392         <echo message="Creating tar.gz archive from ${directory}/${source}"/>
393         <exec dir="${directory}" executable="tar" spawn="false" failonerror="true">
394             <arg line="-czf ${build.deploy}/${target} ${source}"/>
395         </exec>
396         <echo message="Calculating MD5 sum..."/>
397         <checksum file="${build.deploy}/${target}" algorithm="md5"/>
398     </target>
400     <target name="zip">
401         <echo message="Creating ZIP archive from ${directory}/${source}"/>
402         <exec dir="${directory}" executable="ditto" spawn="false" failonerror="true">
403             <arg line="-c -k --sequesterRsrc --keepParent ${source} ${build.deploy}/${target}"/>
404         </exec>
405         <checksum file="${build.deploy}/${target}" algorithm="md5"/>
406     </target>
408     <target name="nightly" depends="revision">
409         <antcall target="build">
410             <param name="app.runtime.system.min" value="10.6"/>
411             <param name="sparkle.feed" value="https://version.cyberduck.io/nightly/changelog.rss"/>
412         </antcall>
413         <antcall target="deploy-sparkle">
414             <param name="url.archive" value="https://update.cyberduck.io/nightly/Cyberduck-${revision}.tar.gz"/>
415             <param name="url.changelog" value="https://version.cyberduck.io/nightly/changelog.html"/>
416         </antcall>
417     </target>
419     <target name="beta" depends="revision">
420         <antcall target="build">
421             <param name="app.runtime.system.min" value="10.6"/>
422             <param name="sparkle.feed" value="https://version.cyberduck.io/beta/changelog.rss"/>
423         </antcall>
424         <antcall target="deploy-sparkle">
425             <param name="url.archive" value="https://update.cyberduck.io/beta/Cyberduck-${revision}.tar.gz"/>
426             <param name="url.changelog" value="https://version.cyberduck.io/beta/changelog.html"/>
427         </antcall>
428     </target>
430     <target name="release" depends="revision">
431         <antcall target="build">
432             <param name="app.runtime.system.min" value="10.6"/>
433             <param name="sparkle.feed" value="https://version.cyberduck.io/changelog.rss"/>
434         </antcall>
435         <antcall target="deploy-sparkle">
436             <param name="url.archive" value="https://update.cyberduck.io/Cyberduck-${revision}.tar.gz"/>
437             <param name="url.changelog" value="https://version.cyberduck.io/changelog.html"/>
438         </antcall>
439     </target>
441     <target name="mas">
442         <antcall target="build">
443             <param name="app.runtime.system.min" value="10.7.3"/>
444         </antcall>
445         <antcall target="deploy-mas"/>
446     </target>
447 </project>