root/release-kits/rk3/ant-scripts/wrap.xml @ 20938

Revision 20938, 10.9 KB (checked in by oranfry, 11 years ago)

purged remaining used of windows- and linux-java.extracted

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