source: main/trunk/release-kits/shared/core/ant-scripts/wrap.xml@ 21658

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

fixes

File size: 7.7 KB
Line 
1<?xml version="1.0" encoding="utf-8" ?>
2<project name="wrap" default="wrap">
3
4 <target name="wrap" depends="init">
5
6 <!-- create products directory -->
7 <mkdir dir="products"/>
8
9 <!-- (windows) -->
10 <if><bool><equals arg1="${rk.os}" arg2="windows"/></bool>
11
12 <!--create a directory to build the wrapped installer in -->
13 <mkdir dir="wrapped-installer"/>
14
15 <!-- copy wrapper source into place -->
16 <copy todir="wrapped-installer" overwrite="true">
17 <fileset dir="${rk.home}/shared/windows/wrapper"/>
18 <fileset file="${rk.home}/shared/core/icon/icon.ico"/>
19 <fileset dir="${rk.home}/shared/core/search4j" includes="libsearch4j.cpp,libsearch4j.h"/>
20 </copy>
21
22 <!-- substitute in concrete values -->
23 <rsr file="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 <!-- 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/${windows-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/Greenstone-${version}-${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\Greenstone-${version}-${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/${linux-java.installer}"/>
81 <copy tofile="wrapped-installer/greenstone.jar" file="installer/Greenstone-${version}-${os.suffix}.jar"/>
82
83 <!-- substitute in real values -->
84 <rsr file="wrapped-installer/wrapper.cpp">
85 <job pattern="@java.installer@" replacement="${linux-java.installer}"/>
86 <job pattern="@java.extracted@" replacement="${java.extracted}"/>
87 <job pattern="@java.min.version@" replacement="${java.min.version}"/>
88 </rsr>
89
90 <!-- create an object file (extension .o) for each file to bundle -->
91 <exec executable="/usr/bin/objcopy" dir="wrapped-installer">
92 <arg line="-I binary -O elf32-i386 -B i386 --redefine-sym _binary_greenstone_jar_start=greenstonejar --readonly-text greenstone.jar greenstone.jar.o"/>
93 </exec>
94 <exec executable="/usr/bin/objcopy" dir="wrapped-installer">
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 <!-- compile libsearch4j -->
99 <exec executable="g++" dir="wrapped-installer">
100 <arg line="-Wall -static -static-libgcc -c -o libsearch4j.o libsearch4j.cpp"/>
101 </exec>
102
103 <!-- figure out jar size (web jar) -->
104 <exec executable="ls" dir="wrapped-installer" outputproperty="greenstone.jar.ls"><arg line="-l greenstone.jar"/></exec>
105 <exec executable="sed" inputstring="${greenstone.jar.ls}" outputproperty="greenstone.jar.size"><arg line="-e 's/^[^\ ]*\ *[^\ ]*\ *[^\ ]*\ *[^\ ]*\ *\([0-9]*\).*$/\1/g'"/></exec>
106
107 <!-- figure out java size -->
108 <exec executable="ls" dir="wrapped-installer" outputproperty="java.ls"><arg line="-l ${linux-java.installer}"/></exec>
109 <exec executable="sed" inputstring="${java.ls}" outputproperty="java.size"><arg line="-e 's/^[^\ ]*\ *[^\ ]*\ *[^\ ]*\ *[^\ ]*\ *\([0-9]*\).*$/\1/g'"/></exec>
110
111 <!-- creating wrapper header file -->
112 <delete file="wrapper.h"/>
113 <exec executable="echo" output="wrapped-installer/wrapper.h"><arg line="extern const char greenstonejar[${greenstone.jar.size}];"/></exec>
114 <exec executable="echo" output="wrapped-installer/wrapper.h" append="true"><arg line="extern const char java[${java.size}];"/></exec>
115 <exec executable="echo" output="wrapped-installer/wrapper.h" append="true"><arg line="#define java_is_bundled yes"/></exec>
116
117 <!-- compile the wrapper program -->
118 <exec executable="g++" dir="wrapped-installer">
119 <arg line="-Wall -static -static-libgcc -c -o wrapper.o wrapper.cpp"/>
120 </exec>
121
122 <!-- link the compiled code and bundled files -->
123 <exec executable="g++" dir="wrapped-installer">
124 <arg line="-static -static-libgcc -o ../products/Greenstone-${version}-linux wrapper.o libsearch4j.o greenstone.jar.o java.o"/>
125 </exec>
126
127 <!-- (mac) -->
128 <else><if><bool><equals arg1="${rk.os}" arg2="mac"/></bool>
129
130 <!-- create and setup the build directory -->
131 <delete dir="wrapped-installer"/>
132 <mkdir dir="wrapped-installer"/>
133
134 <!-- create app for main installer -->
135 <copy todir="wrapped-installer/Greenstone${version}.app"><fileset dir="${rk.home}/shared/mac/Wrapper.app"/></copy>
136 <copy todir="wrapped-installer/Greenstone${version}.app/Contents/Resources" file="${rk.home}/shared/core/icon/icon.icns"/>
137 <chmod file="wrapped-installer/Greenstone${version}.app/Contents/MacOS/JavaApplicationStub" perm="ug+x"/>
138
139 <!-- copy bundled files -->
140 <copy todir="wrapped-installer/Greenstone${version}.app/Contents/Resources/Java" file="installer/Greenstone-${version}-${os.suffix}.jar"/>
141
142 <!-- substitute in real values -->
143 <rsr file="wrapped-installer/Greenstone${version}.app/Contents/Info.plist">
144 <job pattern="@jar@" replacement="Greenstone-${version}-${os.suffix}.jar"/>
145 <job pattern="@version@" replacement="${version}"/>
146 </rsr>
147
148 <!-- turn app into a dmg -->
149
150 <!-- get size of app -->
151 <exec executable="du" dir="wrapped-installer" outputproperty="app.du"><arg line="-ks Greenstone${version}.app"/></exec>
152 <exec executable="sed" inputstring="${app.du}" outputproperty="app.size"><arg line="-e 's/^\([0-9]*\).*$/\1/g'"/></exec>
153 <math result="dmg.size" operand1="${app.size}" operation="+" operand2="${dmg.overhead}" datatype="int"/>
154
155 <!-- create disk image -->
156 <property name="dmg.name" value="Greenstone-${version}-${os.suffix}"/>
157 <exec dir="products" executable="hdiutil"><arg line="create -ov -size ${dmg.size}k -fs HFS+ -volname ${dmg.name} ${dmg.name}.dmg"/></exec>
158 <!-- mount it -->
159 <exec executable="hdiutil" dir="products"><arg line="attach ${dmg.name}.dmg"/></exec>
160 <!-- copy file into it -->
161 <exec executable="cp"><arg line="-r wrapped-installer/Greenstone${version}.app /Volumes/${dmg.name}"/></exec>
162 <!-- unmount it-->
163 <exec executable="hdiutil"><arg line="detach /Volumes/${dmg.name}"/></exec>
164 </if></else></if></else></if>
165
166
167 </target>
168
169</project>
170
Note: See TracBrowser for help on using the repository browser.