source: android/build.xml @ 7e84451

Last change on this file since 7e84451 was 7e84451, checked in by zzz <zzz@…>, 9 years ago

Android:

  • Import the main_rules file and remove the copied rules
  • Set the version code and name in the apk badging
  • Build target is 8 to allow SD install, MIN-SDK is still 3
  • Fix NPE on new install
  • Remove some debug code from NBigI
  • Property mode set to 100644
File size: 8.5 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2
3<!--
4  -  Portions copied and modified from Android SDK
5  -  Copyright (c) 2005-2008, The Android Open Source Project
6  -  Apache 2.0 license
7  -  See ../licenses/LICENSE-Apache2.0.txt
8 -->
9
10<project name="I2PAndroid" default="help">
11
12    <!-- The local.properties file is created and updated by the 'android' tool.
13         It contain the path to the SDK. It should *NOT* be checked in in Version
14         Control Systems. -->
15    <property file="local.properties"/>
16
17    <!-- The build.properties file can be created by you and is never touched
18         by the 'android' tool. This is the place to change some of the default property values
19         used by the Ant rules.
20         Here are some properties you may want to change/update:
21
22         application-package
23             the name of your application package as defined in the manifest. Used by the
24             'uninstall' rule.
25         source-folder
26             the name of the source folder. Default is 'src'.
27         out-folder
28             the name of the output folder. Default is 'bin'.
29
30         Properties related to the SDK location or the project target should be updated
31          using the 'android' tool with the 'update' action.
32
33         This file is an integral part of the build system for your application and
34         should be checked in in Version Control Systems.
35
36         -->
37    <property file="build.properties"/>
38    <!-- set the old name to the new name -->
39    <property name="sdk-location" value="${sdk.dir}" />
40
41    <!-- The default.properties file is created and updated by the 'android' tool, as well
42         as ADT.
43         This file is an integral part of the build system for your application and
44         should be checked in in Version Control Systems. -->
45    <property file="default.properties"/>
46
47    <!-- Custom Android task to deal with the project target, and import the proper rules.
48         This requires ant 1.6.0 or above. -->
49    <path id="android.antlibs">
50        <pathelement path="${sdk-location}/tools/lib/anttasks.jar" />
51        <pathelement path="${sdk-location}/tools/lib/sdklib.jar" />
52        <pathelement path="${sdk-location}/tools/lib/androidprefs.jar" />
53        <pathelement path="${sdk-location}/tools/lib/apkbuilder.jar" />
54        <pathelement path="${sdk-location}/tools/lib/jarutils.jar" />
55    </path>
56
57    <taskdef name="setup"
58        classname="com.android.ant.SetupTask"
59        classpathref="android.antlibs"/>
60
61    <!-- Execute the Android Setup task that will setup some properties specific to the target,
62         and import the rules files.
63         To customize the rules, copy/paste them below the task, and disable import by setting
64         the import attribute to false:
65            <setup import="false" />
66         
67         This will ensure that the properties are setup correctly but that your customized
68         targets are used.
69    -->
70    <setup import="true" />
71
72    <echo>Ignore warning about SDK version</echo>
73    <!--
74         ================================================================================
75         New I2P rules
76         ================================================================================
77    -->
78
79    <!-- overrides of those in main_rules.xml -->
80
81    <target name="-pre-build" depends="copy-i2p-resources, incrementBuild" />
82
83    <target name="-pre-compile" depends="buildrouter" />
84
85    <target name="-post-compile" depends="hackcleanup, jbigi" />
86
87    <!-- new rules -->
88
89    <target name="buildrouter" depends="-dirs" >
90        <!-- build router and core -->
91        <ant dir=".." target="buildrouter" />
92
93        <!-- router -->
94        <copy file="../build/router.jar" todir="${jar.libs.dir}" />
95
96        <!-- core -->
97
98        <!-- org.bouncycastle.crypto already in android
99             but we need a little trickery because our HMac is incompatible...
100             and the libs aren't in the SDK to compile against??? -->
101        <jar destfile="${jar.libs.dir}/crypto.jar" >
102            <zipfileset src="../build/i2p.jar" >
103                <include name="org/bouncycastle/crypto/Digest.class" />
104                <include name="org/bouncycastle/crypto/Mac.class" />
105                <include name="org/bouncycastle/crypto/digests/GeneralDigest.class" />
106                <include name="org/bouncycastle/crypto/digests/MD5Digest.class" />
107            </zipfileset >
108        </jar>
109
110        <!-- lots of unneeded stuff could be deleted here -->
111        <jar destfile="${jar.libs.dir}/i2p.jar" >
112            <zipfileset src="../build/i2p.jar" >
113                <exclude name="net/i2p/util/LogWriter.class" />
114                <exclude name="net/i2p/util/SecureDirectory.class" />
115                <exclude name="net/i2p/util/SecureFile.class" />
116                <exclude name="net/i2p/util/SecureFileOutputStream.class" />
117                <exclude name="org/bouncycastle/crypto/Digest.class" />
118                <exclude name="org/bouncycastle/crypto/Mac.class" />
119                <exclude name="org/bouncycastle/crypto/digests/GeneralDigest.class" />
120                <exclude name="org/bouncycastle/crypto/digests/MD5Digest.class" />
121            </zipfileset >
122        </jar>
123    </target>
124
125    <!-- some resources -->
126    <target name="copy-i2p-resources" depends="-dirs" >
127        <copy file="../installer/resources/themes/console/images/i2plogo.png" todir="res/drawable/" />
128        <copy file="../installer/resources/blocklist.txt" tofile="res/raw/blocklist_txt" />
129    </target>
130
131    <target name="hackcleanup">
132        <delete file="${jar.libs.dir}/crypto.jar" />
133    </target>
134
135    <target name="jbigi">
136        <exec executable="sh" osfamily="unix" failonerror="true">
137            <arg value="-c" />
138            <arg value="jni/build.sh" />
139        </exec>
140        <copy file="jni/libjbigi.so" todir="${native.libs.dir}/armeabi" />
141    </target>
142
143    <target name="incrementBuild">
144        <buildnumber file="scripts/build.number" />
145        <exec executable="sh" osfamily="unix" failonerror="true">
146            <arg value="-c" />
147            <arg value="scripts/setversion.sh" />
148        </exec>
149        <!-- this loads my.version.code and my.version.name -->
150        <property file="scripts/version.properties" />
151    </target>
152
153    <!-- install now does both -->
154    <target name="reinstall" depends="install" />
155
156    <target name="distclean" depends="clean">
157        <delete dir="${jar.libs.dir}" verbose="${verbose}" />
158        <delete file="res/drawable/i2plogo.png" verbose="${verbose}"/>
159        <delete file="res/raw/blocklist_txt" verbose="${verbose}" />
160        <delete dir="jni/build/" verbose="${verbose}" />
161        <delete file="jni/libjbigi.so" verbose="${verbose}" />
162        <delete file="scripts/build.number" verbose="${verbose}" />
163        <delete file="scripts/version.properties" verbose="${verbose}" />
164    </target>
165
166    <!--
167         ================================================================================
168         From here down copied from SDK tools/ant/main_rules.xml from Tools version 11
169         and then modified
170         ================================================================================
171    -->
172
173    <!-- not necessary to copy if setup import="true" -->
174
175
176    <!--
177         override this because the ant task com.android.ant.AaptExecLoopTask has issues:
178             a) it uses version.code which main_rules sets to "" and
179             b) it can't set versionName via the aapt task, have to use the aapt command line
180    -->
181
182    <!-- Puts the project's resources into the output package file
183         This actually can create multiple resource package in case
184         Some custom apk with specific configuration have been
185         declared in default.properties.
186         -->
187    <target name="-package-resources">
188        <echo>Packaging resources</echo>
189        <exec executable="${aapt}" failonerror="true" >
190            <arg value="package" />
191            <arg value="--version-code" />
192            <arg value="${my.version.code}" />
193            <arg value="--version-name" />
194            <arg value="${my.version.name}" />
195            <arg value="-f" />
196            <arg value="-m" />
197            <arg value="-M" />
198            <arg value="AndroidManifest.xml" />
199            <arg value="-I" />
200            <arg value="${android.jar}" />
201            <arg value="-S" />
202            <arg value="${resource.absolute.dir}" />
203            <arg value="-J" />
204            <arg value="${gen.absolute.dir}" />
205            <arg value="-F" />
206            <arg value="${out.absolute.dir}/${resource.package.file.name}" />
207        </exec>
208    </target>
209
210</project>
Note: See TracBrowser for help on using the repository browser.