root/release-kits/lirk2/ant-scripts/wrap.xml @ 19510

Revision 19510, 5.6 KB (checked in by oranfry, 10 years ago)

main release kits now create their own cdrom installers and wrap them

Line 
1<?xml version="1.0" encoding="utf-8" ?>
2<project name="lirk2-wrap" default="wrap">
3
4    <target name="wrap">
5        <antcall target="setup-for-wrapping"/>
6        <antcall target="create-objects"/>
7        <antcall target="compile-wrapper-web"/>
8        <antcall target="compile-wrapper-cdrom"/>
9    </target>
10
11
12    <target name="setup-for-wrapping">
13
14        <!-- create and setup the build directory -->
15        <mkdir dir="${basedir}/wrapped-installer"/>
16        <copy todir="${basedir}/wrapped-installer" file="${lirk2.home}/linux/wrapper.cpp"/>
17        <copy todir="${basedir}/wrapped-installer" file="${lirk2.home}/core/search4j/libsearch4j.cpp"/>
18        <copy todir="${basedir}/wrapped-installer" file="${lirk2.home}/core/search4j/libsearch4j.h"/>
19
20        <!-- copy bundled files -->
21        <copy todir="${basedir}/wrapped-installer" file="${lirk2.home}/linux/${linux-java.installer}"/>
22        <copy tofile="${basedir}/wrapped-installer/greenstone2.jar" file="${basedir}/installer/Greenstone-${version}-linux.jar"/>
23
24        <!-- substitute in real values -->
25        <rsr file="${basedir}/wrapped-installer/wrapper.cpp" pattern="@java.installer@" replacement="${linux-java.installer}"/>
26        <rsr file="${basedir}/wrapped-installer/wrapper.cpp" pattern="@installer.name@" replacement="greenstone2"/>
27        <rsr file="${basedir}/wrapped-installer/wrapper.cpp" pattern="@java.extracted@" replacement="${linux-java.extracted}"/>
28        <rsr file="${basedir}/wrapped-installer/wrapper.cpp" pattern="@java.min.version@" replacement="${java.min.version}"/>
29
30    </target>
31
32    <target name="create-objects">
33
34        <echo level="info">create an object file (extension .o) for each file to bundle</echo>
35        <!-- jar (web) -->
36        <exec executable="/usr/bin/objcopy" dir="${basedir}/wrapped-installer">
37            <arg line="-I binary -O elf32-i386 -B i386 --redefine-sym _binary_greenstone2_jar_start=greenstone2jar --readonly-text greenstone2.jar greenstone2.jar.o"/>
38        </exec>
39        <!-- jar (cdrom) -->
40        <exec executable="/usr/bin/objcopy" dir="installer">
41            <arg line="-I binary -O elf32-i386 -B i386 --redefine-sym _binary_cdrom_jar_start=greenstone2jar --readonly-text cdrom.jar ../wrapped-installer/cdrom.jar.o"/>
42        </exec>
43        <!-- java -->
44        <exec executable="/usr/bin/objcopy" dir="${basedir}/wrapped-installer">
45            <arg line="-I binary -O elf32-i386 -B i386 --redefine-sym _binary_${linux-java.installer}_start=java --readonly-text ${linux-java.installer} java.o"/>
46        </exec>
47
48        <echo level="info">compile libsearch4j</echo>
49        <exec executable="g++" dir="wrapped-installer">
50            <arg line="-Wall -static -static-libgcc -c -o libsearch4j.o libsearch4j.cpp"/>
51        </exec>
52
53    </target>
54
55    <target name="calculate-object-sizes">
56
57        <echo level="info">working out the size of the objects</echo>
58        <!-- jar(web) -->
59        <exec executable="ls" dir="wrapped-installer" outputproperty="greenstone2.jar.ls"><arg line="-l greenstone2.jar"/></exec>
60        <exec executable="sed" inputstring="${greenstone2.jar.ls}" outputproperty="greenstone2.jar.size"><arg line="-e 's/^[^\ ]*\ *[^\ ]*\ *[^\ ]*\ *[^\ ]*\ *\([0-9]*\).*$/\1/g'"/></exec>
61
62        <!-- jar(cdrom) -->
63        <exec executable="ls" dir="installer" outputproperty="cdrom.jar.ls"><arg line="-l cdrom.jar"/></exec>
64        <exec executable="sed" inputstring="${cdrom.jar.ls}" outputproperty="cdrom.jar.size"><arg line="-e 's/^[^\ ]*\ *[^\ ]*\ *[^\ ]*\ *[^\ ]*\ *\([0-9]*\).*$/\1/g'"/></exec>
65
66        <!-- java -->
67        <exec executable="ls" dir="wrapped-installer" outputproperty="java.ls"><arg line="-l ${linux-java.installer}"/></exec>
68        <exec executable="sed" inputstring="${java.ls}" outputproperty="java.size"><arg line="-e 's/^[^\ ]*\ *[^\ ]*\ *[^\ ]*\ *[^\ ]*\ *\([0-9]*\).*$/\1/g'"/></exec>
69
70    </target>
71
72    <target name="compile-wrapper-web" depends="calculate-object-sizes">
73
74        <echo level="info">creating wrapper header file</echo>
75        <delete file="wrapper.h"/>
76        <exec executable="echo" output="${basedir}/wrapped-installer/wrapper.h"><arg line="extern const char greenstone2jar[${greenstone2.jar.size}];"/></exec>
77        <exec executable="echo" output="${basedir}/wrapped-installer/wrapper.h" append="true"><arg line="extern const char java[${java.size}];"/></exec>
78        <exec executable="echo" output="${basedir}/wrapped-installer/wrapper.h" append="true"><arg line="#define java_is_bundled yes"/></exec>
79
80        <echo level="info">compile the wrapper program</echo>
81        <exec executable="g++" dir="wrapped-installer">
82            <arg line="-Wall -static -static-libgcc -c -o wrapper.o wrapper.cpp"/>
83        </exec>
84
85        <echo level="info">link the compiled code and bundled files</echo>
86        <exec executable="g++" dir="${basedir}/wrapped-installer">
87            <arg line="-static -static-libgcc -o ../products/Greenstone-${version}-linux.bin wrapper.o libsearch4j.o greenstone2.jar.o java.o"/>
88        </exec>
89
90    </target>
91
92    <target name="compile-wrapper-cdrom" depends="calculate-object-sizes">
93
94        <echo level="info">creating wrapper header file</echo>
95        <delete file="wrapper.h"/>
96        <exec executable="echo" output="${basedir}/wrapped-installer/wrapper.h"><arg line="extern const char greenstone2jar[${cdrom.jar.size}];"/></exec>
97        <exec executable="echo" output="${basedir}/wrapped-installer/wrapper.h" append="true"><arg line="extern const char java[${java.size}];"/></exec>
98        <exec executable="echo" output="${basedir}/wrapped-installer/wrapper.h" append="true"><arg line="#define java_is_bundled yes"/></exec>
99
100        <echo level="info">compile the wrapper program</echo>
101        <exec executable="g++" dir="wrapped-installer">
102            <arg line="-Wall -static -static-libgcc -c -o wrapper.o wrapper.cpp"/>
103        </exec>
104
105        <echo level="info">link the compiled code and bundled files</echo>
106        <exec executable="g++" dir="${basedir}/wrapped-installer">
107            <arg line="-static -static-libgcc -o ../products/cdrom-linux.bin wrapper.o libsearch4j.o cdrom.jar.o java.o"/>
108        </exec>
109
110    </target>
111
112</project>
Note: See TracBrowser for help on using the browser.