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

Revision 19592, 4.0 KB (checked in by oranfry, 11 years ago)

separating out cdrom code for linux and mac too

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