diff options
author | yfriedman@chromium.org <yfriedman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-06 23:23:51 +0000 |
---|---|---|
committer | yfriedman@chromium.org <yfriedman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-06 23:23:51 +0000 |
commit | 300800480f12dc97c8e9d90dd101fabd29203115 (patch) | |
tree | 21cfcb39e090675b55c3c512da10ee721bd11817 | |
parent | 4f3db5b5a785511a73282af279d3f30c975944a9 (diff) | |
download | chromium_src-300800480f12dc97c8e9d90dd101fabd29203115.zip chromium_src-300800480f12dc97c8e9d90dd101fabd29203115.tar.gz chromium_src-300800480f12dc97c8e9d90dd101fabd29203115.tar.bz2 |
[Android] Add chrome_java target for building Java code in the chromium layer.
Also includes a refactoring of the Ant xml scripts to use a common template (contributed by shashishekhar@chromium.org). As part of this, I also continued Torne's effort of removing our reliance on environment variables. Unfortunately this currently means that you have to specify 5 gyp flags:
ANDROID_SDK, ANDROID_SDK_ROOT, ANDROID_SDK_TOOLS, ANDROID_SDK_VERSION, ANDROID_TOOLCHAIN.
This'll get better as we make further use of the checked in sdk both upstream and downstream. The problem stems from the android tree and released sdk having different configurations.
Review URL: https://chromiumcodereview.appspot.com/10830012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150172 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/android/java/base.xml | 55 | ||||
-rw-r--r-- | build/android/ant/chromium-jars.xml | 64 | ||||
-rw-r--r-- | build/android/ant/common.xml | 78 | ||||
-rw-r--r-- | build/android/ant/sdk-targets.xml | 97 | ||||
-rw-r--r-- | build/apk_test.gypi | 13 | ||||
-rw-r--r-- | build/java.gypi | 4 | ||||
-rw-r--r-- | chrome/android/java/chrome.xml | 19 | ||||
-rw-r--r-- | chrome/android/java/src/org/chromium/chrome/browser/IntentHelper.java | 2 | ||||
-rw-r--r-- | chrome/chrome.gyp | 19 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 1 | ||||
-rw-r--r-- | content/content_shell.gypi | 5 | ||||
-rw-r--r-- | content/content_tests.gypi | 5 | ||||
-rw-r--r-- | content/public/android/java/content.xml | 59 | ||||
-rw-r--r-- | content/shell/android/java/content_shell_apk.xml | 39 | ||||
-rw-r--r-- | content/shell/android/javatests/content_shell_test_apk.xml | 11 | ||||
-rw-r--r-- | media/base/android/java/media.xml | 52 | ||||
-rw-r--r-- | net/android/java/net.xml | 49 | ||||
-rwxr-xr-x | testing/android/generate_native_test.py | 4 | ||||
-rw-r--r-- | testing/android/native_test.gyp | 5 | ||||
-rw-r--r-- | testing/android/native_test_apk.xml | 26 |
20 files changed, 391 insertions, 216 deletions
diff --git a/base/android/java/base.xml b/base/android/java/base.xml index 8698341..e315875 100644 --- a/base/android/java/base.xml +++ b/base/android/java/base.xml @@ -1,52 +1,15 @@ +<!-- + 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 name="Base" default="dist" basedir="."> <description> building base java source code with ant </description> - <!-- Set global properties for this build --> - <property name="src" location="src"/> - <property name="dist" location="dist"/> - <property name="out.dir" location="${PRODUCT_DIR}/lib.java"/> - <!-- TODO(jrg): establish a standard for the intermediate java - directories. Settle on a standard once ant/jar build files - like this are androidified --> - <property name="dest.dir" location="${PRODUCT_DIR}/java/base"/> + <import file="../../../build/android/ant/chromium-jars.xml" /> - <target name="init"> - <!-- Create the time stamp --> - <tstamp/> - <!-- Create the build directory structure used by compile --> - <mkdir dir="${out.dir}"/> - <mkdir dir="${dest.dir}"/> - </target> - - <target name="compile" depends="init" - description="compile the source " > - <!-- Compile the java code from ${src} into ${build} --> - <!-- TODO(jrg): adapting this to a proper android antfile will - remove warnings like this: - base.xml:23: warning: 'includeantruntime' was not set, - defaulting to build.sysclasspath=last; - set to false for repeatable builds - --> - <javac srcdir="${src}" destdir="${dest.dir}" debug="true" includeantruntime="false"> - <classpath> - <path location="${ANDROID_SDK}/android.jar"/> - </classpath> - </javac> - </target> - - <target name="dist" depends="compile" - description="generate the distribution" > - <!-- Create the distribution directory --> - <mkdir dir="${out.dir}"/> - - <jar jarfile="${out.dir}/chromium_base.jar" basedir="${dest.dir}"/> - </target> - - <target name="clean" - description="clean up" > - <!-- Delete the appropriate directory trees --> - <delete dir="${dest.dir}"/> - <delete dir="${dist}"/> - </target> + <path id="javac.custom.classpath"> + <pathelement location="${ANDROID_SDK}/android.jar" /> + </path> </project> diff --git a/build/android/ant/chromium-jars.xml b/build/android/ant/chromium-jars.xml new file mode 100644 index 0000000..dbe01ea --- /dev/null +++ b/build/android/ant/chromium-jars.xml @@ -0,0 +1,64 @@ +<!-- + 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 name="chromium-jars" default="dist"> + <!-- + Common ant build file for for chromium_*.jars. + For creating a new chromium_*.jar : + 1. Use build/java.gyp action. This action will set PACKAGE_NAME. + The jar will be created as chromium_${PACKAGE_NAME} in + ${PRODUCT_DIR}/lib.java. + 2. Set javac.custom.classpath to classpath to use for javac. + 3. Override javac.srcdir for providing custom source directory for javac. + --> + + <import file="common.xml"/> + <property-location name="src" location="src"/> + <property-location name="lib.dir" location="${PRODUCT_DIR}/lib.java" + check-exists="false"/> + <property-location name="dest.dir" location="${PRODUCT_DIR}/java/${PACKAGE_NAME}" + check-exists="false"/> + + <target name="init"> + <!-- Create the time stamp --> + <tstamp/> + <!-- Create the build directory structure used by compile --> + <mkdir dir="${lib.dir}"/> + <mkdir dir="${dest.dir}"/> + </target> + + <!-- + Compile target for jars. Requires javac.custom.classpath to be set. + Optionally javac.srcdir can be overridden to custom path for src + directories. + --> + <target name="compile" depends="init" description="Compiles source." > + <fail message="Error: javac.custom.classpath is not set. Please set it to + classpath for javac."> + <condition> + <not><isreference refid="javac.custom.classpath"/></not> + </condition> + </fail> + <property-value name="javac.srcdir" value ="${src}"/> + <echo>Compiling ${javac.srcdir}, classpath: ${toString:javac.custom.classpath}</echo> + <javac srcdir="${javac.srcdir}" destdir="${dest.dir}" debug="true" includeantruntime="false"> + <classpath> + <path refid="javac.custom.classpath" /> + </classpath> + </javac> + </target> + + <target name="dist" depends="compile" + description="Generate chromium_${PACKAGE_NAME}.jar."> + <!-- Create the distribution directory --> + <mkdir dir="${lib.dir}" /> + <jar jarfile="${lib.dir}/chromium_${PACKAGE_NAME}.jar" basedir="${dest.dir}"/> + </target> + + <target name="clean" description="clean up"> + <!-- Delete the appropriate directory trees --> + <delete dir="${dest.dir}" /> + </target> +</project> diff --git a/build/android/ant/common.xml b/build/android/ant/common.xml new file mode 100644 index 0000000..c7c730b --- /dev/null +++ b/build/android/ant/common.xml @@ -0,0 +1,78 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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 name="chrome_common_defines"> + <!-- Common build properties for Chrome for android. --> + + <!-- + Macro for checking that a property is correctly set. Performs checks for: + 1. Property is set and not null. + 2. String value of property does not contains any '$' signs. + --> + <macrodef name="check-property-value"> + <attribute name="property"/> + <sequential> + <fail message ="Property @{property} is not set."> + <condition> + <or> + <not><isset property="@{property}"/></not> + <length string="${@{property}}" trim="true" when="less" length="1"/> + </or> + </condition> + </fail> + <!-- + Check for $ signs. This catches errors when properties are initialized from environment + variables. E.g. if we have <property name="foo" value="${env.bar}" /> but env.bar is + not set then foo will have the literal value of '${env.bar}'. + --> + <fail message="Value checked failed for property: @{property} : ${@{property}}. + Property value contains an uninitialized environment variable."> + <condition> + <contains string="${@{property}}" substring="$"/> + </condition> + </fail> + </sequential> + </macrodef> + + <!-- + A safe setter for location properties. Checks that a location is not + empty and actually exists. For specifying output directories, location + check can be disabled by specifying check-exists="false". + --> + <macrodef name="property-location"> + <attribute name="name"/> + <attribute name="location"/> + <attribute name="check-exists" default="true"/> + <sequential> + <property name="@{name}" location="@{location}"/> + <check-property-value property="@{name}"/> + <fail message="Location specified for @{name} : @{location} does not exist."> + <condition> + <and> + <equals arg1="@{check-exists}" arg2="true"/> + <not><available type="dir" file="@{location}"/></not> + </and> + </condition> + </fail> + </sequential> + </macrodef> + + <!-- A safe setter for property values --> + <macrodef name="property-value"> + <attribute name="name"/> + <attribute name="value"/> + <sequential> + <property name="@{name}" value="@{value}"/> + <check-property-value property="@{name}"/> + </sequential> + </macrodef> + + <!-- Common environment properties. --> + <property-location name="sdk.dir" location="${ANDROID_SDK_ROOT}"/> + <property-value name="target" value="android-${ANDROID_SDK_VERSION}"/> + <property name="source.dir" location="src"/> + <property-location name="toolchain.dir" location="${ANDROID_TOOLCHAIN}"/> +</project> diff --git a/build/android/ant/sdk-targets.xml b/build/android/ant/sdk-targets.xml new file mode 100644 index 0000000..8f980b4 --- /dev/null +++ b/build/android/ant/sdk-targets.xml @@ -0,0 +1,97 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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 name="chrome_sdk_overrides" > + <!-- + Redefinition of targets used by SDK tools. + Supported version: SDK tools revision 20. + + SDK tools do not allow easy way of extending classpaths + for aidl and javac. This file defines targets which can be used to + override targets used by tools. + --> + + <!-- + 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'. + --> + <target + 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> + <condition> + <not> + <isreference refid="javac.custom.sourcepath"/> + </not> + </condition> + <then> + <path id="javac.custom.sourcepath"> + <pathelement path="${source.absolute.dir}"/> + <pathelement path="${gen.absolute.dir}"/> + </path> + </then> + </if> + <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.custom.sourcepath"/> + </src> + <compilerarg line="${java.compilerargs}"/> + </javac> + <!-- + If the project is instrumented, then instrument the classes + TODO(shashishekhar): Add option to override emma filter. + --> + <if condition="${build.is.instrumented}"> + <then> + <echo level="info"> + Instrumenting classes from ${out.absolute.dir}/classes... + </echo> + <!-- build the default filter to remove R, Manifest, BuildConfig --> + <getemmafilter + appPackage="${project.app.package}" + filterOut="emma.default.filter" + libraryPackagesRefId="project.library.packages"/> + <!-- + Define where the .em file is output. + This may have been setup already if this is a library. + --> + <property name="emma.coverage.absolute.file" + location="${out.absolute.dir}/coverage.em"/> + <!-- It only instruments class files, not any external libs --> + + <emma enabled="true"> + <instr + instrpath="${out.absolute.dir}/classes" + metadatafile="${emma.coverage.absolute.file}" + mode="overwrite" + outdir="${out.absolute.dir}/classes" + verbosity="${verbosity}"> + <filter excludes="${emma.default.filter}"/> + <filter value="${emma.filter}"/> + </instr> + </emma> + </then> + </if> + </do-only-if-manifest-hasCode> + </target> +</project> diff --git a/build/apk_test.gypi b/build/apk_test.gypi index 557499b..bd74105 100644 --- a/build/apk_test.gypi +++ b/build/apk_test.gypi @@ -45,9 +45,20 @@ '<(PRODUCT_DIR)/<(test_suite_name)_apk', '--app_abi', '<(android_app_abi)', + '--sdk-build=<(sdk_build)', '--ant-args', '-DPRODUCT_DIR=<(ant_build_out)', - '--sdk-build=<(sdk_build)', + '--ant-args', + '-DANDROID_SDK=<(android_sdk)', + '--ant-args', + '-DANDROID_SDK_ROOT=<(android_sdk_root)', + '--ant-args', + '-DANDROID_SDK_TOOLS=<(android_sdk_tools)', + '--ant-args', + '-DANDROID_SDK_VERSION=<(android_sdk_version)', + '--ant-args', + '-DANDROID_TOOLCHAIN=<(android_toolchain)', + '--ant-compile' ], }], }], # 'OS == "android" and gtest_target_type == "shared_library" diff --git a/build/java.gypi b/build/java.gypi index 89f4c6b..f3d9798 100644 --- a/build/java.gypi +++ b/build/java.gypi @@ -47,6 +47,10 @@ '-DPRODUCT_DIR=<(ant_build_out)', '-DPACKAGE_NAME=<(package_name)', '-DANDROID_SDK=<(android_sdk)', + '-DANDROID_SDK_ROOT=<(android_sdk_root)', + '-DANDROID_SDK_TOOLS=<(android_sdk_tools)', + '-DANDROID_SDK_VERSION=<(android_sdk_version)', + '-DANDROID_TOOLCHAIN=<(android_toolchain)', '-buildfile', '<(java_in_dir)/<(package_name).xml', ] diff --git a/chrome/android/java/chrome.xml b/chrome/android/java/chrome.xml new file mode 100644 index 0000000..410af23 --- /dev/null +++ b/chrome/android/java/chrome.xml @@ -0,0 +1,19 @@ +<!-- + 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 name="Chrome" default="dist" basedir="."> + <description> + Building chrome.jar from java source code. + </description> + <import file="../../../build/android/ant/chromium-jars.xml" /> + <path id="javac.custom.classpath"> + <pathelement location="${ANDROID_SDK}/android.jar" /> + <pathelement location="${lib.dir}/chromium_content.jar" /> + <pathelement location="${lib.dir}/chromium_base.jar" /> + <pathelement location="${lib.dir}/chromium_net.jar" /> + </path> + <!-- Override javac path to include jars in lib.java directory --> + <property-value name="javac.srcdir" value="${src}" /> +</project> diff --git a/chrome/android/java/src/org/chromium/chrome/browser/IntentHelper.java b/chrome/android/java/src/org/chromium/chrome/browser/IntentHelper.java index 487d71d..ffc0695 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/IntentHelper.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/IntentHelper.java @@ -61,7 +61,7 @@ public abstract class IntentHelper { send.putExtra(Intent.EXTRA_SUBJECT, subject); send.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body)); try { - Intent chooser = Intent.createChooser(send, chooserTitle)); + Intent chooser = Intent.createChooser(send, chooserTitle); // we start this activity outside the main activity. chooser.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(chooser); diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index eae32d9..e9a108c 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -1073,5 +1073,24 @@ }, ]}, # 'targets' ], # OS=="win" + ['OS=="android"', + { + 'targets': [ + { + 'target_name': 'chrome_java', + 'type': 'none', + 'dependencies': [ + '../base/base.gyp:base_java', + '../content/content.gyp:content_java', + '../net/net.gyp:net_java', + ], + 'variables': { + 'package_name': 'chrome', + 'java_in_dir': '../chrome/android/java', + }, + 'includes': [ '../build/java.gypi' ], + }, + ]}, # 'targets' + ], # OS=="android" ], # 'conditions' } diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 132ad87..f0bce86 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -4591,6 +4591,7 @@ 'dependencies': [ '../base/base.gyp:base_java', '../net/net.gyp:net_java', + 'chrome_java', 'unit_tests', ], 'variables': { diff --git a/content/content_shell.gypi b/content/content_shell.gypi index 9923bf9..272279b 100644 --- a/content/content_shell.gypi +++ b/content/content_shell.gypi @@ -647,6 +647,11 @@ 'ant', '-DPRODUCT_DIR=<(ant_build_out)', '-DAPP_ABI=<(android_app_abi)', + '-DANDROID_SDK=<(android_sdk)', + '-DANDROID_SDK_ROOT=<(android_sdk_root)', + '-DANDROID_SDK_TOOLS=<(android_sdk_tools)', + '-DANDROID_SDK_VERSION=<(android_sdk_version)', + '-DANDROID_TOOLCHAIN=<(android_toolchain)', '-buildfile', 'shell/android/java/content_shell_apk.xml', # '<(CONFIGURATION_NAME)', diff --git a/content/content_tests.gypi b/content/content_tests.gypi index 50bb7db..8b4ac17 100644 --- a/content/content_tests.gypi +++ b/content/content_tests.gypi @@ -824,6 +824,11 @@ 'ant', '-DPRODUCT_DIR=<(ant_build_out)', '-DAPP_ABI=<(android_app_abi)', + '-DANDROID_SDK=<(android_sdk)', + '-DANDROID_SDK_ROOT=<(android_sdk_root)', + '-DANDROID_SDK_TOOLS=<(android_sdk_tools)', + '-DANDROID_SDK_VERSION=<(android_sdk_version)', + '-DANDROID_TOOLCHAIN=<(android_toolchain)', '-buildfile', '<(DEPTH)/content/shell/android/javatests/content_shell_test_apk.xml', ] diff --git a/content/public/android/java/content.xml b/content/public/android/java/content.xml index 7e4cd98..1a6bd52 100644 --- a/content/public/android/java/content.xml +++ b/content/public/android/java/content.xml @@ -1,54 +1,19 @@ -<!-- 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. +<!-- + 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 name="Content" default="dist" basedir="."> <description> building content java source code with ant </description> - <!-- set global properties for this build --> - <property name="src" location="src"/> - <property name="out.dir" location="${PRODUCT_DIR}/lib.java"/> - <property name="classes.dir" location="${PRODUCT_DIR}/java/${PACKAGE_NAME}"/> - <property name="jar.dir" location="${out.dir}"/> - - <target name="init"> - <!-- Create the time stamp --> - <tstamp/> - <!-- Create the build directory structure used by compile --> - <mkdir dir="${out.dir}"/> - </target> - - <target name="compile" depends="init" - description="compile the source " > - <!-- Create the classes output directory --> - <mkdir dir="${classes.dir}"/> - - <!-- Compile the java code from ${src} into ${classes.dir} --> - <!-- Gyp target should have compiled aidl files into java source files in - lib.jar (see content.gyp:common_aidl). --> - <javac srcdir="${src}:${out.dir}" destdir="${classes.dir}" debug="true" includeantruntime="false"> - <classpath> - <pathelement path="${ANDROID_SDK}/android.jar" /> - <pathelement path="${jar.dir}/chromium_base.jar" /> - <pathelement path="${jar.dir}/chromium_net.jar" /> - </classpath> - </javac> - </target> - - <target name="dist" depends="compile" - description="generate the distribution" > - <!-- Create the distribution directory --> - <mkdir dir="${jar.dir}"/> - - <!-- Put everything in ${classes.dir} into the chromium_content.jar file --> - <jar jarfile="${jar.dir}/chromium_${PACKAGE_NAME}.jar" basedir="${classes.dir}"/> - </target> + <import file="../../../../build/android/ant/chromium-jars.xml" /> - <target name="clean" description="clean up" > - <!-- Delete the generated content --> - <delete dir="${classes.dir}"/> - <delete file="${jar.dir}/chromium_${PACKAGE_NAME}.jar"/> - </target> + <path id="javac.custom.classpath"> + <pathelement location="${ANDROID_SDK}/android.jar" /> + <pathelement location="${lib.dir}/chromium_base.jar" /> + <pathelement location="${lib.dir}/chromium_net.jar" /> + </path> + <!-- Override javac path to include jars in lib.java directory --> + <property-value name="javac.srcdir" value="${src}:${lib.dir}" /> </project> diff --git a/content/shell/android/java/content_shell_apk.xml b/content/shell/android/java/content_shell_apk.xml index 2b47611..9b2a674 100644 --- a/content/shell/android/java/content_shell_apk.xml +++ b/content/shell/android/java/content_shell_apk.xml @@ -5,25 +5,22 @@ found in the LICENSE file. --> <project name="ContentShell" default="debug" basedir="."> - <description> Building ContentShell.apk </description> - - <property environment="env"/> - <property name="sdk.dir" location="${env.ANDROID_SDK_ROOT}"/> - <property name="toolchain.dir" location="${env.ANDROID_TOOLCHAIN}"/> - <property name="source.dir" location="src"/> - <property name="target" value="android-${env.ANDROID_SDK_VERSION}"/> - <property name="target.abi" value="${APP_ABI}"/> - <property name="out.dir" location="${PRODUCT_DIR}/content_shell"/> + <import file="../../../../build/android/ant/common.xml"/> + <import file="../../../../build/android/ant/sdk-targets.xml"/> + <property-value name="target.abi" value="${APP_ABI}"/> + <property-location name="out.dir" location="${PRODUCT_DIR}/content_shell" + check-exists="false"/> <property name="resource.absolute.dir" value="../res"/> <property name="gen.absolute.dir" value="${out.dir}/gen"/> + <property name="jar.libs.dir" value="${out.dir}/java/libs"/> <path id="native.libs.gdbserver"> <fileset file="${toolchain.dir}/../../gdbserver"/> </path> - <property name="native.libs.absolute.dir" location="${out.dir}/libs" /> - <property name="asset.absolute.dir" location="${out.dir}/assets" /> + <property name="native.libs.absolute.dir" location="${out.dir}/libs"/> + <property name="asset.absolute.dir" location="${out.dir}/assets"/> <path id="out.dex.jar.input.ref"> <fileset file="${out.dir}/java/libs/chromium_content.jar"/> @@ -33,8 +30,7 @@ </path> <property name="java.compilerargs" value="-classpath ${toString:out.dex.jar.input.ref}"/> - <!-- We expect PRODUCT_DIR to be set like the gyp var - (e.g. $ROOT/out/Debug) --> + <!-- We expect PRODUCT_DIR to be set like the gyp var (e.g. $ROOT/out/Debug) --> <fail message="PRODUCT_DIR env var not set?"> <condition> <not> @@ -44,17 +40,19 @@ </fail> <target name="-post-compile"> - <!-- copy gdbserver to main libs directory if building debug. + <!-- + Copy gdbserver to main libs directory if building debug. 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. --> + Release Official build java/ant as Release. + --> <if> <condition> - <equals arg1="${build.target}" arg2="debug" /> + <equals arg1="${build.target}" arg2="debug"/> </condition> <then> - <echo message="Copying gdbserver to the apk to enable native debugging"/> + <echo message="Copying gdbserver to the apk to enable native debugging" /> <copy todir="${out.dir}/libs/${target.abi}"> <path refid="native.libs.gdbserver"/> </copy> @@ -62,6 +60,9 @@ </if> </target> - <import file="${sdk.dir}/tools/ant/build.xml" /> - + <!-- Classpath for javac --> + <path id="javac.custom.classpath"> + <path refid="out.dex.jar.input.ref"/> + </path> + <import file="${sdk.dir}/tools/ant/build.xml"/> </project> diff --git a/content/shell/android/javatests/content_shell_test_apk.xml b/content/shell/android/javatests/content_shell_test_apk.xml index ba8ba490..f4ba3f2 100644 --- a/content/shell/android/javatests/content_shell_test_apk.xml +++ b/content/shell/android/javatests/content_shell_test_apk.xml @@ -10,11 +10,8 @@ Building ContentShellTest.apk </description> - <property environment="env"/> - <property name="sdk.dir" location="${env.ANDROID_SDK_ROOT}"/> - <property name="toolchain.dir" location="${env.ANDROID_TOOLCHAIN}"/> - <property name="source.dir" location="src"/> - <property name="target" value="android-${env.ANDROID_SDK_VERSION}"/> + <import file="../../../../build/android/ant/common.xml"/> + <import file="../../../../build/android/ant/sdk-targets.xml"/> <property name="target.abi" value="${APP_ABI}"/> <property name="out.dir" location="${PRODUCT_DIR}/content_shell_test"/> <property name="resource.absolute.dir" value="../res"/> @@ -71,6 +68,10 @@ </target> + <!-- Classpath for javac --> + <path id="javac.custom.classpath"> + <path refid="out.dex.jar.input.ref"/> + </path> <import file="${sdk.dir}/tools/ant/build.xml" /> </project> diff --git a/media/base/android/java/media.xml b/media/base/android/java/media.xml index 2dbec23..0504807 100644 --- a/media/base/android/java/media.xml +++ b/media/base/android/java/media.xml @@ -1,51 +1,17 @@ -<!-- 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. +<!-- + 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 name="Media" default="dist" basedir="."> <description> building media java source code with ant </description> - <!-- set global properties for this build --> - <property name="src" location="src"/> - <property name="build" location="build"/> - <property name="dist" location="dist"/> - <property name="out.dir" location="${PRODUCT_DIR}/lib.java"/> - <property name="dest.dir" location="${PRODUCT_DIR}/java/media"/> - - <target name="init"> - <!-- Create the time stamp --> - <tstamp/> - <!-- Create the build directory structure used by compile --> - <mkdir dir="${out.dir}"/> - <mkdir dir="${dest.dir}"/> - </target> - - <target name="compile" depends="init" - description="compile the source " > - <!-- Compile the java code from ${src} into ${dest.dir} --> - <javac srcdir="${src}" destdir="${dest.dir}" debug="true" includeantruntime="false"> - <classpath> - <pathelement path="${ANDROID_SDK}/android.jar" /> - <pathelement path="${out.dir}/chromium_base.jar" /> - </classpath> - </javac> - </target> - - <target name="dist" depends="compile" - description="generate the distribution" > - <!-- Create the distribution directory --> - <mkdir dir="${out.dir}"/> - <!-- Put everything in ${build} into the chromium_media.jar file --> - <jar jarfile="${out.dir}/chromium_media.jar" basedir="${dest.dir}"/> - </target> + <import file="../../../../build/android/ant/chromium-jars.xml"/> - <target name="clean" - description="clean up" > - <!-- Delete the appropriate directory trees --> - <delete dir="${dest.dir}"/> - <delete dir="${dist}"/> - </target> + <path id="javac.custom.classpath"> + <pathelement location="${ANDROID_SDK}/android.jar"/> + <pathelement location="${lib.dir}/chromium_base.jar"/> + </path> </project> diff --git a/net/android/java/net.xml b/net/android/java/net.xml index 22d3871..521f245 100644 --- a/net/android/java/net.xml +++ b/net/android/java/net.xml @@ -1,45 +1,16 @@ +<!-- + 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 name="net" default="dist" basedir="."> <description> Building net/ java source code with ant. </description> - <!-- Set global properties for this build --> - <property name="src" location="src"/> - <property name="dist" location="dist"/> - <property name="out.dir" location="${PRODUCT_DIR}/lib.java"/> - <!-- TODO(jrg): establish a standard for the intermediate java - directories. Settle on a standard once ant/jar build files - like this are androidified --> - <property name="dest.dir" location="${PRODUCT_DIR}/java/net"/> + <import file="../../../build/android/ant/chromium-jars.xml"/> - <target name="init"> - <!-- Create the time stamp --> - <tstamp/> - <!-- Create the build directory structure used by compile --> - <mkdir dir="${out.dir}"/> - <mkdir dir="${dest.dir}"/> - </target> - - <target name="compile" depends="init" - description="compile the source " > - <javac srcdir="${src}" destdir="${dest.dir}" debug="true" includeantruntime="false"> - <classpath> - <path location="${ANDROID_SDK}/android.jar"/> - <path location="${out.dir}/chromium_base.jar"/> - </classpath> - </javac> - </target> - - <target name="dist" depends="compile" - description="generate the distribution" > - <!-- Create the distribution directory --> - <mkdir dir="${dist}/lib"/> - - <jar jarfile="${out.dir}/chromium_net.jar" basedir="${dest.dir}"/> - </target> - - <target name="clean" - description="clean up" > - <delete dir="${dest.dir}"/> - <delete dir="${dist}"/> - </target> + <path id="javac.custom.classpath"> + <pathelement location="${ANDROID_SDK}/android.jar"/> + <pathelement location="${lib.dir}/chromium_base.jar"/> + </path> </project> diff --git a/testing/android/generate_native_test.py b/testing/android/generate_native_test.py index f5c3356..c5fc1ed 100755 --- a/testing/android/generate_native_test.py +++ b/testing/android/generate_native_test.py @@ -145,7 +145,7 @@ class NativeTestApkGenerator(object): """ cmd = ['ant'] if ant_args: - cmd.append(ant_args) + cmd.extend(ant_args) cmd.append("-DAPP_ABI=" + self._target_abi) cmd.extend(['-buildfile', os.path.join(self._output_directory, 'native_test_apk.xml')]) @@ -189,7 +189,7 @@ def main(argv): help=('If specified, build the generated apk with ant. ' 'Otherwise assume compiling within the Android ' 'source tree using Android.mk.')) - parser.add_option('--ant-args', + parser.add_option('--ant-args', action='append', help='extra args for ant') options, _ = parser.parse_args(argv) diff --git a/testing/android/native_test.gyp b/testing/android/native_test.gyp index fb21f27..38d2f39 100644 --- a/testing/android/native_test.gyp +++ b/testing/android/native_test.gyp @@ -39,6 +39,11 @@ 'action': [ 'ant', '-DPRODUCT_DIR=<(ant_build_out)', + '-DANDROID_SDK=<(android_sdk)', + '-DANDROID_SDK_ROOT=<(android_sdk_root)', + '-DANDROID_SDK_TOOLS=<(android_sdk_tools)', + '-DANDROID_SDK_VERSION=<(android_sdk_version)', + '-DANDROID_TOOLCHAIN=<(android_toolchain)', '-buildfile', '<(DEPTH)/testing/android/native_test_apk.xml', ] diff --git a/testing/android/native_test_apk.xml b/testing/android/native_test_apk.xml index 444cf93..64d0e88 100644 --- a/testing/android/native_test_apk.xml +++ b/testing/android/native_test_apk.xml @@ -11,25 +11,25 @@ found in the LICENSE file. Building native test runner ChromeNativeTests_replaceme.apk </description> - <property environment="env"/> - <property name="sdk.dir" location="${env.ANDROID_SDK_ROOT}"/> - <property name="sdk.version" value="${env.ANDROID_SDK_VERSION}"/> - <property name="toolchain.dir" location="${env.ANDROID_TOOLCHAIN}"/> - <property name="src" location="."/> - <property name="source.dir" location="java/src"/> + <!-- + TODO(yfriedman): This target can be invoked from multiple depths. So we use ${PRODUCT_DIR} to normalize the paths. This could be cleaned up. + --> + <import file="${PRODUCT_DIR}/../../build/android/ant/common.xml"/> + <import file="${PRODUCT_DIR}/../../build/android/ant/sdk-targets.xml"/> + <!-- + TODO(yfriedman): Remove the need to specify this. We should generate the packages in a way such + that it's not required. + --> + <property name="source.absolute.dir" value="java/src"/> + <path id="javac.custom.classpath"> + <pathelement location="${ANDROID_SDK}/android.jar" /> + </path> <property name="target.abi" value="${APP_ABI}"/> - <property name="target" value="android-${env.ANDROID_SDK_VERSION}"/> <path id="native.libs.gdbserver"> <fileset file="${toolchain.dir}/../../gdbserver"/> </path> - <condition property="location.base" - value="${sdk.dir}" - else="${sdk.dir}/platforms/android-${sdk.version}"> - <isset property="env.ANDROID_BUILD_TOP"/> - </condition> - <!-- We expect PRODUCT_DIR to be set like the gyp var (e.g. $ROOT/out/Debug) --> <fail message="PRODUCT_DIR env var not set?"> |