Commit d4910aba authored by cjhopman's avatar cjhopman Committed by Commit bot

Don't include tested apks resources in test apk

This restricts the test apk's resources to just be those not already
included in the tested apk. Because GN apk targets typically don't
include java of their own, this requires supporting javac+jar for the
case where there is no java files.

Fixes deps so that chrome_shell_test_apk actually builds.

TBR=nyquist,dalecurtis,cbentzel

BUG=359249

Review URL: https://codereview.chromium.org/1127233005

Cr-Commit-Position: refs/heads/master@{#329510}
parent d5c5a7e8
...@@ -27,16 +27,20 @@ def Jar(class_files, classes_dir, jar_path, manifest_file=None): ...@@ -27,16 +27,20 @@ def Jar(class_files, classes_dir, jar_path, manifest_file=None):
jar_cmd.append(os.path.abspath(manifest_file)) jar_cmd.append(os.path.abspath(manifest_file))
jar_cmd.extend(class_files_rel) jar_cmd.extend(class_files_rel)
record_path = '%s.md5.stamp' % jar_path with build_utils.TempDir() as temp_dir:
md5_check.CallAndRecordIfStale( empty_file = os.path.join(temp_dir, '.empty')
lambda: build_utils.CheckOutput(jar_cmd, cwd=jar_cwd), build_utils.Touch(empty_file)
record_path=record_path, jar_cmd.append(os.path.relpath(empty_file, jar_cwd))
input_paths=class_files, record_path = '%s.md5.stamp' % jar_path
input_strings=jar_cmd, md5_check.CallAndRecordIfStale(
force=not os.path.exists(jar_path), lambda: build_utils.CheckOutput(jar_cmd, cwd=jar_cwd),
) record_path=record_path,
input_paths=class_files,
build_utils.Touch(jar_path, fail_if_missing=True) input_strings=jar_cmd,
force=not os.path.exists(jar_path),
)
build_utils.Touch(jar_path, fail_if_missing=True)
def JarDirectory(classes_dir, excluded_classes, jar_path, manifest_file=None): def JarDirectory(classes_dir, excluded_classes, jar_path, manifest_file=None):
......
...@@ -72,8 +72,10 @@ def ExtractToc(disassembled_classes): ...@@ -72,8 +72,10 @@ def ExtractToc(disassembled_classes):
def UpdateToc(jar_path, toc_path): def UpdateToc(jar_path, toc_path):
classes = GetClassesInZipFile(zipfile.ZipFile(jar_path)) classes = GetClassesInZipFile(zipfile.ZipFile(jar_path))
javap_output = CallJavap(classpath=jar_path, classes=classes) toc = ''
toc = ExtractToc(javap_output) if len(classes) != 0:
javap_output = CallJavap(classpath=jar_path, classes=classes)
toc = ExtractToc(javap_output)
with open(toc_path, 'w') as tocfile: with open(toc_path, 'w') as tocfile:
tocfile.write(toc) tocfile.write(toc)
......
...@@ -236,11 +236,12 @@ def main(argv): ...@@ -236,11 +236,12 @@ def main(argv):
break break
java_files = filtered_java_files java_files = filtered_java_files
DoJavac( if len(java_files) != 0:
classpath, DoJavac(
classes_dir, classpath,
options.chromium_code, classes_dir,
java_files) options.chromium_code,
java_files)
if options.jar_path: if options.jar_path:
if options.main_class or options.manifest_entry: if options.main_class or options.manifest_entry:
......
...@@ -79,9 +79,32 @@ def DepsOfType(wanted_type, configs): ...@@ -79,9 +79,32 @@ def DepsOfType(wanted_type, configs):
def GetAllDepsConfigsInOrder(deps_config_paths): def GetAllDepsConfigsInOrder(deps_config_paths):
def Deps(path): def GetDeps(path):
return set(GetDepConfig(path)['deps_configs']) return set(GetDepConfig(path)['deps_configs'])
return build_utils.GetSortedTransitiveDependencies(deps_config_paths, Deps) return build_utils.GetSortedTransitiveDependencies(deps_config_paths, GetDeps)
class Deps(object):
def __init__(self, direct_deps_config_paths):
self.all_deps_config_paths = GetAllDepsConfigsInOrder(
direct_deps_config_paths)
self.direct_deps_configs = [
GetDepConfig(p) for p in direct_deps_config_paths]
self.all_deps_configs = [
GetDepConfig(p) for p in self.all_deps_config_paths]
def All(self, wanted_type=None):
if type is None:
return self.all_deps_configs
return DepsOfType(wanted_type, self.all_deps_configs)
def Direct(self, wanted_type=None):
if wanted_type is None:
return self.direct_deps_configs
return DepsOfType(wanted_type, self.direct_deps_configs)
def AllConfigPaths(self):
return self.all_deps_config_paths
def main(argv): def main(argv):
...@@ -166,20 +189,23 @@ def main(argv): ...@@ -166,20 +189,23 @@ def main(argv):
direct_deps_config_paths = [ direct_deps_config_paths = [
c for c in possible_deps_config_paths if not c in unknown_deps] c for c in possible_deps_config_paths if not c in unknown_deps]
all_deps_config_paths = GetAllDepsConfigsInOrder(direct_deps_config_paths)
direct_deps_configs = [GetDepConfig(p) for p in direct_deps_config_paths]
all_deps_configs = [GetDepConfig(p) for p in all_deps_config_paths]
direct_library_deps = DepsOfType('java_library', direct_deps_configs) deps = Deps(direct_deps_config_paths)
all_library_deps = DepsOfType('java_library', all_deps_configs) direct_library_deps = deps.Direct('java_library')
all_library_deps = deps.All('java_library')
direct_resources_deps = DepsOfType('android_resources', direct_deps_configs) direct_resources_deps = deps.Direct('android_resources')
all_resources_deps = DepsOfType('android_resources', all_deps_configs) all_resources_deps = deps.All('android_resources')
# Resources should be ordered with the highest-level dependency first so that # Resources should be ordered with the highest-level dependency first so that
# overrides are done correctly. # overrides are done correctly.
all_resources_deps.reverse() all_resources_deps.reverse()
if options.type == 'android_apk' and options.tested_apk_config:
tested_apk_deps = Deps([options.tested_apk_config])
tested_apk_resources_deps = tested_apk_deps.All('android_resources')
all_resources_deps = [
d for d in all_resources_deps if not d in tested_apk_resources_deps]
# Initialize some common config. # Initialize some common config.
config = { config = {
'deps_info': { 'deps_info': {
...@@ -265,10 +291,8 @@ def main(argv): ...@@ -265,10 +291,8 @@ def main(argv):
# An instrumentation test apk should exclude the dex files that are in the apk # An instrumentation test apk should exclude the dex files that are in the apk
# under test. # under test.
if options.type == 'android_apk' and options.tested_apk_config: if options.type == 'android_apk' and options.tested_apk_config:
tested_apk_config_paths = GetAllDepsConfigsInOrder( tested_apk_deps = Deps([options.tested_apk_config])
[options.tested_apk_config]) tested_apk_library_deps = tested_apk_deps.All('java_library')
tested_apk_configs = [GetDepConfig(p) for p in tested_apk_config_paths]
tested_apk_library_deps = DepsOfType('java_library', tested_apk_configs)
tested_apk_deps_dex_files = [c['dex_path'] for c in tested_apk_library_deps] tested_apk_deps_dex_files = [c['dex_path'] for c in tested_apk_library_deps]
deps_dex_files = [ deps_dex_files = [
p for p in deps_dex_files if not p in tested_apk_deps_dex_files] p for p in deps_dex_files if not p in tested_apk_deps_dex_files]
...@@ -325,7 +349,7 @@ def main(argv): ...@@ -325,7 +349,7 @@ def main(argv):
if options.depfile: if options.depfile:
build_utils.WriteDepfile( build_utils.WriteDepfile(
options.depfile, options.depfile,
all_deps_config_paths + build_utils.GetPythonDependencies()) deps.AllConfigPaths() + build_utils.GetPythonDependencies())
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -106,6 +106,7 @@ android_library("chrome_java") { ...@@ -106,6 +106,7 @@ android_library("chrome_java") {
"//third_party/cacheinvalidation:cacheinvalidation_proto_java", "//third_party/cacheinvalidation:cacheinvalidation_proto_java",
"//third_party/jsr-305:jsr_305_javalib", "//third_party/jsr-305:jsr_305_javalib",
"//media/base/android:media_java", "//media/base/android:media_java",
"//media/midi:midi_java",
"//ui/android:ui_java", "//ui/android:ui_java",
"//ui/android:ui_java_resources", "//ui/android:ui_java_resources",
google_play_services_library, google_play_services_library,
...@@ -405,6 +406,7 @@ android_library("chrome_javatests") { ...@@ -405,6 +406,7 @@ android_library("chrome_javatests") {
"//components/bookmarks/common/android:bookmarks_java", "//components/bookmarks/common/android:bookmarks_java",
"//components/dom_distiller/android:dom_distiller_core_java", "//components/dom_distiller/android:dom_distiller_core_java",
"//components/invalidation:java", "//components/invalidation:java",
"//components/invalidation:javatests",
"//components/navigation_interception/android:navigation_interception_java", "//components/navigation_interception/android:navigation_interception_java",
"//components/precache/android:precache_java", "//components/precache/android:precache_java",
"//components/precache/android:precache_javatests", "//components/precache/android:precache_javatests",
......
...@@ -115,10 +115,7 @@ group("unittests") { ...@@ -115,10 +115,7 @@ group("unittests") {
":test_support", ":test_support",
] ]
if (is_android) { if (is_android) {
deps += [ deps += [ ":jni_headers" ]
":javatests",
":jni_headers",
]
} }
} }
......
...@@ -321,7 +321,6 @@ component("media") { ...@@ -321,7 +321,6 @@ component("media") {
] ]
deps += [ deps += [
"//media/base/android", "//media/base/android",
"//media/base/android:media_java",
"//media/base/android:media_jni_headers", "//media/base/android:media_jni_headers",
"//media/base/android:video_capture_jni_headers", "//media/base/android:video_capture_jni_headers",
] ]
......
...@@ -1350,10 +1350,7 @@ if (!is_android && !is_mac) { ...@@ -1350,10 +1350,7 @@ if (!is_android && !is_mac) {
# sense. # sense.
"dns/dns_config_service_posix_unittest.cc", "dns/dns_config_service_posix_unittest.cc",
] ]
deps += [ deps += [ ":net_test_jni_headers" ]
":net_javatests", # FIXME(brettw)
":net_test_jni_headers",
]
} }
if (v8_use_external_startup_data) { if (v8_use_external_startup_data) {
......
...@@ -28,6 +28,9 @@ android_aidl("remote_android_keystore_aidl") { ...@@ -28,6 +28,9 @@ android_aidl("remote_android_keystore_aidl") {
android_library("net_java_test_support") { android_library("net_java_test_support") {
DEPRECATED_java_in_dir = "../test/android/javatests/src" DEPRECATED_java_in_dir = "../test/android/javatests/src"
deps = [
"//base:base_java",
]
srcjar_deps = [ ":net_java_test_support_enums_srcjar" ] srcjar_deps = [ ":net_java_test_support_enums_srcjar" ]
} }
......
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