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

Last change on this file since 30131 was 30131, checked in by ak19, 7 years ago

Changes specific to 64 bit MacOS with which we now bundle a JRE.

File size: 9.1 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}${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\Greenstone-${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/${linux-java.installer}"/>
81 <copy tofile="wrapped-installer/greenstone.jar" file="installer/Greenstone-${version}${version-extra}-${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 <if><bool><equals arg1="${x64}" arg2="true"/></bool>
92 <exec executable="/usr/bin/objcopy" dir="wrapped-installer">
93 <arg line="-I binary -O elf64-x86-64 -B i386 --redefine-sym _binary_greenstone_jar_start=greenstonejar --readonly-text greenstone.jar greenstone.jar.o"/>
94 </exec>
95 <exec executable="/usr/bin/objcopy" dir="wrapped-installer">
96 <arg line="-I binary -O elf64-x86-64 -B i386 --redefine-sym _binary_${linux-java.installer}_start=java --readonly-text ${linux-java.installer} java.o"/>
97 </exec>
98
99 <else>
100 <exec executable="/usr/bin/objcopy" dir="wrapped-installer" failonerror="true">
101 <arg line="-I binary -O elf32-i386 -B i386 --redefine-sym _binary_greenstone_jar_start=greenstonejar --readonly-text greenstone.jar greenstone.jar.o"/>
102 </exec>
103 <exec executable="/usr/bin/objcopy" dir="wrapped-installer" failonerror="true">
104 <arg line="-I binary -O elf32-i386 -B i386 --redefine-sym _binary_${linux-java.installer}_start=java --readonly-text ${linux-java.installer} java.o"/>
105 </exec>
106 </else>
107 </if>
108
109 <!-- compile libsearch4j -->
110 <exec executable="g++" dir="wrapped-installer">
111 <arg line="-Wall -static -static-libgcc -c -o libsearch4j.o libsearch4j.cpp"/>
112 </exec>
113
114 <!-- figure out jar size (web jar) -->
115 <exec executable="ls" dir="wrapped-installer" outputproperty="greenstone.jar.ls"><arg line="-l greenstone.jar"/></exec>
116 <exec executable="sed" inputstring="${greenstone.jar.ls}" outputproperty="greenstone.jar.size"><arg line="-e 's/^[^\ ]*\ *[^\ ]*\ *[^\ ]*\ *[^\ ]*\ *\([0-9]*\).*$/\1/g'"/></exec>
117
118 <!-- figure out java size -->
119 <exec executable="ls" dir="wrapped-installer" outputproperty="java.ls"><arg line="-l ${linux-java.installer}"/></exec>
120 <exec executable="sed" inputstring="${java.ls}" outputproperty="java.size"><arg line="-e 's/^[^\ ]*\ *[^\ ]*\ *[^\ ]*\ *[^\ ]*\ *\([0-9]*\).*$/\1/g'"/></exec>
121
122 <!-- creating wrapper header file -->
123 <delete file="wrapper.h"/>
124 <!-- ensure no tabs/whitespaces in front of each line in the .h file owing to indentation here -->
125 <echo file="wrapped-installer/wrapper.h">extern const char greenstonejar[${greenstone.jar.size}];
126extern const char java[${java.size}];
127#define java_is_bundled yes
128</echo>
129
130 <!-- compile the wrapper program -->
131 <exec executable="g++" dir="wrapped-installer" failonerror="true">
132 <arg line="-Wall -static -static-libgcc -c -o wrapper.o wrapper.cpp"/>
133 </exec>
134
135 <!-- link the compiled code and bundled files -->
136 <exec executable="g++" dir="wrapped-installer">
137 <arg line="-static -static-libgcc -o ../products/Greenstone-${version}${version-extra}-linux${extension-x64} wrapper.o libsearch4j.o greenstone.jar.o java.o"/>
138 </exec>
139
140 <!-- (mac) -->
141 <else><if><bool><equals arg1="${rk.os}" arg2="mac"/></bool>
142
143 <!-- create and setup the build directory -->
144 <delete dir="wrapped-installer"/>
145 <mkdir dir="wrapped-installer"/>
146
147 <!-- create app for main installer -->
148 <copy todir="wrapped-installer/Greenstone${version}${version-extra}.app"><fileset dir="${rk.home}/shared/mac/Wrapper.app"/></copy>
149 <copy todir="wrapped-installer/Greenstone${version}${version-extra}.app/Contents/Resources" file="${rk.home}/shared/core/icon/icon.icns"/>
150 <chmod file="wrapped-installer/Greenstone${version}${version-extra}.app/Contents/MacOS/JavaApplicationStub" perm="ug+x"/>
151
152 <!-- copy bundled files -->
153 <!-- Include the self-extracting jre (for 64 bit) if this Mac is a 64 bit OS
154 http://stackoverflow.com/questions/218989/how-to-determine-build-architecture-32bit-64bit-with-ant -->
155 <exec dir="." executable="/bin/sh" outputproperty="bitness.ouput"><arg line="-c &quot;uname -m&quot;"/></exec>
156 <if><bool><contains string="${bitness.ouput}" substring="_64"/></bool>
157 <copy tofile="wrapped-installer/Greenstone${version}${version-extra}.app/Contents/Resources/Java/jre_bin" file="${rk.home}/shared/mac/${mac-java.installer}"/>
158 </if>
159 <chmod file="wrapped-installer/Greenstone${version}${version-extra}.app/Contents/MacOS/greenstone" perm="ug+x"/>
160 <copy todir="wrapped-installer/Greenstone${version}${version-extra}.app/Contents/Resources/Java" file="installer/Greenstone-${version}${version-extra}-${os.suffix}.jar"/>
161
162 <!-- substitute in real values -->
163 <rsr file="wrapped-installer/Greenstone${version}${version-extra}.app/Contents/Info.plist">
164 <job pattern="@jar@" replacement="Greenstone-${version}${version-extra}-${os.suffix}.jar"/>
165 <job pattern="@version@" replacement="${version}${version-extra}"/>
166 </rsr>
167
168 <!-- turn app into a dmg -->
169
170 <!-- get size of app -->
171 <exec executable="du" dir="wrapped-installer" outputproperty="app.du"><arg line="-ks Greenstone${version}${version-extra}.app"/></exec>
172 <exec executable="sed" inputstring="${app.du}" outputproperty="app.size"><arg line="-e 's/^\([0-9]*\).*$/\1/g'"/></exec>
173 <math result="dmg.size" operand1="${app.size}" operation="+" operand2="${dmg.overhead}" datatype="int"/>
174
175 <!-- create disk image -->
176 <property name="dmg.name" value="Greenstone-${version}${version-extra}-${os.suffix}"/>
177 <exec dir="products" executable="hdiutil" failonerror="true"><arg line="create -ov -size ${dmg.size}k -fs HFS+ -volname ${dmg.name} ${dmg.name}.dmg"/></exec>
178 <!-- mount it -->
179 <exec executable="hdiutil" dir="products" failonerror="true"><arg line="attach ${dmg.name}.dmg"/></exec>
180 <!-- copy file into it -->
181 <exec executable="cp"><arg line="-r wrapped-installer/Greenstone${version}${version-extra}.app /Volumes/${dmg.name}"/></exec>
182 <!-- unmount it-->
183 <exec executable="hdiutil" failonerror="true"><arg line="detach /Volumes/${dmg.name}"/></exec>
184 </if></else></if></else></if>
185
186
187 </target>
188
189</project>
190
Note: See TracBrowser for help on using the repository browser.