source: release-kits/rk3/ant-scripts/wrap.xml@ 20374

Last change on this file since 20374 was 20374, checked in by oranfry, 13 years ago

don't skip export of binaries, and do wrap

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