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

Revision 19537, 6.0 KB (checked in by oranfry, 10 years ago)

work on creating the cdrom installers and putting them with the cdrom components

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