diff options
-rw-r--r-- | build/all_android.gyp | 30 | ||||
-rwxr-xr-x | build/android/adb_install_content_shell | 3 | ||||
-rw-r--r-- | build/android/ant/chromium-jars.xml | 19 | ||||
-rw-r--r-- | build/android/ant/common.xml | 12 | ||||
-rw-r--r-- | build/android/ant/create-test-jar.js | 70 | ||||
-rw-r--r-- | build/android/ant/sdk-targets.xml | 19 | ||||
-rwxr-xr-x | build/android/buildbot/buildbot_functions.sh | 2 | ||||
-rw-r--r-- | build/android/pylib/constants.py | 4 | ||||
-rw-r--r-- | build/android/pylib/test_options_parser.py | 15 | ||||
-rw-r--r-- | build/java.gypi | 3 | ||||
-rw-r--r-- | build/java_apk.gypi | 3 | ||||
-rw-r--r-- | content/shell/android/java/content_shell_apk.xml | 24 | ||||
-rw-r--r-- | content/shell/android/javatests/content_shell_test_apk.xml | 73 |
13 files changed, 182 insertions, 95 deletions
diff --git a/build/all_android.gyp b/build/all_android.gyp index c4ade07..3d215ab 100644 --- a/build/all_android.gyp +++ b/build/all_android.gyp @@ -115,5 +115,35 @@ '../content/content.gyp:content_browsertests', ], }, + { + # Target for creating common output build directories. Creating output + # dirs beforehand ensures that build scripts can assume these folders to + # exist and there are no race conditions resulting from build scripts + # trying to create these directories. + # The build/java.gypi target depends on this target. + 'target_name': 'build_output_dirs', + 'type': 'none', + 'actions': [ + { + 'action_name': 'create_java_output_dirs', + 'variables' : { + 'output_dirs' : [ + '<(PRODUCT_DIR)/apks', + '<(PRODUCT_DIR)/lib.java', + '<(PRODUCT_DIR)/test.lib.java', + ] + }, + 'inputs' : [], + 'outputs': [ + '<@(output_dirs)' + ], + 'action': [ + 'mkdir', + '-p', + '<@(output_dirs)', + ], + }, + ], + }, # build_output_dirs ], # targets } diff --git a/build/android/adb_install_content_shell b/build/android/adb_install_content_shell index fd883cc..1af1df4 100755 --- a/build/android/adb_install_content_shell +++ b/build/android/adb_install_content_shell @@ -11,12 +11,13 @@ import sys from pylib import android_commands from pylib import test_options_parser +from pylib import constants def InstallContentShell(device, build_type): apk_path = os.path.join(os.environ['CHROME_SRC'], 'out', build_type, - 'content_shell', 'ContentShell-debug.apk') + constants.SDK_BUILD_APKS_DIR, 'ContentShell-debug.apk') result = android_commands.AndroidCommands(device=device).ManagedInstall( apk_path, False, 'org.chromium.content_shell') print '----- Installed on %s -----' % device diff --git a/build/android/ant/chromium-jars.xml b/build/android/ant/chromium-jars.xml index 9521473..aac4064 100644 --- a/build/android/ant/chromium-jars.xml +++ b/build/android/ant/chromium-jars.xml @@ -19,11 +19,11 @@ <path id="javac.custom.classpath"> <filelist files="${INPUT_JARS_PATHS}"/> - <pathelement location="${ANDROID_SDK}/android.jar" /> + <pathelement location="${ANDROID_SDK}/android.jar"/> </path> <path id="javac.srcdirs.additional"> - <filelist files="${ADDITIONAL_SRC_DIRS}" /> + <filelist files="${ADDITIONAL_SRC_DIRS}"/> </path> <property-value @@ -32,12 +32,6 @@ /> <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" @@ -47,7 +41,6 @@ <!-- Create the time stamp --> <tstamp/> <!-- Create the build directory structure used by compile --> - <mkdir dir="${lib.dir}"/> <mkdir dir="${dest.dir}"/> <!-- Remove all .class files from dest.dir. This prevents inclusion of @@ -60,7 +53,7 @@ </delete> </target> - <target name="compile" depends="init" description="Compiles source." > + <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> @@ -85,7 +78,7 @@ description="Generate chromium_${PACKAGE_NAME}.jar."> <!-- Create the distribution directory --> <jar - jarfile="${lib.dir}/chromium_${PACKAGE_NAME}.jar" + jarfile="${lib.java.dir}/chromium_${PACKAGE_NAME}.jar" basedir="${dest.dir}" /> @@ -93,11 +86,11 @@ time should still be updated. Otherwise, this target will continue to be rebuilt in future builds. --> - <touch file="${lib.dir}/chromium_${PACKAGE_NAME}.jar"/> + <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}" /> + <delete dir="${dest.dir}"/> </target> </project> diff --git a/build/android/ant/common.xml b/build/android/ant/common.xml index ff88fd0..1001f19 100644 --- a/build/android/ant/common.xml +++ b/build/android/ant/common.xml @@ -75,4 +75,16 @@ <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/build/android/ant/create-test-jar.js b/build/android/ant/create-test-jar.js new file mode 100644 index 0000000..542a89e --- /dev/null +++ b/build/android/ant/create-test-jar.js @@ -0,0 +1,70 @@ +// 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. + +/** + * Combines classes from javac.custom.classpath property and ${out.dir}/classes + * into a single jar file ${ant.project.name}-debug.jar and places the file in + * ${lib.java.dir}. + */ + +importClass(java.io.File); +importClass(org.apache.tools.ant.types.Reference); +importClass(org.apache.tools.ant.types.FileSet); +importClass(org.apache.tools.ant.types.ZipFileSet); +importClass(org.apache.tools.ant.taskdefs.Zip); + +var echo = project.createTask("echo"); +var jarTask = project.createTask("jar"); + +// Do not allow duplicates in the jar, the default behavior of Jar task +// is "add" which means duplicates are allowed. +// This can cause a class file to be included multiple times, setting the +// duplicate to "preserve" ensures that only the first definition is included. + +var duplicate = Zip.Duplicate(); +duplicate.setValue("preserve"); +jarTask.setDuplicate(duplicate); + +var destFile = project.getProperty("ant.project.name") + "-debug.jar"; +var destPath = File(project.getProperty("test.lib.java.dir") + "/" + destFile); +jarTask.setDestFile(destPath); + +// Include all the jars in the classpath. +var javacCustomClasspath = + project.getReference("javac.custom.classpath").list(); + +for (var i in javacCustomClasspath) { + var fileName = javacCustomClasspath[i] + var fileExtension = fileName.split("\\.").pop(); + if(fileExtension == "jar") + { + var zipFileSet = ZipFileSet(); + zipFileSet.setIncludes("**/*.class"); + zipFileSet.setSrc(File(fileName)); + jarTask.addFileset(zipFileSet); + } +} + +// Add the compiled classes in ${out.dir}/classes. +var projectClasses = FileSet(); +projectClasses.setIncludes("**/*.class"); +projectClasses.setDir(File(project.getProperty("out.dir") + "/classes")); +jarTask.addFileset(projectClasses); + +// Exclude manifest and resource classes. +var appPackagePath = + (project.getProperty("project.app.package")).replace('.','/'); +var excludedClasses = ["R.class", "R$*.class", "Manifest.class", + "Manifest$*.class", "BuildConfig.class"] + +var exclusionString = ""; +for (var i in excludedClasses) { + exclusionString += appPackagePath+ "/" + excludedClasses[i] + " "; +} + +jarTask.setExcludes(exclusionString); +echo.setMessage("Creating test jar: " + + jarTask.getDestFile().getAbsolutePath()); +echo.perform(); +jarTask.perform(); diff --git a/build/android/ant/sdk-targets.xml b/build/android/ant/sdk-targets.xml index 59913e3..6707b08 100644 --- a/build/android/ant/sdk-targets.xml +++ b/build/android/ant/sdk-targets.xml @@ -13,7 +13,6 @@ 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 @@ -92,6 +91,20 @@ </emma> </then> </if> + <!-- + If the project needs a test jar then generate a jar containing + all compiled classes and referenced jars. + --> + <if condition="${generate.test.jar}"> + <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> @@ -115,9 +128,9 @@ <!-- SDK tools assume that out.packaged.file is signed and name it "...-unaligned" --> <property name="out.packaged.file" - value="${out.dir}/${ant.project.name}-debug-unsigned.apk" /> + value="${apks.dir}/${ant.project.name}-debug-unsigned.apk" /> <property name="out.unaligned.file" - value="${out.dir}/${ant.project.name}-debug-unaligned.apk" /> + 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" diff --git a/build/android/buildbot/buildbot_functions.sh b/build/android/buildbot/buildbot_functions.sh index 4136e69..482ec90 100755 --- a/build/android/buildbot/buildbot_functions.sh +++ b/build/android/buildbot/buildbot_functions.sh @@ -229,7 +229,7 @@ function bb_run_instrumentation_test { # Run content shell instrumentation test on device. function bb_run_instrumentation_tests { build/android/adb_install_content_shell - local TEST_APK="content_shell_test/ContentShellTest-debug" + local TEST_APK="ContentShellTest" # Use -I to install the test apk only on the first run. # TODO(bulach): remove the second once we have a Smoke test. bb_run_instrumentation_test ${TEST_APK} "-I -A Smoke" diff --git a/build/android/pylib/constants.py b/build/android/pylib/constants.py index 0121fd6..876b592 100644 --- a/build/android/pylib/constants.py +++ b/build/android/pylib/constants.py @@ -37,3 +37,7 @@ TEST_SERVER_PORT_FILE = '/tmp/test_server_port' TEST_SERVER_PORT_LOCKFILE = '/tmp/test_server_port.lock' TEST_EXECUTABLE_DIR = '/data/local/tmp' +# Directories for common java libraries for SDK build. +# These constants are defined in build/android/ant/common.xml +SDK_BUILD_TEST_JAVALIB_DIR = 'test.lib.java' +SDK_BUILD_APKS_DIR = 'apks' diff --git a/build/android/pylib/test_options_parser.py b/build/android/pylib/test_options_parser.py index 8492ec3..4edd5f9 100644 --- a/build/android/pylib/test_options_parser.py +++ b/build/android/pylib/test_options_parser.py @@ -85,10 +85,9 @@ def AddInstrumentationOptions(option_parser): 'of the result. (Default is 1)')) option_parser.add_option('--test-apk', dest='test_apk', help=('The name of the apk containing the tests ' - '(without the .apk extension) or for SDK ' - 'builds, the path to the APK from ' - 'out/(Debug|Release) (for example, ' - 'content_shell_test/ContentShellTest-debug).')) + '(without the .apk extension). For SDK ' + 'builds, the apk name without the debug ' + 'suffix(for example, ContentShellTest).')) option_parser.add_option('--screenshot', dest='screenshot_failures', action='store_true', help='Capture screenshots of test failures') @@ -119,13 +118,15 @@ def ValidateInstrumentationOptions(option_parser, options, args): elif options.python_only: options.run_java_tests = False + # In case of SDK Build, the jars and apks have a -debug suffix. options.test_apk_path = os.path.join(_SDK_OUT_DIR, options.build_type, - '%s.apk' % options.test_apk) + constants.SDK_BUILD_APKS_DIR, + '%s-debug.apk' % options.test_apk) options.test_apk_jar_path = os.path.join(_SDK_OUT_DIR, options.build_type, - '%s.jar' - % options.test_apk) + constants.SDK_BUILD_TEST_JAVALIB_DIR, + '%s-debug.jar' % options.test_apk) if options.annotation_str: options.annotation = options.annotation_str.split() elif options.test_filter: diff --git a/build/java.gypi b/build/java.gypi index 046cc79..a955917 100644 --- a/build/java.gypi +++ b/build/java.gypi @@ -28,6 +28,9 @@ # <(PRODUCT_DIR)/lib.java/chromium_base.jar { + 'dependencies': [ + '<(DEPTH)/build/all_android.gyp:build_output_dirs' + ], 'direct_dependent_settings': { 'variables': { 'input_jars_paths': ['<(PRODUCT_DIR)/lib.java/chromium_<(package_name).jar'], diff --git a/build/java_apk.gypi b/build/java_apk.gypi index f0d6f2f..a368bfc 100644 --- a/build/java_apk.gypi +++ b/build/java_apk.gypi @@ -50,7 +50,7 @@ '>@(additional_input_paths)', ], 'outputs': [ - '<(PRODUCT_DIR)/<(package_name)/<(apk_name)-debug.apk', + '<(PRODUCT_DIR)/apks/<(apk_name)-debug.apk', ], 'action': [ 'ant', @@ -66,6 +66,7 @@ '-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)', '-DINPUT_JARS_PATHS=>(input_jars_paths)', '-DADDITIONAL_SRC_DIRS=>(additional_src_dirs)', + '-DCHROMIUM_SRC=<(ant_build_out)/../..', '-DRESOURCE_DIR=<(resource_dir)', '-buildfile', '<(java_in_dir)/<(package_name)_apk.xml' diff --git a/content/shell/android/java/content_shell_apk.xml b/content/shell/android/java/content_shell_apk.xml index a1caf1a..9bcfa05 100644 --- a/content/shell/android/java/content_shell_apk.xml +++ b/content/shell/android/java/content_shell_apk.xml @@ -10,7 +10,10 @@ </description> <import file="../../../../build/android/ant/common.xml"/> - <!-- Convert the buildtype to lowercase. E.g Debug -> debug, Release -> release. --> + <!-- + Convert the buildtype to lowercase. E.g Debug -> debug, + Release -> release. + --> <script language="javascript"> project.setProperty("configuration.name", project.getProperty("CONFIGURATION_NAME").toLowerCase()) @@ -20,29 +23,20 @@ check-exists="false"/> <property name="resource.absolute.dir" value="${RESOURCE_DIR}"/> <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="${android.gdbserver}"/> </path> <property name="native.libs.absolute.dir" location="${out.dir}/libs"/> <property name="asset.absolute.dir" location="${out.dir}/assets"/> + <!-- 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> - <property name="java.compilerargs" value="-classpath ${toString:out.dex.jar.input.ref}"/> - <echo>resources: ${RESOURCE_DIR} classpath: ${toString:out.dex.jar.input.ref}</echo> - - <!-- 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> - <isset property="PRODUCT_DIR"/> - </not> - </condition> - </fail> - <target name="-post-compile"> <!-- Copy gdbserver to main libs directory if building debug. @@ -56,7 +50,7 @@ <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> diff --git a/content/shell/android/javatests/content_shell_test_apk.xml b/content/shell/android/javatests/content_shell_test_apk.xml index b2f8757..8f8ee1d 100644 --- a/content/shell/android/javatests/content_shell_test_apk.xml +++ b/content/shell/android/javatests/content_shell_test_apk.xml @@ -12,69 +12,34 @@ <import file="../../../../build/android/ant/common.xml"/> - <property name="target.abi" value="${APP_ABI}"/> - <property name="out.dir" location="${PRODUCT_DIR}/content_shell_test"/> + <property-value name="target.abi" value="${APP_ABI}"/> + <property-location name="out.dir" location="${PRODUCT_DIR}/content_shell_test" + check-exists="false"/> <property name="resource.absolute.dir" value="${RESOURCE_DIR}"/> - <property name="gen.absolute.dir" value="${out.dir}/gen"/> - <path id="native.libs.gdbserver"> - <fileset file="${android.gdbserver}"/> - </path> - <property name="native.libs.absolute.dir" location="${out.dir}/libs" /> - <property name="asset.absolute.dir" location="${out.dir}/assets" /> + <property-value name="gen.absolute.dir" value="${out.dir}/gen"/> + <property-location name="native.libs.absolute.dir" location="${out.dir}/libs" + check-exists="false"/> + <property-location name="asset.absolute.dir" location="${out.dir}/assets" + check-exists="false"/> + <!-- 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"/> + <property name="generate.test.jar" value="true"/> + + <property-location name="contentshell.classes.dir" + location="${PRODUCT_DIR}/content_shell/classes"/> <path id="out.dex.jar.input.ref"> <filelist files="${INPUT_JARS_PATHS}"/> - <pathelement location="${PRODUCT_DIR}/content_shell/classes"/> + <pathelement location="${contentshell.classes.dir}"/> </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) --> - <fail message="PRODUCT_DIR env var not set?"> - <condition> - <not> - <isset property="PRODUCT_DIR"/> - </not> - </condition> - </fail> - - <target name="-post-compile"> - <!-- 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. --> - <if> - <condition> - <equals arg1="${build.target}" arg2="debug" /> - </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> - - <!-- We also want a .jar as well as an .apk for ContentShellTest-debug - so that proguard can be used to list the tests by annotation. --> - <jar destfile="${out.dir}/${ant.project.name}-debug.jar"> - <fileset dir="${out.dir}/classes" includes="**/*.class"/> - <zipfileset - includes="**/*.class" - src="${PRODUCT_DIR}/lib.java/chromium_content_javatests.jar"/> - <zipfileset - includes="**/*.class" - src="${PRODUCT_DIR}/lib.java/chromium_net_javatests.jar"/> - </jar> - - </target> <!-- Classpath for javac --> <path id="javac.custom.classpath"> <path refid="out.dex.jar.input.ref"/> </path> - <import file="../../../../build/android/ant/sdk-targets.xml"/> - <import file="${sdk.dir}/tools/ant/build.xml" /> + <import file="../../../../build/android/ant/sdk-targets.xml"/> + <import file="${sdk.dir}/tools/ant/build.xml"/> </project> |