source: main/trunk/release-kits/kits/rk2/ant-scripts/wrap.xml@ 21394

Last change on this file since 21394 was 21394, checked in by oranfry, 12 years ago

moving specific stuff out of general area

File size: 7.7 KB
Line 
1<?xml version="1.0" encoding="utf-8" ?>
2<project name="rk2-wrap" default="wrap">
3
4 <target name="wrap" depends="init,gs2-init">
5
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="${basedir}/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 dir="${rk.home}/shared/greenstone2/wrapper" includes="*.bmp"/>
18 <fileset dir="${rk.home}/shared/greenstone2/icon" includes="icon.ico"/>
19 <fileset dir="${rk.home}/shared/core/search4j" includes="libsearch4j.cpp,libsearch4j.h"/>
20 </copy>
21
22 <!-- tweak files for wrapping -->
23 <rsr file="${basedir}/wrapped-installer/wrapper.cpp">
24 <job pattern="@java.installer@" replacement="${windows-java.installer}"/>
25 <job pattern="@java.min.version@" replacement="${java.min.version}"/>
26 <job pattern="@bundled.version.java@" replacement="${bundled.version.windows-java}"/>
27 <job pattern="@java.extracted@" replacement="${java.extracted}"/>
28 </rsr>
29
30 <!-- split the resources into chunks, creating a resource script of the chunks -->
31 <copy todir="${basedir}/wrapped-installer" file="${rk.home}/shared/windows/wrapper/wrapper.rc" overwrite="true"/>
32 <rsplit
33 resource="${rk.home}/shared/windows/wrapper/${windows-java.installer}"
34 outputDir="${basedir}/wrapped-installer"
35 resourceScript="${basedir}/wrapped-installer/wrapper.rc"
36 resourceName="JAVA"
37 resourceType="EXE"
38 chunkSize="${resources.chunksize}"/>
39 <rsplit
40 resource="${basedir}/installer/Greenstone-${version}-${os.suffix}.jar"
41 outputDir="${basedir}/wrapped-installer"
42 resourceScript="${basedir}/wrapped-installer/wrapper.rc"
43 resourceName="JAR"
44 resourceType="JAR"
45 chunkSize="${resources.chunksize}"
46 />
47
48 <!-- compile the resources -->
49 <exec executable="rc" dir="${basedir}/wrapped-installer">
50 <arg line="wrapper.rc"/>
51 </exec>
52
53 <!-- compile the wrapper -->
54 <exec executable="cl" dir="${basedir}/wrapped-installer">
55 <arg line="/c -GX /DWINDOWS=yes libsearch4j.cpp /out:libsearch4j.obj"/>
56 </exec>
57
58 <exec executable="cl" dir="${basedir}/wrapped-installer">
59 <arg line="/c -GX /DWINDOWS=yes wrapper.cpp /out:wrapper.obj"/>
60 </exec>
61
62 <!-- link the wrapper -->
63 <exec executable="link" dir="${basedir}/wrapped-installer">
64 <arg line="/OUT:..\products\Greenstone-${version}-${os.suffix}.exe gdi32.lib advapi32.lib shell32.lib user32.lib libsearch4j.obj wrapper.obj wrapper.res"/>
65 </exec>
66
67 <!-- linux -->
68 <else><if><bool><equals arg1="${rk.os}" arg2="linux"/></bool>
69 <!-- create and setup the build directory -->
70 <mkdir dir="${basedir}/wrapped-installer"/>
71 <copy todir="${basedir}/wrapped-installer" file="${rk.home}/shared/linux/wrapper.cpp"/>
72 <copy todir="${basedir}/wrapped-installer" file="${rk.home}/shared/core/search4j/libsearch4j.cpp"/>
73 <copy todir="${basedir}/wrapped-installer" file="${rk.home}/shared/core/search4j/libsearch4j.h"/>
74
75 <!-- copy bundled files -->
76 <copy todir="${basedir}/wrapped-installer" file="${rk.home}/shared/linux/${linux-java.installer}"/>
77 <copy tofile="${basedir}/wrapped-installer/greenstone2.jar" file="${basedir}/installer/Greenstone-${version}-linux.jar"/>
78
79 <!-- substitute in real values -->
80 <rsr file="${basedir}/wrapped-installer/wrapper.cpp">
81 <job pattern="@java.installer@" replacement="${linux-java.installer}"/>
82 <job pattern="@installer.name@" replacement="greenstone2"/>
83 <job pattern="@java.extracted@" replacement="${java.extracted}"/>
84 <job pattern="@java.min.version@" replacement="${java.min.version}"/>
85 </rsr>
86
87 <!-- create an object file (extension .o) for each file to bundle -->
88 <exec executable="/usr/bin/objcopy" dir="${basedir}/wrapped-installer">
89 <arg line="-I binary -O elf32-i386 -B i386 --redefine-sym _binary_greenstone2_jar_start=greenstone2jar --readonly-text greenstone2.jar greenstone2.jar.o"/>
90 </exec>
91 <exec executable="/usr/bin/objcopy" dir="${basedir}/wrapped-installer">
92 <arg line="-I binary -O elf32-i386 -B i386 --redefine-sym _binary_${linux-java.installer}_start=java --readonly-text ${linux-java.installer} java.o"/>
93 </exec>
94
95 <!-- compile libsearch4j -->
96 <exec executable="g++" dir="wrapped-installer">
97 <arg line="-Wall -static -static-libgcc -c -o libsearch4j.o libsearch4j.cpp"/>
98 </exec>
99
100 <!-- creating wrapper header file -->
101 <delete file="wrapper.h"/>
102 <exec executable="echo" output="${basedir}/wrapped-installer/wrapper.h"><arg line="extern const char greenstone2jar[${greenstone2.jar.size}];"/></exec>
103 <exec executable="echo" output="${basedir}/wrapped-installer/wrapper.h" append="true"><arg line="extern const char java[${java.size}];"/></exec>
104 <exec executable="echo" output="${basedir}/wrapped-installer/wrapper.h" append="true"><arg line="#define java_is_bundled yes"/></exec>
105
106 <!-- compile the wrapper program -->
107 <exec executable="g++" dir="wrapped-installer">
108 <arg line="-Wall -static -static-libgcc -c -o wrapper.o wrapper.cpp"/>
109 </exec>
110
111 <!-- link the compiled code and bundled files -->
112 <exec executable="g++" dir="${basedir}/wrapped-installer">
113 <arg line="-static -static-libgcc -o ../products/Greenstone-${version}-linux wrapper.o libsearch4j.o greenstone2.jar.o java.o"/>
114 </exec>
115
116 <!-- mac -->
117 <else><if><bool><equals arg1="${rk.os}" arg2="mac"/></bool>
118
119 <!-- create and setup the build directory -->
120 <delete dir="${basedir}/wrapped-installer"/>
121 <mkdir dir="${basedir}/wrapped-installer"/>
122
123 <!-- create app for main installer -->
124 <copy todir="${basedir}/wrapped-installer/Greenstone${version}.app"><fileset dir="${rk.home}/shared/mac/Wrapper.app"/></copy>
125 <copy todir="${basedir}/wrapped-installer/Greenstone${version}.app/Contents/Resources" file="${rk.home}/shared/greenstone2/icon/icon.icns"/>
126 <chmod file="${basedir}/wrapped-installer/Greenstone${version}.app/Contents/MacOS/JavaApplicationStub" perm="ug+x"/>
127
128 <!-- copy bundled files -->
129 <copy todir="${basedir}/wrapped-installer/Greenstone${version}.app/Contents/Resources/Java" file="${basedir}/installer/Greenstone-${version}-MacOS-${processor}.jar"/>
130
131 <!-- substitute in real values -->
132 <rsr file="${basedir}/wrapped-installer/Greenstone${version}.app/Contents/Info.plist" pattern="@jar@" replacement="Greenstone-${version}-MacOS-${processor}.jar"/>
133 <rsr file="${basedir}/wrapped-installer/Greenstone${version}.app/Contents/Info.plist" pattern="@version@" replacement="${version}"/>
134
135 <!-- turn app into a dmg -->
136
137 <!-- get size of app -->
138 <exec executable="du" dir="${basedir}/wrapped-installer" outputproperty="app.du"><arg line="-ks Greenstone${version}.app"/></exec>
139 <echo>app.du: ${app.du}</echo>
140 <exec executable="sed" inputstring="${app.du}" outputproperty="app.size"><arg line="-e 's/^\([0-9]*\).*$/\1/g'"/></exec>
141 <echo>app.size: ${app.size}</echo>
142 <math result="dmg.size" operand1="${app.size}" operation="+" operand2="${dmg.overhead}" datatype="int"/>
143 <echo>dmg.size: ${dmg.size}</echo>
144
145
146 <!-- create disk image -->
147 <property name="dmg.name" value="Greenstone-${version}-${os.suffix}"/>
148 <exec dir="${basedir}/products" executable="hdiutil"><arg line="create -ov -size ${dmg.size}k -fs HFS+ -volname ${dmg.name} ${dmg.name}.dmg"/></exec>
149 <!-- mount it -->
150 <exec executable="hdiutil" dir="${basedir}/products"><arg line="attach ${dmg.name}.dmg"/></exec>
151 <!-- copy file into it -->
152 <exec executable="cp"><arg line="-r ${basedir}/wrapped-installer/Greenstone${version}.app /Volumes/${dmg.name}"/></exec>
153 <!-- unmount it-->
154 <exec executable="hdiutil"><arg line="detach /Volumes/${dmg.name}"/></exec>
155 </if></else></if></else></if>
156
157 </target>
158
159
160</project>
Note: See TracBrowser for help on using the repository browser.