source: other-projects/expeditee-release-kits/kits/rke/ant-scripts/wrap.xml@ 28741

Last change on this file since 28741 was 28741, checked in by ak19, 8 years ago

Expeditee team (jts21). Test/fix changes to Mac dmg, add generated DS_Store

File size: 9.7 KB
Line 
1<?xml version="1.0" encoding="utf-8" ?>
2<project name="wrap" default="wrap">
3
4 <target name="wrap">
5 <!-- create products directory -->
6 <mkdir dir="products"/>
7
8 <!-- (windows) -->
9 <if><bool><equals arg1="${rk.os}" arg2="windows"/></bool>
10
11 <!--create a directory to build the wrapped installer in -->
12 <mkdir dir="wrapped-installer"/>
13
14 <!-- copy wrapper source into place -->
15 <copy todir="wrapped-installer" overwrite="true">
16 <fileset dir="${rk.home}/shared/windows/wrapper"/>
17 <fileset file="${rk.home}/shared/core/icon/icon.ico"/>
18 <fileset dir="${rk.home}/shared/core/search4j" includes="libsearch4j.cpp,libsearch4j.h"/>
19 </copy>
20
21 <!-- substitute in concrete values -->
22 <rsr file="wrapped-installer/wrapper.cpp">
23 <job pattern="@projectname@" replacement="${projectname}"/>
24 <job pattern="@java.installer@" replacement="${java.installer}"/>
25 <job pattern="@java.min.version@" replacement="${java.min.version}"/>
26 <job pattern="@bundled.version.java@" replacement="${bundled.version.java}"/>
27 <job pattern="@java.extracted@" replacement="${java.extracted}"/>
28 </rsr>
29
30 <!-- get the template resource script -->
31 <copy todir="wrapped-installer" file="${rk.home}/shared/windows/wrapper/wrapper.rc" overwrite="true"/>
32
33 <!-- split the resources into chunks, creating a resource script of the chunks -->
34 <rsplit
35 resource="${rk.home}/shared/windows/wrapper/${java.installer}"
36 outputDir="wrapped-installer"
37 resourceScript="wrapped-installer/wrapper.rc"
38 resourceName="JAVA"
39 resourceType="EXE"
40 chunkSize="${resources.chunksize}"/>
41 <rsplit
42 resource="installer/${projectname}-${version}${version-extra}-${os.suffix}.jar"
43 outputDir="wrapped-installer"
44 resourceScript="wrapped-installer/wrapper.rc"
45 resourceName="JAR"
46 resourceType="JAR"
47 chunkSize="${resources.chunksize}"
48 />
49
50 <!-- compile the resources -->
51 <exec executable="rc" dir="wrapped-installer">
52 <arg line="wrapper.rc"/>
53 </exec>
54
55 <!-- compile the wrapper -->
56 <exec executable="cl" dir="wrapped-installer">
57 <arg line="/c -GX /DWINDOWS=yes libsearch4j.cpp /out:libsearch4j.obj"/>
58 </exec>
59 <exec executable="cl" dir="wrapped-installer">
60 <arg line="/c -GX /DWINDOWS=yes wrapper.cpp /out:wrapper.obj"/>
61 </exec>
62
63 <!-- link wrapper -->
64 <exec executable="link" dir="wrapped-installer">
65 <arg line="/OUT:..\products\${projectname}-${version}${version-extra}-${os.suffix}.exe gdi32.lib advapi32.lib shell32.lib user32.lib libsearch4j.obj wrapper.obj wrapper.res"/>
66 </exec>
67
68 <!-- (linux) -->
69 <else><if><bool><equals arg1="${rk.os}" arg2="linux"/></bool>
70 <!-- create the build directory -->
71 <mkdir dir="wrapped-installer"/>
72
73 <!-- copy the source into place -->
74 <copy todir="wrapped-installer" overwrite="true">
75 <fileset file="${rk.home}/shared/linux/wrapper.cpp"/>
76 <fileset dir="${rk.home}/shared/core/search4j" includes="libsearch4j.cpp,libsearch4j.h"/>
77 </copy>
78
79 <!-- copy bundled files into place -->
80 <copy todir="wrapped-installer" file="${rk.home}/shared/linux/${java.installer}"/>
81 <copy tofile="wrapped-installer/${projectname}.jar" file="installer/${projectname}-${version}${version-extra}-${os.suffix}.jar"/>
82
83 <!-- substitute in real values -->
84 <rsr file="wrapped-installer/wrapper.cpp">
85 <job pattern="@projectname@" replacement="${projectname}"/>
86 <job pattern="@java.installer@" replacement="${java.installer}"/>
87 <job pattern="@java.extracted@" replacement="${java.extracted}"/>
88 <job pattern="@java.min.version@" replacement="${java.min.version}"/>
89 </rsr>
90
91 <!-- create an object file (extension .o) for each file to bundle -->
92 <if><bool><equals arg1="${x64}" arg2="true"/></bool>
93 <exec executable="/usr/bin/objcopy" dir="wrapped-installer">
94 <arg line="-I binary -O elf64-x86-64 -B i386 --redefine-sym _binary_${projectname}_jar_start=${projectname}jar --readonly-text ${projectname}.jar ${projectname}.jar.o"/>
95 </exec>
96 <exec executable="/usr/bin/objcopy" dir="wrapped-installer">
97 <arg line="-I binary -O elf64-x86-64 -B i386 --redefine-sym _binary_${java.installer}_start=java --readonly-text ${java.installer} java.o"/>
98 </exec>
99
100 <else>
101 <exec executable="/usr/bin/objcopy" dir="wrapped-installer" failonerror="true">
102 <arg line="-I binary -O elf32-i386 -B i386 --redefine-sym _binary_${projectname}_jar_start=${projectname}jar --readonly-text ${projectname}.jar ${projectname}.jar.o"/>
103 </exec>
104 <exec executable="/usr/bin/objcopy" dir="wrapped-installer" failonerror="true">
105 <arg line="-I binary -O elf32-i386 -B i386 --redefine-sym _binary_${java.installer}_start=java --readonly-text ${java.installer} java.o"/>
106 </exec>
107 </else>
108 </if>
109
110 <!-- compile libsearch4j -->
111 <exec executable="g++" dir="wrapped-installer">
112 <arg line="-Wall -static -static-libgcc -c -o libsearch4j.o libsearch4j.cpp"/>
113 </exec>
114
115 <!-- figure out jar size (web jar) -->
116 <exec executable="ls" dir="wrapped-installer" outputproperty="project.jar.ls"><arg line="-l ${projectname}.jar"/></exec>
117 <exec executable="sed" inputstring="${project.jar.ls}" outputproperty="project.jar.size"><arg line="-e 's/^[^\ ]*\ *[^\ ]*\ *[^\ ]*\ *[^\ ]*\ *\([0-9]*\).*$/\1/g'"/></exec>
118
119 <!-- figure out java size -->
120 <exec executable="ls" dir="wrapped-installer" outputproperty="java.ls"><arg line="-l ${java.installer}"/></exec>
121 <exec executable="sed" inputstring="${java.ls}" outputproperty="java.size"><arg line="-e 's/^[^\ ]*\ *[^\ ]*\ *[^\ ]*\ *[^\ ]*\ *\([0-9]*\).*$/\1/g'"/></exec>
122
123 <!-- creating wrapper header file -->
124 <delete file="wrapper.h"/>
125 <!-- ensure no tabs/whitespaces in front of each line in the .h file owing to indentation here -->
126 <echo file="wrapped-installer/wrapper.h">extern const char ${projectname}jar[${project.jar.size}];
127extern const char java[${java.size}];
128#define java_is_bundled yes
129</echo>
130
131 <!-- compile the wrapper program -->
132 <exec executable="g++" dir="wrapped-installer" failonerror="true">
133 <arg line="-Wall -static -static-libgcc -c -o wrapper.o wrapper.cpp"/>
134 </exec>
135
136 <!-- link the compiled code and bundled files -->
137 <exec executable="g++" dir="wrapped-installer">
138 <arg line="-static -static-libgcc -o ../products/${projectname}-${version}${version-extra}-linux${extension-x64} wrapper.o libsearch4j.o ${projectname}.jar.o java.o"/>
139 </exec>
140
141 <!-- (mac) -->
142 <else><if><bool><equals arg1="${rk.os}" arg2="mac"/></bool>
143
144 <!-- create and setup the build directory -->
145 <mkdir dir="wrapped-installer"/>
146
147 <!-- create app for main installer -->
148 <copy todir="wrapped-installer/${projectname}${version}${version-extra}.app">
149 <fileset dir="${rk.home}/shared/mac/Wrapper.app"/>
150 </copy>
151 <copy todir="wrapped-installer/${projectname}${version}${version-extra}.app/Contents/Resources" file="${rk.home}/shared/core/icon/icon.icns"/>
152 <chmod file="wrapped-installer/${projectname}${version}${version-extra}.app/Contents/MacOS/Expeditee" perm="ug+x"/>
153
154 <!-- copy bundled files -->
155 <copy todir="wrapped-installer/${projectname}${version}${version-extra}.app/Contents/Resources">
156 <fileset dir="compiled"/>
157 </copy>
158 <copy tofile="wrapped-installer/${projectname}${version}${version-extra}.app/Contents/Resources/jre_bin" file="${rk.home}/shared/mac/${java.installer}"/>
159
160 <!-- substitute in real values -->
161 <rsr file="wrapped-installer/${projectname}${version}${version-extra}.app/Contents/Info.plist">
162 <job pattern="@projectname@" replacement="${projectname}"/>
163 <job pattern="@version@" replacement="${version}${version-extra}"/>
164 </rsr>
165
166
167 <!-- turn app into a dmg -->
168
169 <!-- get size of app -->
170 <exec executable="du" dir="wrapped-installer" outputproperty="app.du">
171 <arg line="-ks ${projectname}${version}${version-extra}.app"/>
172 </exec>
173 <exec executable="sed" inputstring="${app.du}" outputproperty="app.size">
174 <arg line="-e 's/^\([0-9]*\).*$/\1/g'"/>
175 </exec>
176 <math result="dmg.size" operand1="${app.size}" operation="+" operand2="${dmg.overhead}" datatype="int"/>
177
178 <!-- create disk image -->
179 <property name="dmg.name" value="${projectname}-${version}${version-extra}-${os.suffix}"/>
180 <exec dir="products" executable="hdiutil" failonerror="true">
181 <arg line="create -ov -size ${dmg.size}k -fs HFS+ -volname ${dmg.name} ${dmg.name}-tmp.dmg"/>
182 </exec>
183 <!-- mount it -->
184 <exec executable="hdiutil" dir="products" failonerror="true">
185 <arg line="attach ${dmg.name}-tmp.dmg"/>
186 </exec>
187 <!-- copy file into it -->
188 <exec executable="cp">
189 <arg line="-r wrapped-installer/${projectname}${version}${version-extra}.app /Volumes/${dmg.name}"/>
190 </exec>
191 <!-- add background image, icon and .DS_STORE -->
192 <copy file="${rk.home}/shared/mac/dmg-bg.png"
193 tofile="/Volumes/${dmg.name}/.background.png"
194 overwrite="true"/>
195 <copy file="${rk.home}/shared/core/icon/icon.icns"
196 tofile="/Volumes/${dmg.name}/.VolumeIcon.icns"
197 overwrite="true"/>
198 <copy file="${rk.home}/shared/mac/DS_Store"
199 tofile="/Volumes/${dmg.name}/.DS_Store"
200 overwrite="true"/>
201 <!-- Set icon -->
202 <exec executable="SetFile">
203 <arg line="-a C /Volumes/${dmg.name}"/>
204 </exec>
205 <!-- add symlink to applications folder -->
206 <symlink link="/Volumes/${dmg.name}" resource="/Applications"/>
207 <!-- unmount it-->
208 <exec executable="hdiutil" failonerror="true">
209 <arg line="detach /Volumes/${dmg.name}"/>
210 </exec>
211 <!-- Compress it to a new image -->
212 <!--
213 <exec executable="hdiutil" failonerror="true">
214 <arg line="convert ${dmg.name}-tmp.dmg -format UDZO -o ${dmg.name}.dmg"/>
215 </exec>
216 -->
217 <!-- Delete the temporary image -->
218 <delete file="${dmg.name}-tmp.dmg" quiet="yes" failonerror="false"/>
219 </if></else></if></else></if>
220
221
222 </target>
223
224</project>
225
Note: See TracBrowser for help on using the repository browser.