Make apks build from a single ant .xml template

The ant build files for each of the apks that we create consisted of
only fairly straightforward boilerplate. With the recent changes to
java_apk.gypi and the gyp targets we can now build these correctly from
a single .xml with the differences in how the targets are built being
reflected in the gyp files (and then passed into ant).

TBR=joth
BUG=145991


Review URL: https://chromiumcodereview.appspot.com/10959034

git-svn-id: http://src.chromium.org/svn/trunk/src/build@160396 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
This commit is contained in:
cjhopman@chromium.org 2012-10-05 16:51:32 +00:00
Родитель 9e99105533
Коммит ce4c432363
4 изменённых файлов: 106 добавлений и 13 удалений

Просмотреть файл

@ -0,0 +1,54 @@
<!--
Copyright (c) 2012 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<project default="debug">
<property name="ant.project.name" value="${APK_NAME}"/>
<description>
Building ${ant.project.name}.apk
</description>
<import file="common.xml"/>
<property-location
name="out.dir"
location="${PRODUCT_DIR}/${PACKAGE_NAME}"
check-exists="false"
/>
<path id="javac.srcdirs.additional">
<filelist files="${ADDITIONAL_SRC_DIRS}"/>
<filelist files="${GENERATED_SRC_DIRS}"/>
</path>
<property-value name="target.abi" value="${APP_ABI}"/>
<property name="resource.absolute.dir" value="${RESOURCE_DIR}"/>
<property-value name="gen.absolute.dir" value="${out.dir}/gen"/>
<property-location name="native.libs.absolute.dir" location="${out.dir}/libs"
check-exists="false"/>
<condition property="asset.absolute.dir"
value="${out.dir}/assets"
else="${ASSET_DIR}">
<equals arg1="${ASSET_DIR}" arg2=""/>
</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}-debug.apk"
check-exists="false"/>
<path id="out.dex.jar.input.ref">
<filelist files="${INPUT_JARS_PATHS}"/>
</path>
<!-- Classpath for javac -->
<path id="javac.custom.classpath">
<path refid="out.dex.jar.input.ref"/>
</path>
<import file="sdk-targets.xml"/>
<import file="${sdk.dir}/tools/ant/build.xml"/>
</project>

Просмотреть файл

@ -34,18 +34,15 @@
name="-compile"
depends="-build-setup, -pre-build, -code-gen, -pre-compile">
<do-only-if-manifest-hasCode elseText="hasCode = false. Skipping..." >
<!-- If souce path is not set, then use the default value -->
<!-- If javac.srcdirs.additional isn't set, set it to an empty path. -->
<if>
<condition>
<not>
<isreference refid="javac.custom.sourcepath"/>
<isreference refid="javac.srcdirs.additional"/>
</not>
</condition>
<then>
<path id="javac.custom.sourcepath">
<pathelement path="${source.absolute.dir}"/>
<pathelement path="${gen.absolute.dir}"/>
</path>
<path id="javac.srcdirs.additional"/>
</then>
</if>
<javac
@ -63,7 +60,7 @@
<src path="${source.absolute.dir}"/>
<src path="${gen.absolute.dir}"/>
<src>
<path refid="javac.custom.sourcepath"/>
<path refid="javac.srcdirs.additional"/>
</src>
<compilerarg line="${java.compilerargs}"/>
</javac>
@ -105,8 +102,10 @@
<!--
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="${generate.test.jar}">
<if condition="${project.is.testapp}">
<then>
<echo level="info">Creating test jar file:
${ant.project.name}-debug.jar</echo>
@ -168,4 +167,38 @@
</do-only-if-not-library>
<record-build-info />
</target>
<path id="native.libs.gdbserver">
<fileset file="${android.gdbserver}"/>
</path>
<target name="-post-compile">
<!--
Copy gdbserver to main libs directory if building a non-instrumentation debug apk.
TODO(jrg): For now, Chrome on Android always builds native code
as Release and java/ant as Debug, which means we always install
gdbserver. Resolve this discrepancy, possibly by making this
Release Official build java/ant as Release.
-->
<if>
<condition>
<and>
<equals arg1="${build.target}" arg2="debug"/>
<isfalse value="${project.is.testapp}"/>
</and>
</condition>
<then>
<echo message="Copying gdbserver to the apk to enable native debugging"/>
<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}/chromium_${PACKAGE_NAME}.jar"
basedir="${out.classes.absolute.dir}"
/>
</target>
</project>

Просмотреть файл

@ -18,7 +18,6 @@
#
# The generated jar-file will be:
# <(PRODUCT_DIR)/lib.java/chromium_<(package_name).jar
#
# Required variables:
# package_name - Used to name the intermediate output directory and in the
# names of some output files.
@ -67,6 +66,7 @@
],
'action': [
'ant',
'-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)',
'-DANDROID_SDK=<(android_sdk)',
'-DANDROID_SDK_ROOT=<(android_sdk_root)',
'-DANDROID_SDK_TOOLS=<(android_sdk_tools)',

Просмотреть файл

@ -39,6 +39,8 @@
# ensure that this target is rebuilt when one of these paths changes.
# additional_src_dirs - Additional directories with .java files to be compiled
# and included in the output of this target.
# asset_location - The directory where assets are located (default:
# <PRODUCT_DIR>/<package_name>/assets).
# generated_src_dirs - Same as additional_src_dirs except used for .java files
# that are generated at build time. This should be set automatically by a
# target's dependencies. The .java files in these directories are not
@ -50,9 +52,10 @@
{
'variables': {
'asset_location': '',
'additional_input_paths': [],
'input_jars_paths': [],
'native_libs_paths': [],
'additional_input_paths': [],
'additional_src_dirs': [],
'generated_src_dirs': [],
},
@ -61,8 +64,8 @@
'action_name': 'ant_<(package_name)_apk',
'message': 'Building <(package_name) apk.',
'inputs': [
'<(java_in_dir)/<(package_name)_apk.xml',
'<(java_in_dir)/AndroidManifest.xml',
'<(DEPTH)/build/android/ant/chromium-apk.xml',
'<(DEPTH)/build/android/ant/common.xml',
'<(DEPTH)/build/android/ant/sdk-targets.xml',
# If there is a separate find for additonal_src_dirs, it will find the
@ -89,14 +92,17 @@
'-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)',
'-DPRODUCT_DIR=<(ant_build_out)',
'-DAPK_NAME=<(apk_name)',
'-DASSET_DIR=<(asset_location)',
'-DADDITIONAL_SRC_DIRS=>(additional_src_dirs)',
'-DINPUT_JARS_PATHS=>(input_jars_paths)',
'-DGENERATED_SRC_DIRS=>(generated_src_dirs)',
'-DINPUT_JARS_PATHS=>(input_jars_paths)',
'-DPACKAGE_NAME=<(package_name)',
'-DRESOURCE_DIR=<(resource_dir)',
'-Dbasedir=<(java_in_dir)',
'-buildfile',
'<(java_in_dir)/<(package_name)_apk.xml'
'<(DEPTH)/build/android/ant/chromium-apk.xml'
]
},
],