moved ProGuard optimization into Android build file since it's the only way to fully optimize the final build product (inlining of key methods). Also always dump proguard results.

git-svn-id: https://zxing.googlecode.com/svn/trunk@649 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2008-10-29 15:42:22 +00:00
parent d80cd07064
commit 6f6da9a04c
3 changed files with 62 additions and 15 deletions

View file

@ -1,4 +1,4 @@
<?xml version="1.0" ?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
Copyright (C) 2008 ZXing authors Copyright (C) 2008 ZXing authors
@ -160,6 +160,50 @@ limitations under the License.
</javac> </javac>
</target> </target>
<target name="compile-release" depends="dirs, resource-src, aidl">
<javac encoding="ascii" target="1.5" debug="off" extdirs=""
srcdir="."
destdir="${outdir-classes}"
bootclasspath="${android-jar}">
<classpath>
<fileset dir="${external-libs}" includes="*.jar"/>
</classpath>
</javac>
</target>
<target name="optimize" depends="compile-release">
<fail message="Please put proguard.jar in 'bin' under the WTK install directory">
<condition>
<not>
<available file="${WTK-home}/bin/proguard.jar" type="file"/>
</not>
</condition>
</fail>
<unzip src="../core/core.jar" dest="${outdir-classes}" overwrite="true"/>
<jar jarfile="temp.jar" basedir="${outdir-classes}"/>
<delete dir="${outdir-classes}"/>
<mkdir dir="${outdir-classes}"/>
<java jar="${WTK-home}/bin/proguard.jar" fork="true" failonerror="true">
<jvmarg value="-Dmaximum.inlined.code.length=32"/>
<arg value="-injars temp.jar"/>
<arg value="-outjars temp-optimized.jar"/>
<arg value="-libraryjars ${android-jar}"/>
<arg value="-keepattributes Exceptions,InnerClasses,Signature,!LocalVariableTable,!LocalVariableTypeTable"/>
<arg value="-keep class com.google.zxing.client.android.*Activity"/>
<arg value="-target 5"/>
<arg value="-optimizationpasses 7"/>
<arg value="-allowaccessmodification"/>
<arg value="-dontshrink"/>
<arg value="-dontobfuscate"/>
<arg value="-dontskipnonpubliclibraryclasses"/>
<arg value="-verbose"/>
<arg value="-dump proguard-dump.txt"/>
</java>
<delete file="temp.jar"/>
<unzip src="temp-optimized.jar" dest="${outdir-classes}" overwrite="true"/>
<delete file="temp-optimized.jar"/>
</target>
<!-- Convert this project's .class files into .dex files. --> <!-- Convert this project's .class files into .dex files. -->
<target name="dex" depends="compile"> <target name="dex" depends="compile">
<echo>Converting compiled files and external libraries into ${outdir}/${dex-file}...</echo> <echo>Converting compiled files and external libraries into ${outdir}/${dex-file}...</echo>
@ -171,6 +215,17 @@ limitations under the License.
</apply> </apply>
</target> </target>
<target name="dex-optimized" depends="compile-release,optimize">
<echo>Converting compiled files and external libraries into ${outdir}/${dex-file}...</echo>
<apply executable="${dx}" failonerror="true" parallel="true">
<arg value="--dex" />
<arg value="--output=${intermediate-dex-ospath}" />
<arg path="${outdir-classes-ospath}" />
<!-- workaround to appease 'apply'. Not really the right Ant task to use here. -->
<fileset dir="." includes="nosuchfile.jar"/>
</apply>
</target>
<!-- Put the project's resources into the output package file. --> <!-- Put the project's resources into the output package file. -->
<target name="package-res-and-assets"> <target name="package-res-and-assets">
<echo>Packaging resources and assets...</echo> <echo>Packaging resources and assets...</echo>
@ -238,7 +293,7 @@ only when the assets dir exists. -->
<!-- Package the application without signing it. <!-- Package the application without signing it.
This allows for the application to be signed later with an official publishing key. --> This allows for the application to be signed later with an official publishing key. -->
<target name="release" depends="dex, package-res"> <target name="release" depends="dex-optimized, package-res">
<echo>Packaging ${out-unsigned-package} for release...</echo> <echo>Packaging ${out-unsigned-package} for release...</echo>
<exec executable="${apk-builder}" failonerror="true"> <exec executable="${apk-builder}" failonerror="true">
<arg value="${out-unsigned-package-ospath}" /> <arg value="${out-unsigned-package-ospath}" />
@ -249,8 +304,6 @@ only when the assets dir exists. -->
<arg value="${intermediate-dex-ospath}" /> <arg value="${intermediate-dex-ospath}" />
<arg value="-rf" /> <arg value="-rf" />
<arg value="${srcdir-ospath}" /> <arg value="${srcdir-ospath}" />
<arg value="-rj" />
<arg value="${external-libs-ospath}" />
</exec> </exec>
<echo>It will need to be signed with jarsigner before being published.</echo> <echo>It will need to be signed with jarsigner before being published.</echo>
</target> </target>
@ -284,6 +337,7 @@ only when the assets dir exists. -->
<target name="clean"> <target name="clean">
<delete dir="${outdir}"/> <delete dir="${outdir}"/>
<delete file="proguard-dump.txt"/>
</target> </target>
</project> </project>

View file

@ -87,21 +87,11 @@
<arg value="-dontobfuscate"/> <arg value="-dontobfuscate"/>
<arg value="-optimizationpasses 7"/> <arg value="-optimizationpasses 7"/>
<arg value="-verbose"/> <arg value="-verbose"/>
<arg value="-dump proguard-dump.txt"/>
</java> </java>
<delete file="temp.jar"/> <delete file="temp.jar"/>
</target> </target>
<target name="dump">
<java jar="${WTK-home}/bin/proguard.jar" fork="true">
<arg value="-injars core.jar"/>
<arg value="-libraryjars ${WTK-home}/lib/cldcapi11.jar"/>
<arg value="-dontshrink"/>
<arg value="-dontobfuscate"/>
<arg value="-dontoptimize"/>
<arg value="-dump dump.txt"/>
</java>
</target>
<target name="build-test" depends="init,build"> <target name="build-test" depends="init,build">
<fail message="Please build 'javase' first"> <fail message="Please build 'javase' first">
<condition> <condition>
@ -188,6 +178,7 @@
<delete dir="build-test"/> <delete dir="build-test"/>
<delete file="core.jar"/> <delete file="core.jar"/>
<delete file="ZXingReader.*"/> <delete file="ZXingReader.*"/>
<delete file="proguard-dump.txt"/>
</target> </target>
</project> </project>

View file

@ -121,6 +121,7 @@
<arg value="-overloadaggressively"/> <arg value="-overloadaggressively"/>
<arg value="-allowaccessmodification"/> <arg value="-allowaccessmodification"/>
<arg value="-verbose"/> <arg value="-verbose"/>
<arg value="-dump proguard-dump.txt"/>
</java> </java>
<delete file="temp.jar"/> <delete file="temp.jar"/>
@ -157,6 +158,7 @@
<delete dir="." includes="*.jar"/> <delete dir="." includes="*.jar"/>
<delete dir="." includes="*.jad"/> <delete dir="." includes="*.jad"/>
<delete file="src/com/google/zxing/client/j2me/MANIFEST.MF"/> <delete file="src/com/google/zxing/client/j2me/MANIFEST.MF"/>
<delete file="proguard-dump.txt"/>
</target> </target>
</project> </project>