diff options
Diffstat (limited to 'media/webrtc/trunk/build/android/ant')
-rw-r--r-- | media/webrtc/trunk/build/android/ant/chromium-jars.xml | 97 | ||||
-rw-r--r-- | media/webrtc/trunk/build/android/ant/common.xml | 90 | ||||
-rw-r--r-- | media/webrtc/trunk/build/android/ant/sdk-targets.xml | 284 |
3 files changed, 471 insertions, 0 deletions
diff --git a/media/webrtc/trunk/build/android/ant/chromium-jars.xml b/media/webrtc/trunk/build/android/ant/chromium-jars.xml new file mode 100644 index 000000000..7007df5dc --- /dev/null +++ b/media/webrtc/trunk/build/android/ant/chromium-jars.xml @@ -0,0 +1,97 @@ +<!-- + 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.gypi action. + The jar will be created as chromium_${PACKAGE_NAME} in + ${PRODUCT_DIR}/lib.java. + --> + <description> + Building ${PROJECT_NAME}/ java source code with ant. + </description> + + <import file="common.xml"/> + + <path id="javac.custom.classpath"> + <filelist files="${INPUT_JARS_PATHS}"/> + <pathelement location="${ANDROID_SDK}/android.jar"/> + </path> + + <path id="javac.srcdirs.additional"> + <filelist files="${ADDITIONAL_SRC_DIRS}"/> + <filelist files="${GENERATED_SRC_DIRS}"/> + </path> + + <property-value + name="javac.srcdir" + value="src:${toString:javac.srcdirs.additional}" + /> + + <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="${dest.dir}"/> + + <!-- Remove all .class files from dest.dir. This prevents inclusion of + incorrect .class files in the final .jar. For example, if a .java file + was deleted, the .jar should not contain the .class files for that + .java from previous builds. + --> + <delete> + <fileset dir="${dest.dir}" includes="**/*.class"/> + </delete> + </target> + + <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> + + <echo> + Compiling ${javac.srcdir}, classpath: ${toString:javac.custom.classpath} + </echo> + + <javac + srcdir="${javac.srcdir}" + destdir="${dest.dir}" + classpathref="javac.custom.classpath" + debug="true" + includeantruntime="false" + /> + </target> + + <target name="dist" depends="compile" + description="Generate chromium_${PACKAGE_NAME}.jar."> + <!-- Create the distribution directory --> + <jar + jarfile="${lib.java.dir}/chromium_${PACKAGE_NAME}.jar" + basedir="${dest.dir}" + /> + + <!-- If Gyp thinks this output is stale but Ant doesn't, the modification + time should still be updated. Otherwise, this target will continue to + be rebuilt in future builds. + --> + <touch file="${lib.java.dir}/chromium_${PACKAGE_NAME}.jar"/> + </target> + + <target name="clean" description="clean up"> + <!-- Delete the appropriate directory trees --> + <delete dir="${dest.dir}"/> + </target> +</project> diff --git a/media/webrtc/trunk/build/android/ant/common.xml b/media/webrtc/trunk/build/android/ant/common.xml new file mode 100644 index 000000000..1001f19eb --- /dev/null +++ b/media/webrtc/trunk/build/android/ant/common.xml @@ -0,0 +1,90 @@ +<?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 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="android.gdbserver" location="${ANDROID_GDBSERVER}"/> + <!-- + Common directories used by SDK Build, when making changes here + make sure to update gyp files and test scripts constants in + build/android/pylib/constants.py + --> + <!-- Common directory for chromium_*.jars. --> + <property-location name="lib.java.dir" location="${PRODUCT_DIR}/lib.java"/> + <!-- Common directory for test jars. --> + <property-location name="test.lib.java.dir" + location="${PRODUCT_DIR}/test.lib.java"/> + <!-- Common directory for apks. --> + <property-location name="apks.dir" location="${PRODUCT_DIR}/apks"/> +</project> diff --git a/media/webrtc/trunk/build/android/ant/sdk-targets.xml b/media/webrtc/trunk/build/android/ant/sdk-targets.xml new file mode 100644 index 000000000..b692f6ec6 --- /dev/null +++ b/media/webrtc/trunk/build/android/ant/sdk-targets.xml @@ -0,0 +1,284 @@ +<?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. + --> + <target name="-pre-compile"> + <!-- + Remove all .class files from the output directory. This prevents inclusion of incorrect .class + files in the final apk. For example, if a .java file was deleted, the apk should not contain + the .class files for that .java from previous builds. + --> + <delete> + <fileset dir="${out.classes.absolute.dir}" includes="**/*.class"/> + </delete> + </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'. + --> + <target + name="-compile" + depends="-build-setup, -pre-build, -code-gen, -pre-compile"> + <do-only-if-manifest-hasCode elseText="hasCode = false. Skipping..." > + <!-- If javac.srcdirs.additional isn't set, set it to an empty path. --> + <if> + <condition> + <not> + <isreference refid="javac.srcdirs.additional"/> + </not> + </condition> + <then> + <path id="javac.srcdirs.additional"/> + </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.srcdirs.additional"/> + </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> + <!-- + 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> + <echo level="info">Creating test jar file: + ${ant.project.name}-debug.jar</echo> + <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> + + </do-only-if-manifest-hasCode> + </target> + + <!-- + 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. + --> + + <!-- Disables automatic signing. --> + <property name="build.is.signing.debug" value="false"/> + + <!-- TODO(cjhopman): Remove this property when all gyp files define the CHROMIUM_SRC property. --> + <property name="CHROMIUM_SRC" value="${PRODUCT_DIR}/../.." /> + + <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"/> + + <!-- SDK tools assume that out.packaged.file is signed and name it "...-unaligned" --> + <property name="out.packaged.file" + value="${apks.dir}/${ant.project.name}-debug-unsigned.apk" /> + <property name="out.unaligned.file" + value="${apks.dir}/${ant.project.name}-debug-unaligned.apk" /> + + <!-- By default, the SDK tools build only aligns the APK in the -do-debug target. --> + <target name="-do-debug" + depends="-set-debug-mode, -debug-obfuscation-check, -package, -post-package"> + <!-- only create apk if *not* a library project --> + <do-only-if-not-library elseText="Library project: do not create apk..." > + <sequential> + <!-- Signs the APK --> + <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}"/> + + <!-- Zip aligns the APK --> + <zipalign-helper + in.package="${out.unaligned.file}" + out.package="${out.final.file}" /> + <echo level="info">Release Package: ${out.final.file}</echo> + </sequential> + </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_apk_${PACKAGE_NAME}.jar" + basedir="${out.classes.absolute.dir}" + /> + </target> + + <!-- + 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"> + <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}"/> + <path refid="project.all.jars.path"/> + <!-- 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> +</project> |