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 /build | |
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
Diffstat (limited to 'build')
-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 |
5 files changed, 255 insertions, 1 deletions
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', ] |