root/release-kits/lirk3/ant-scripts/wrap.xml @ 15142

Revision 15142, 5.3 KB (checked in by oranfry, 11 years ago)

changes to the wrapper and installer logic, and a few changes to init and compile stuff

Line 
1<?xml version="1.0" encoding="utf-8" ?>
2
3<!--
4        ..........................................................
5         September 2007
6         Greenstone3 'release maker' script
7         Oran Fry
8        ..........................................................
9-->
10
11<project name="lirk3-wrap" default="wrap">
12
13    <target name="wrap">
14        <addressedcall target="setup-for-wrapping"/>
15        <addressedcall target="compile-wrapper"/>
16        <addressedcall target="clean-up-after-wrapping"/>
17    </target>
18
19
20    <target name="setup-for-wrapping">
21        <if><bool><istrue value="${execute}"/></bool>
22
23            <!-- create and setup the build directory -->
24            <mkdir dir="${basedir}/wrapped-installer/build"/>
25            <copy todir="${basedir}/wrapped-installer/build" file="${lirk3.home}/wrapper/mywrapper.c"/>
26
27            <!-- copy bundled files -->
28            <copy todir="${basedir}/wrapped-installer/build" file="${lirk3.home}/search4j/search4j"/>
29            <copy todir="${basedir}/wrapped-installer/build" file="${lirk3.home}/wrapper/${java.installer}"/>
30            <copy todir="${basedir}/wrapped-installer/build" file="${basedir}/installer/greenstone3.jar"/>
31
32            <!-- substitute the real java installer filename and min version into various files -->
33            <rsr file="${basedir}/wrapped-installer/build/mywrapper.c" pattern="@java.installer@" replacement="${java.installer}"/>
34            <rsr file="${basedir}/wrapped-installer/build/mywrapper.c" pattern="@java.extracted@" replacement="${java.extracted}"/>
35            <rsr file="${basedir}/wrapped-installer/build/mywrapper.c" pattern="@java.min.version@" replacement="${java.min.version}"/>
36
37        </if>
38    </target>
39
40    <target name="compile-wrapper">
41        <if><bool><istrue value="${execute}"/></bool>
42
43            <echo level="info">create an object file (extension .o) for each file to bundle</echo>
44            <exec executable="/usr/bin/objcopy" dir="${basedir}/wrapped-installer/build">
45                <arg line="-I binary -O elf32-i386 -B i386 --redefine-sym _binary_greenstone3_jar_start=greenstone3jar --readonly-text greenstone3.jar greenstone3.jar.o"/>
46            </exec>
47            <exec executable="/usr/bin/objcopy" dir="${basedir}/wrapped-installer/build">
48                <arg line="-I binary -O elf32-i386 -B i386 --redefine-sym _binary_search4j_start=search4j --readonly-text search4j search4j.o"/>
49            </exec>
50            <exec executable="/usr/bin/objcopy" dir="${basedir}/wrapped-installer/build">
51                <arg line="-I binary -O elf32-i386 -B i386 --redefine-sym _binary_${java.installer}_start=java --readonly-text ${java.installer} java.o"/>
52            </exec>
53
54
55            <echo level="info">create a header file declaring bundled greenstone.jar and search4j</echo>
56            <delete file="mywrapper.h"/>
57
58            <!-- greenstone.jar -->
59            <exec executable="ls" dir="${basedir}/wrapped-installer/build" outputproperty="greenstone3.jar.ls"><arg line="-l greenstone3.jar"/></exec>
60            <exec executable="sed" inputstring="${greenstone3.jar.ls}" outputproperty="greenstone3.jar.size"><arg line="-e 's/^[^\ ]*\ *[^\ ]*\ *[^\ ]*\ *[^\ ]*\ *\([0-9]*\).*$/\1/g'"/></exec>
61            <exec executable="echo" output="${basedir}/wrapped-installer/build/mywrapper.h"><arg line="extern const char greenstone3jar[${greenstone3.jar.size}];"/></exec>
62
63            <!-- search4j -->
64            <exec executable="ls" dir="${basedir}/wrapped-installer/build" outputproperty="search4j.ls"><arg line="-l search4j"/></exec>
65            <exec executable="sed" inputstring="${search4j.ls}" outputproperty="search4j.size"><arg line="-e 's/^[^\ ]*\ *[^\ ]*\ *[^\ ]*\ *[^\ ]*\ *\([0-9]*\).*$/\1/g'"/></exec>
66            <exec executable="echo" output="${basedir}/wrapped-installer/build/mywrapper.h" append="true"><arg line="extern const char search4j[${search4j.size}];"/></exec>
67
68
69            <echo level="info">compile the wrapper program</echo>
70            <exec executable="g++" dir="${basedir}/wrapped-installer/build">
71                <arg line="-Wall -static -static-libgcc -c -o mywrapper.o mywrapper.c"/>
72            </exec>
73
74            <echo level="info">link, bundling the files to be bundled</echo>
75            <exec executable="g++" dir="${basedir}/wrapped-installer/build">
76                <arg line="-static -static-libgcc -o  ../greenstone-${version}-linux.bin mywrapper.o greenstone3.jar.o search4j.o"/>
77            </exec>
78
79
80            <echo level="info">add java to the header file</echo>
81            <!-- java -->
82            <exec executable="ls" dir="${basedir}/wrapped-installer/build" outputproperty="java.ls"><arg line="-l ${java.installer}"/></exec>
83            <exec executable="sed" inputstring="${java.ls}" outputproperty="java.size"><arg line="-e 's/^[^\ ]*\ *[^\ ]*\ *[^\ ]*\ *[^\ ]*\ *\([0-9]*\).*$/\1/g'"/></exec>
84            <exec executable="echo" output="${basedir}/wrapped-installer/build/mywrapper.h" append="true"><arg line="extern const char java[${java.size}];"/></exec>
85            <exec executable="echo" output="${basedir}/wrapped-installer/build/mywrapper.h" append="true"><arg line="#define java_is_bundled yes"/></exec>
86
87            <echo level="info">recompile the wrapper program</echo>
88            <exec executable="g++" dir="${basedir}/wrapped-installer/build">
89                <arg line="-Wall -static -static-libgcc -c -o mywrapper.o mywrapper.c"/>
90            </exec>
91
92            <echo level="info">relink, bundling the files to be bundled</echo>
93            <exec executable="g++" dir="${basedir}/wrapped-installer/build">
94                <arg line="-static -static-libgcc -o  ../greenstone-${version}-linux-with-jre.bin mywrapper.o greenstone3.jar.o search4j.o java.o"/>
95            </exec>
96
97
98
99        </if>
100    </target>
101
102    <target name="clean-up-after-wrapping">
103        <if><bool><istrue value="${execute}"/></bool>
104            <delete dir="${basedir}/wrapped-installer/build"/>
105        </if>
106    </target>
107
108
109
110</project>
Note: See TracBrowser for help on using the browser.