Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Unified Diff: build/android/ant/apk-build.xml

Issue 12963009: Split apk-build.xml into 3 steps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « android_webview/android_webview_tests.gypi ('k') | build/android/ant/apk-codegen.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/ant/apk-build.xml
diff --git a/build/android/ant/apk-build.xml b/build/android/ant/apk-build.xml
deleted file mode 100644
index d123279a58de9a50fae3aa2abae0671542a50dd3..0000000000000000000000000000000000000000
--- a/build/android/ant/apk-build.xml
+++ /dev/null
@@ -1,605 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (C) 2005-2008 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<project name="android_rules" default="debug">
-
- <property-location name="out.dir" location="${OUT_DIR}" check-exists="false" />
-
- <path id="javac.srcdirs.additional">
- <filelist files="${ADDITIONAL_SRC_DIRS}"/>
- <filelist files="${GENERATED_SRC_DIRS}"/>
- </path>
-
- <!--
- Include additional resource folders in the apk, e.g. content/.../res. We
- list the res folders in project.library.res.folder.path and the
- corresponding java packages in project.library.packages, which must be
- semicolon-delimited while ADDITIONAL_RES_PACKAGES is space-delimited, hence
- the javascript task.
- -->
- <path id="project.library.res.folder.path">
- <filelist files="${ADDITIONAL_RES_DIRS}"/>
- </path>
- <path id="project.library.bin.r.file.path">
- <filelist files="${ADDITIONAL_R_TEXT_FILES}"/>
- </path>
- <path id="project.library.manifest.file.path">
- <filelist files="${LIBRARY_MANIFEST_PATHS}"/>
- </path>
- <script language="javascript">
- var before = project.getProperty("ADDITIONAL_RES_PACKAGES");
- project.setProperty("project.library.packages", before.replaceAll(" ", ";"));
- </script>
-
- <property-value name="target.abi" value="${APP_ABI}"/>
-
- <!--
- We use the PROGUARD_ENABLED flag for enabling proguard. By default proguard is enabled for
- Release builds if proguard.config is set. Setting proguard.config even to an empty string will
- enable proguard. Set this property only when we have explicitly enabled proguard.
- -->
- <condition property="proguard.config" value="${PROGUARD_FLAGS}">
- <istrue value="${PROGUARD_ENABLED}"/>
- </condition>
-
- <!-- Set the output directory for the final apk to the ${apks.dir}. -->
- <property-location name="out.final.file"
- location="${apks.dir}/${ant.project.name}.apk"
- check-exists="false"/>
-
- <!-- Classpath for javac -->
- <path id="javac.custom.classpath">
- <filelist files="${INPUT_JARS_PATHS}"/>
- </path>
-
- <!--
- TODO(cjhopman): This is wrong for proguard builds. In that case, it should be just the
- obfuscated jar.
- -->
- <path id="out.dex.jar.input.ref">
- <path refid="javac.custom.classpath"/>
- </path>
-
- <path id="native.libs.gdbserver">
- <fileset file="${android.gdbserver}"/>
- </path>
-
- <!-- Disables automatic signing. -->
- <property name="build.is.signing.debug" value="false"/>
-
- <!-- SDK tools assume that out.packaged.file is signed and name it "...-unaligned" -->
- <property name="out.packaged.file"
- value="${apks.dir}/${ant.project.name}-unsigned.apk" />
- <property name="out.unaligned.file"
- value="${apks.dir}/${ant.project.name}-unaligned.apk" />
-
- <!-- fileset exclude patterns (space separated) to prevent
- files inside src/ from being packaged. -->
- <property name="android.package.excludes" value="" />
-
- <!-- set some properties used for filtering/override. If those weren't defined
- before, then this will create them with empty values, which are then ignored
- by the custom tasks receiving them. -->
- <property-value name="version.code" value="${APP_MANIFEST_VERSION_CODE}"/>
- <property-value name="version.name" value="${APP_MANIFEST_VERSION_NAME}"/>
-
- <property name="aapt.resource.filter" value="" />
- <!-- 'aapt.ignore.assets' is the list of file patterns to ignore under /res and /assets.
- Default is "!.svn:!.git:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~"
-
- Overall patterns syntax is:
- [!][<dir>|<file>][*suffix-match|prefix-match*|full-match]:more:patterns...
-
- - The first character flag ! avoids printing a warning.
- - Pattern can have the flag "<dir>" to match only directories
- or "<file>" to match only files. Default is to match both.
- - Match is not case-sensitive.
- -->
- <property name="aapt.ignore.assets" value="" />
-
- <!-- compilation options -->
- <property name="java.encoding" value="UTF-8" />
- <property name="java.target" value="1.5" />
- <property name="java.source" value="1.5" />
- <property name="java.compilerargs" value="" />
-
- <!-- manifest merger default value if it's not set.-->
- <condition property="manifestmerger.enabled"
- value="false"
- else="true">
- <equals arg1="${LIBRARY_MANIFEST_PATHS}" arg2=""/>
- </condition>
-
- <!-- Verbosity -->
- <property name="verbose" value="false" />
-
- <!-- ******************************************************* -->
- <!-- ********************* Custom Tasks ******************** -->
- <!-- ******************************************************* -->
-
- <!-- jar file from where the tasks are loaded -->
- <path id="android.antlibs">
- <pathelement path="${sdk.dir}/tools/lib/anttasks.jar" />
- </path>
-
- <!-- Custom tasks -->
- <taskdef resource="anttasks.properties" classpathref="android.antlibs" />
-
- <!-- ******************************************************* -->
- <!-- ******************* Other Properties ****************** -->
- <!-- ******************************************************* -->
- <!-- overriding these properties may break the build
- unless the whole file is updated -->
-
- <target name="-set-release-mode">
- <!-- record the current build target -->
- <property name="build.target" value="release" />
-
- <!-- release mode is only valid if the manifest does not explicitly
- set debuggable to true. default is false. -->
- <xpath input="${manifest.abs.file}" expression="/manifest/application/@android:debuggable"
- output="build.is.packaging.debug" default="false"/>
-
- <if condition="${build.is.packaging.debug}">
- <then>
- <echo>*************************************************</echo>
- <echo>**** Android Manifest has debuggable=true ****</echo>
- <echo>**** Doing DEBUG packaging with RELEASE keys ****</echo>
- <echo>*************************************************</echo>
- </then>
- <else>
- <!-- property only set in release mode.
- Useful for if/unless attributes in target node
- when using Ant before 1.8 -->
- <property name="build.is.mode.release" value="true"/>
- </else>
- </if>
-
- <echo level="info">proguard.config is ${proguard.config}</echo>
- <condition property="proguard.enabled" value="true" else="false">
- <and>
- <isset property="build.is.mode.release" />
- <isset property="proguard.config" />
- </and>
- </condition>
- <if condition="${proguard.enabled}">
- <then>
- <echo level="info">Proguard.config is enabled</echo>
- <!-- Secondary dx input (jar files) is empty since all the
- jar files will be in the obfuscated jar -->
- <path id="out.dex.jar.input.ref" />
- </then>
- </if>
- </target>
-
- <target name="-set-debug-mode">
- <!-- record the current build target -->
- <property name="build.target" value="debug" />
-
- <!-- whether the build is a debug build. always set. -->
- <property name="build.is.packaging.debug" value="true" />
-
- <!-- proguard is never enabled in debug mode -->
- <property name="proguard.enabled" value="false"/>
- </target>
-
-
- <!-- Input directories -->
- <property name="source.dir" value="src" />
- <property name="source.absolute.dir" location="${source.dir}" />
- <property-value name="gen.absolute.dir" value="${out.dir}/gen"/>
- <property name="resource.absolute.dir" value="${RESOURCE_DIR}"/>
- <property name="asset.dir" value="assets" />
- <condition property="asset.absolute.dir"
- value="${out.dir}/assets"
- else="${ASSET_DIR}">
- <equals arg1="${ASSET_DIR}" arg2=""/>
- </condition>
-
- <property-location name="native.libs.absolute.dir" location="${out.dir}/libs"
- check-exists="false"/>
-
- <property name="manifest.file" value="AndroidManifest.xml" />
- <property name="manifest.abs.file" location="${manifest.file}" />
-
- <!-- Output directories -->
- <property name="out.dir" value="bin" />
- <property name="out.absolute.dir" location="${out.dir}" />
- <property name="out.classes.absolute.dir" location="${out.dir}/classes" />
- <property name="out.res.absolute.dir" location="${out.dir}/res" />
- <property name="out.aidl.absolute.dir" location="${out.dir}/aidl" />
- <property name="out.dexed.absolute.dir" location="${out.dir}/dexedLibs" />
- <property name="out.manifest.abs.file" location="${out.dir}/AndroidManifest.xml" />
-
- <!-- tools location -->
- <property name="android.tools.dir" location="${sdk.dir}/tools" />
- <property name="android.platform.tools.dir" location="${sdk.dir}/platform-tools" />
- <property name="exe" value="" />
- <property name="bat" value="" />
- <property name="zipalign" location="${android.tools.dir}/zipalign${exe}" />
- <property name="aidl" location="${android.platform.tools.dir}/aidl${exe}" />
- <property name="aapt" location="${android.platform.tools.dir}/aapt${exe}" />
- <property name="dx" location="${android.platform.tools.dir}/dx${bat}" />
-
- <!-- Intermediate files -->
- <property name="dex.file.name" value="classes.dex" />
- <property name="intermediate.dex.file" location="${out.absolute.dir}/${dex.file.name}" />
- <property name="resource.package.file.name" value="${ant.project.name}.ap_" />
-
- <!-- Build property file -->
- <property name="out.build.prop.file" location="${out.absolute.dir}/build.prop" />
-
- <!--
- For debug builds, the Android SDK tools create a key in ~/.android and sign the build with it.
- This has caused all kinds of issues. Instead, the debug build should be signed with a key in
- build/android/ant. The SDK tools do not provide any support for overriding that behavior and so
- instead one must use the hack below.
- -->
- <property name="key.store" value="${CHROMIUM_SRC}/build/android/ant/chromium-debug.keystore"/>
- <property name="key.store.password" value="chromium"/>
- <property name="key.alias" value="chromiumdebugkey"/>
- <property name="key.alias.password" value="chromium"/>
-
- <!-- properties for packaging -->
- <property name="build.packaging.nocrunch" value="true" />
-
- <property name="need.javac.fork" value="false" />
-
- <!-- ******************************************************* -->
- <!-- ******************** Build Targets ******************** -->
- <!-- ******************************************************* -->
-
- <!-- generic setup -->
- <target name="-setup">
- <checkenv />
- <echo level="info">Project Name: ${ant.project.name}</echo>
- <gettype projectTypeOut="project.type" />
-
- <!-- sets a few boolean based on project.type
- to make the if task easier -->
- <condition property="project.is.testapp" value="true" else="false">
- <equals arg1="${project.type}" arg2="test-app" />
- </condition>
-
- <!-- get the project manifest package -->
- <xpath input="${manifest.abs.file}"
- expression="/manifest/@package" output="project.app.package" />
-
- <!-- read the previous build mode -->
- <property file="${out.build.prop.file}" />
-
- <echo level="info">Resolving Build Target for ${ant.project.name}...</echo>
- <!-- load project properties, resolve Android target, library dependencies
- and set some properties with the results.
- All property names are passed as parameters ending in -Out -->
- <gettarget
- androidJarFileOut="project.target.android.jar"
- androidAidlFileOut="project.target.framework.aidl"
- bootClassPathOut="project.target.class.path"
- targetApiOut="project.target.apilevel"
- minSdkVersionOut="project.minSdkVersion" />
-
- <property name="manifest.hasCode" value="true" />
-
- <echo level="info">----------</echo>
- <echo level="info">Creating output directories if needed...</echo>
- <mkdir dir="${out.absolute.dir}" />
- <mkdir dir="${out.res.absolute.dir}" />
- <mkdir dir="${gen.absolute.dir}" />
- <mkdir dir="${out.classes.absolute.dir}" />
- <mkdir dir="${out.dexed.absolute.dir}" />
- </target>
-
- <!-- Code Generation: compile resources (aapt -> R.java), aidl -->
- <target name="-code-gen" depends="-setup">
- <!-- always merge manifest -->
- <mergemanifest
- appManifest="${manifest.abs.file}"
- outManifest="${out.manifest.abs.file}"
- enabled="${manifestmerger.enabled}">
- <library refid="project.library.manifest.file.path" />
- </mergemanifest>
-
- <echo level="info">----------</echo>
- <echo level="info">Handling Resources...</echo>
- <aapt executable="${aapt}"
- command="package"
- verbose="${verbose}"
- manifest="${out.manifest.abs.file}"
- androidjar="${project.target.android.jar}"
- rfolder="${gen.absolute.dir}"
- nonConstantId="${android.library}"
- libraryResFolderPathRefid="project.library.res.folder.path"
- libraryPackagesRefid="project.library.packages"
- libraryRFileRefid="project.library.bin.r.file.path"
- ignoreAssets="${aapt.ignore.assets}"
- binFolder="${out.absolute.dir}"
- proguardFile="${out.absolute.dir}/proguard.txt">
- <res path="${out.res.absolute.dir}" />
- <res path="${resource.absolute.dir}" />
- </aapt>
-
- </target>
-
- <!--
- Override the -compile target.
- This target requires 'javac.custom.classpath' to be set to reference
- of classpath to be used for javac. Also accepts custom path for
- sources: 'javac.custom.sourcepath'.
- -->
- <!-- Compiles this project's .java files into .class files. -->
- <target name="-compile" depends="-code-gen">
- <delete>
- <fileset dir="${out.classes.absolute.dir}" includes="**/*.class"/>
- </delete>
-
- <javac
- bootclasspathref="project.target.class.path"
- classpathref="javac.custom.classpath"
- debug="true"
- destdir="${out.classes.absolute.dir}"
- encoding="${java.encoding}"
- extdirs=""
- fork="${need.javac.fork}"
- includeantruntime="false"
- source="${java.source}"
- target="${java.target}"
- verbose="${verbose}">
- <src path="${source.absolute.dir}"/>
- <src path="${gen.absolute.dir}"/>
- <src>
- <path refid="javac.srcdirs.additional"/>
- </src>
- <compilerarg value="-Xlint:unchecked"/>
- <compilerarg line="${java.compilerargs}"/>
- </javac>
- <!--
- If the project needs a test jar then generate a jar containing
- all compiled classes and referenced jars.
- project.is.testapp is set by Android's ant build system based on the
- target's manifest. It is true only for instrumentation apks.
- -->
- <if condition="${project.is.testapp}">
- <then>
- <property-location name="create.test.jar.file"
- location="${CHROMIUM_SRC}/build/android/ant/create-test-jar.js"/>
- <script language="javascript" src="${create.test.jar.file}"/>
- </then>
- </if>
- <!--
- Copy gdbserver to main libs directory if building a non-instrumentation debug apk.
- -->
- <if>
- <condition>
- <and>
- <equals arg1="${build.target}" arg2="debug"/>
- <isfalse value="${project.is.testapp}"/>
- </and>
- </condition>
- <then>
- <copy todir="${out.dir}/libs/${target.abi}">
- <path refid="native.libs.gdbserver"/>
- </copy>
- </then>
- </if>
-
- <!-- Package all the compiled .class files into a .jar. -->
- <jar
- jarfile="${lib.java.dir}/${JAR_NAME}"
- basedir="${out.classes.absolute.dir}"
- />
- </target>
-
-
- <!-- Obfuscate target
- This is only active in release builds when proguard.config is defined
- in default.properties.
-
- -->
- <!--
- Override obfuscate target to pass javac.custom.classpath to Proguard. SDK tools do not provide
- any way to pass custom class paths to Proguard.
- -->
- <target name="-obfuscate" depends="-compile">
- <if condition="${proguard.enabled}">
- <then>
- <property name="obfuscate.absolute.dir" location="${out.absolute.dir}/proguard"/>
- <property name="preobfuscate.jar.file" value="${obfuscate.absolute.dir}/original.jar"/>
- <property name="obfuscated.jar.file" value="${obfuscate.absolute.dir}/obfuscated.jar"/>
- <!-- input for dex will be proguard's output -->
- <property name="out.dex.input.absolute.dir" value="${obfuscated.jar.file}"/>
-
- <!-- Add Proguard Tasks -->
- <property name="proguard.jar" location="${android.tools.dir}/proguard/lib/proguard.jar"/>
- <taskdef name="proguard" classname="proguard.ant.ProGuardTask" classpath="${proguard.jar}"/>
-
- <!-- Set the android classpath Path object into a single property. It'll be
- all the jar files separated by a platform path-separator.
- Each path must be quoted if it contains spaces.
- -->
- <pathconvert property="project.target.classpath.value" refid="project.target.class.path">
- <firstmatchmapper>
- <regexpmapper from='^([^ ]*)( .*)$$' to='"\1\2"'/>
- <identitymapper/>
- </firstmatchmapper>
- </pathconvert>
-
- <!-- Build a path object with all the jar files that must be obfuscated.
- This include the project compiled source code and any 3rd party jar
- files. -->
- <path id="project.all.classes.path">
- <pathelement location="${preobfuscate.jar.file}"/>
- <!-- Pass javac.custom.classpath for apks. -->
- <path refid="javac.custom.classpath"/>
- </path>
- <!-- Set the project jar files Path object into a single property. It'll be
- all the jar files separated by a platform path-separator.
- Each path must be quoted if it contains spaces.
- -->
- <pathconvert property="project.all.classes.value" refid="project.all.classes.path">
- <firstmatchmapper>
- <regexpmapper from='^([^ ]*)( .*)$$' to='"\1\2"'/>
- <identitymapper/>
- </firstmatchmapper>
- </pathconvert>
-
- <!-- Turn the path property ${proguard.config} from an A:B:C property
- into a series of includes: -include A -include B -include C
- suitable for processing by the ProGuard task. Note - this does
- not include the leading '-include "' or the closing '"'; those
- are added under the <proguard> call below.
- -->
- <path id="proguard.configpath">
- <pathelement path="${proguard.config}"/>
- </path>
- <pathconvert pathsep='" -include "' property="proguard.configcmd"
- refid="proguard.configpath"/>
-
- <mkdir dir="${obfuscate.absolute.dir}"/>
- <delete file="${preobfuscate.jar.file}"/>
- <delete file="${obfuscated.jar.file}"/>
- <jar basedir="${out.classes.absolute.dir}"
- destfile="${preobfuscate.jar.file}"/>
- <proguard>
- -include "${proguard.configcmd}"
- -include "${out.absolute.dir}/proguard.txt"
- -injars ${project.all.classes.value}
- -outjars "${obfuscated.jar.file}"
- -libraryjars ${project.target.classpath.value}
- -dump "${obfuscate.absolute.dir}/dump.txt"
- -printseeds "${obfuscate.absolute.dir}/seeds.txt"
- -printusage "${obfuscate.absolute.dir}/usage.txt"
- -printmapping "${obfuscate.absolute.dir}/mapping.txt"
- </proguard>
- </then>
- </if>
- </target>
-
- <!-- Converts this project's .class files into .dex files -->
- <target name="-dex" depends="-obfuscate">
- <sequential>
- <!-- sets the primary input for dex. If a pre-dex task sets it to
- something else this has no effect -->
- <property name="out.dex.input.absolute.dir" value="${out.classes.absolute.dir}" />
- <property name="dex.force.jumbo" value="false" />
-
- <dex executable="${dx}"
- output="${intermediate.dex.file}"
- dexedlibs="${out.dexed.absolute.dir}"
- nolocals="false"
- forceJumbo="${dex.force.jumbo}"
- verbose="${verbose}">
- <path path="${out.dex.input.absolute.dir}"/>
- <path refid="out.dex.jar.input.ref" />
- </dex>
- </sequential>
- </target>
-
- <!-- Puts the project's resources into the output package file
- This actually can create multiple resource package in case
- Some custom apk with specific configuration have been
- declared in default.properties.
- -->
- <target name="-package-resources" depends="-setup">
- <!-- Updates the pre-processed PNG cache -->
- <exec executable="${aapt}" taskName="crunch">
- <arg value="crunch" />
- <arg value="-v" />
- <arg value="-S" />
- <arg path="${resource.absolute.dir}" />
- <arg value="-C" />
- <arg path="${out.res.absolute.dir}" />
- </exec>
- <aapt executable="${aapt}"
- command="package"
- versioncode="${version.code}"
- versionname="${version.name}"
- debug="${build.is.packaging.debug}"
- manifest="${out.manifest.abs.file}"
- assets="${asset.absolute.dir}"
- androidjar="${project.target.android.jar}"
- apkfolder="${out.absolute.dir}"
- nocrunch="${build.packaging.nocrunch}"
- resourcefilename="${resource.package.file.name}"
- resourcefilter="${aapt.resource.filter}"
- libraryResFolderPathRefid="project.library.res.folder.path"
- libraryPackagesRefid="project.library.packages"
- libraryRFileRefid="project.library.bin.r.file.path"
- previousBuildType=""
- buildType="${build.target}"
- ignoreAssets="${aapt.ignore.assets}">
- <res path="${out.res.absolute.dir}" />
- <res path="${resource.absolute.dir}" />
- <!-- <nocompress /> forces no compression on any files in assets or res/raw -->
- <!-- <nocompress extension="xml" /> forces no compression on specific file extensions in assets and res/raw -->
- </aapt>
- </target>
-
- <!-- Packages the application. -->
- <target name="-package" depends="-dex, -package-resources">
- <apkbuilder
- outfolder="${out.absolute.dir}"
- resourcefile="${resource.package.file.name}"
- apkfilepath="${out.packaged.file}"
- debugpackaging="${build.is.packaging.debug}"
- debugsigning="${build.is.signing.debug}"
- verbose="${verbose}"
- hascode="${manifest.hasCode}"
- previousBuildType="/"
- buildType="${build.is.packaging.debug}/${build.is.signing.debug}">
- <dex path="${intermediate.dex.file}"/>
- <sourcefolder path="${source.absolute.dir}"/>
- <nativefolder path="${native.libs.absolute.dir}" />
- </apkbuilder>
- </target>
-
- <!-- Signs and zipaligns the apk. -->
- <target name="-do-sign" depends="-package">
- <sequential>
- <echo level="info">Signing final apk...</echo>
- <signapk
- input="${out.packaged.file}"
- output="${out.unaligned.file}"
- keystore="${key.store}"
- storepass="${key.store.password}"
- alias="${key.alias}"
- keypass="${key.alias.password}"/>
-
- <zipalign
- executable="${zipalign}"
- input="${out.unaligned.file}"
- output="${out.final.file}"
- verbose="${verbose}" />
- <echo level="info">Release Package: ${out.final.file}</echo>
- </sequential>
- </target>
-
- <!-- Builds debug output package -->
- <target name="debug"
- depends="-set-debug-mode, -do-sign"
- description="Builds the application and signs it with a debug key.">
- </target>
-
- <!-- This runs -package-release first and then runs
- only if release-sign is true (set in -release-check,
- called by -release-no-sign)-->
- <target name="release"
- depends="-set-release-mode, -do-sign"
- description="Builds the application in release mode.">
- </target>
-
-</project>
« no previous file with comments | « android_webview/android_webview_tests.gypi ('k') | build/android/ant/apk-codegen.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698