root/other-projects/expeditee-release-kits/kits/rke/ant-scripts/wrap.xml @ 28726

Revision 28726, 9.0 KB (checked in by ak19, 7 years ago)

Expeditee team (jts21) - Changes to make the Mac binary inside .app be self-extracting as well as include the JRE with it

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