Commit 4afef6e2 authored by cjhopman@chromium.org's avatar cjhopman@chromium.org

Remove hardcoded chromium_*.jar paths

Targets with dependencies (direct/indirect) on a java target receive the
chromium_*.jar paths in the variable input_jars_paths. Targets should
use that rather than hardcoding where they think the jar will be.

Change native_test_apk.xml to build with a list of jars in
INPUT_JARS_PATHS rather than using all jars in a specific output
directory.

Make generate_native_test.py pass the --jars argument to ant with
-DINPUT_JARS_PATHS. This supports those targets (WebKit) that are not
updated to pass the ant-arg directly.

BUG=


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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171131 0039d316-1c4b-4281-b951-d872f2087c98
parent 3c87ce67
...@@ -88,7 +88,6 @@ ...@@ -88,7 +88,6 @@
'variables': { 'variables': {
'test_suite_name': 'android_webview_unittests', 'test_suite_name': 'android_webview_unittests',
'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)android_webview_unittests<(SHARED_LIB_SUFFIX)', 'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)android_webview_unittests<(SHARED_LIB_SUFFIX)',
'input_jars_paths': ['<(PRODUCT_DIR)/lib.java/chromium_android_webview_unittest_java.jar'],
}, },
'includes': [ '../build/apk_test.gypi' ], 'includes': [ '../build/apk_test.gypi' ],
}, },
......
...@@ -19,12 +19,9 @@ ...@@ -19,12 +19,9 @@
# #
{ {
'variables': { 'dependencies': [
'input_jars_paths': [ '<(DEPTH)/base/base.gyp:base_java',
# Needed by ChromeNativeTestActivity.java. ],
'<(PRODUCT_DIR)/lib.java/chromium_base.jar',
],
},
'target_conditions': [ 'target_conditions': [
['_toolset == "target"', { ['_toolset == "target"', {
'conditions': [ 'conditions': [
...@@ -45,8 +42,6 @@ ...@@ -45,8 +42,6 @@
'<(DEPTH)/testing/android/generate_native_test.py', '<(DEPTH)/testing/android/generate_native_test.py',
'--native_library', '--native_library',
'<(input_shlib_path)', '<(input_shlib_path)',
'--jars',
'">@(input_jars_paths)"',
'--output', '--output',
'<(PRODUCT_DIR)/<(test_suite_name)_apk', '<(PRODUCT_DIR)/<(test_suite_name)_apk',
'--strip-binary=<(android_strip)', '--strip-binary=<(android_strip)',
...@@ -66,6 +61,8 @@ ...@@ -66,6 +61,8 @@
'-DANDROID_GDBSERVER=<(android_gdbserver)', '-DANDROID_GDBSERVER=<(android_gdbserver)',
'--ant-args', '--ant-args',
'-DCHROMIUM_SRC=<(ant_build_out)/../..', '-DCHROMIUM_SRC=<(ant_build_out)/../..',
'--ant-args',
'-DINPUT_JARS_PATHS=>(input_jars_paths)',
], ],
}], }],
}], # 'OS == "android" and gtest_target_type == "shared_library" }], # 'OS == "android" and gtest_target_type == "shared_library"
......
...@@ -18,7 +18,6 @@ import logging ...@@ -18,7 +18,6 @@ import logging
import optparse import optparse
import os import os
import re import re
import shutil
import subprocess import subprocess
import sys import sys
...@@ -52,10 +51,9 @@ class NativeTestApkGenerator(object): ...@@ -52,10 +51,9 @@ class NativeTestApkGenerator(object):
'native_test_apk.xml', 'native_test_apk.xml',
'res/values/strings.xml'] 'res/values/strings.xml']
def __init__(self, native_library, jars, strip_binary, output_directory, def __init__(self, native_library, strip_binary, output_directory,
target_abi): target_abi):
self._native_library = native_library self._native_library = native_library
self._jars = jars
self._strip_binary = strip_binary self._strip_binary = strip_binary
self._output_directory = os.path.abspath(output_directory) self._output_directory = os.path.abspath(output_directory)
self._target_abi = target_abi self._target_abi = target_abi
...@@ -110,8 +108,8 @@ class NativeTestApkGenerator(object): ...@@ -110,8 +108,8 @@ class NativeTestApkGenerator(object):
dest = dest.replace('replaceme', self._root_name) # update the filename! dest = dest.replace('replaceme', self._root_name) # update the filename!
open(dest, 'w').write(contents) open(dest, 'w').write(contents)
def _CopyLibraryAndJars(self): def _CopyLibrary(self):
"""Copy the shlib and jars into the apk source tree (if relevant).""" """Copy the shlib into the apk source tree (if relevant)."""
if self._native_library: if self._native_library:
destdir = os.path.join(self._output_directory, 'libs/' + self._target_abi) destdir = os.path.join(self._output_directory, 'libs/' + self._target_abi)
if not os.path.exists(destdir): if not os.path.exists(destdir):
...@@ -121,20 +119,12 @@ class NativeTestApkGenerator(object): ...@@ -121,20 +119,12 @@ class NativeTestApkGenerator(object):
cmd_helper.RunCmd( cmd_helper.RunCmd(
[self._strip_binary, '--strip-unneeded', self._native_library, '-o', [self._strip_binary, '--strip-unneeded', self._native_library, '-o',
dest]) dest])
if self._jars:
destdir = os.path.join(self._output_directory, 'java/libs')
if not os.path.exists(destdir):
os.makedirs(destdir)
for jar in self._jars:
dest = os.path.join(destdir, os.path.basename(jar))
logging.warn('%s --> %s', jar, dest)
shutil.copyfile(jar, dest)
def CreateBundle(self): def CreateBundle(self):
"""Create the apk bundle source and assemble components.""" """Create the apk bundle source and assemble components."""
self._CopyTemplateFilesAndClearDir() self._CopyTemplateFilesAndClearDir()
self._ReplaceStrings() self._ReplaceStrings()
self._CopyLibraryAndJars() self._CopyLibrary()
def Compile(self, ant_args): def Compile(self, ant_args):
"""Build the generated apk with ant. """Build the generated apk with ant.
...@@ -189,13 +179,17 @@ def main(argv): ...@@ -189,13 +179,17 @@ def main(argv):
if not options.strip_binary: if not options.strip_binary:
raise Exception('No tool for stripping the libraries has been supplied') raise Exception('No tool for stripping the libraries has been supplied')
# Remove all quotes from the jars string # Remove all quotes from the jars string and pass the list to ant as
# INPUT_JARS_PATHS.
# TODO(cjhopman): Remove this when all targets pass the list of jars as an
# ant-arg directly.
jar_list = [] jar_list = []
if options.jars: if options.jars:
jar_list = options.jars.replace('"', '').split() jar_list = options.jars.replace('"', '').split()
options.ant_args.append('-DINPUT_JARS_PATHS=' + " ".join(jar_list))
ntag = NativeTestApkGenerator(native_library=options.native_library, ntag = NativeTestApkGenerator(native_library=options.native_library,
jars=jar_list,
strip_binary=options.strip_binary, strip_binary=options.strip_binary,
output_directory=options.output, output_directory=options.output,
target_abi=options.app_abi) target_abi=options.app_abi)
......
...@@ -12,20 +12,15 @@ ...@@ -12,20 +12,15 @@
'type': 'none', 'type': 'none',
'dependencies': [ 'dependencies': [
'native_test_native_code', 'native_test_native_code',
'<(DEPTH)/base/base.gyp:base_java',
], ],
'actions': [ 'actions': [
{
'action_name': 'copy_base_jar',
'inputs': ['<(PRODUCT_DIR)/lib.java/chromium_base.jar'],
'outputs': ['<(PRODUCT_DIR)/replaceme_apk/java/libs/chromium_base.jar'],
'action': ['cp', '<@(_inputs)', '<@(_outputs)'],
},
{ {
'action_name': 'native_test_apk', 'action_name': 'native_test_apk',
'inputs': [ 'inputs': [
'<(DEPTH)/testing/android/native_test_apk.xml', '<(DEPTH)/testing/android/native_test_apk.xml',
'<!@(find <(DEPTH)/testing/android -name "*.java")', '<!@(find <(DEPTH)/testing/android -name "*.java")',
'<(PRODUCT_DIR)/replaceme_apk/java/libs/chromium_base.jar', '>@(input_jars_paths)',
'native_test_launcher.cc' 'native_test_launcher.cc'
], ],
'outputs': [ 'outputs': [
...@@ -48,6 +43,7 @@ ...@@ -48,6 +43,7 @@
'-DANDROID_SDK_VERSION=<(android_sdk_version)', '-DANDROID_SDK_VERSION=<(android_sdk_version)',
'-DANDROID_GDBSERVER=<(android_gdbserver)', '-DANDROID_GDBSERVER=<(android_gdbserver)',
'-DCHROMIUM_SRC=<(ant_build_out)/../..', '-DCHROMIUM_SRC=<(ant_build_out)/../..',
'-DINPUT_JARS_PATHS=>(input_jars_paths)',
'-buildfile', '-buildfile',
'<(DEPTH)/testing/android/native_test_apk.xml', '<(DEPTH)/testing/android/native_test_apk.xml',
] ]
......
...@@ -49,18 +49,13 @@ found in the LICENSE file. ...@@ -49,18 +49,13 @@ found in the LICENSE file.
<property name="resource.absolute.dir" value="res"/> <property name="resource.absolute.dir" value="res"/>
<property name="gen.absolute.dir" value="${out.dir}/gen"/> <property name="gen.absolute.dir" value="${out.dir}/gen"/>
<condition property="external.jars.dir"
value="${out.dir}/java/libs"
else="">
<available file="${out.dir}/java/libs" type="dir"/>
</condition>
<path id="out.dex.jar.input.ref"> <path id="out.dex.jar.input.ref">
<fileset dir="${external.jars.dir}" includes="*.jar"/> <filelist files="${INPUT_JARS_PATHS}"/>
</path> </path>
<condition property="java.compilerargs" <condition property="java.compilerargs"
value="-classpath ${toString:out.dex.jar.input.ref}"> value="-classpath ${toString:out.dex.jar.input.ref}">
<not> <not>
<equals arg1="${external.jars.dir}" arg2=""/> <equals arg1="${toString:out.dex.jar.input.ref}" arg2=""/>
</not> </not>
</condition> </condition>
<property name="native.libs.absolute.dir" location="${out.dir}/libs" /> <property name="native.libs.absolute.dir" location="${out.dir}/libs" />
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment