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-Original-Commit-Position: refs/heads/master@{#329510}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: d4910aba370e4e5d55477b4b857c707d07526f7b
This commit is contained in:
cjhopman 2015-05-12 15:23:49 -07:00 коммит произвёл Commit bot
Родитель cf9ac8f480
Коммит 0c59052ea0
4 изменённых файлов: 62 добавлений и 31 удалений

Просмотреть файл

@ -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.extend(class_files_rel)
record_path = '%s.md5.stamp' % jar_path
md5_check.CallAndRecordIfStale(
lambda: build_utils.CheckOutput(jar_cmd, cwd=jar_cwd),
record_path=record_path,
input_paths=class_files,
input_strings=jar_cmd,
force=not os.path.exists(jar_path),
)
with build_utils.TempDir() as temp_dir:
empty_file = os.path.join(temp_dir, '.empty')
build_utils.Touch(empty_file)
jar_cmd.append(os.path.relpath(empty_file, jar_cwd))
record_path = '%s.md5.stamp' % jar_path
md5_check.CallAndRecordIfStale(
lambda: build_utils.CheckOutput(jar_cmd, cwd=jar_cwd),
record_path=record_path,
input_paths=class_files,
input_strings=jar_cmd,
force=not os.path.exists(jar_path),
)
build_utils.Touch(jar_path, fail_if_missing=True)
build_utils.Touch(jar_path, fail_if_missing=True)
def JarDirectory(classes_dir, excluded_classes, jar_path, manifest_file=None):

Просмотреть файл

@ -72,8 +72,10 @@ def ExtractToc(disassembled_classes):
def UpdateToc(jar_path, toc_path):
classes = GetClassesInZipFile(zipfile.ZipFile(jar_path))
javap_output = CallJavap(classpath=jar_path, classes=classes)
toc = ExtractToc(javap_output)
toc = ''
if len(classes) != 0:
javap_output = CallJavap(classpath=jar_path, classes=classes)
toc = ExtractToc(javap_output)
with open(toc_path, 'w') as tocfile:
tocfile.write(toc)

Просмотреть файл

@ -236,11 +236,12 @@ def main(argv):
break
java_files = filtered_java_files
DoJavac(
classpath,
classes_dir,
options.chromium_code,
java_files)
if len(java_files) != 0:
DoJavac(
classpath,
classes_dir,
options.chromium_code,
java_files)
if options.jar_path:
if options.main_class or options.manifest_entry:

Просмотреть файл

@ -79,9 +79,32 @@ def DepsOfType(wanted_type, configs):
def GetAllDepsConfigsInOrder(deps_config_paths):
def Deps(path):
def GetDeps(path):
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):
@ -166,20 +189,23 @@ def main(argv):
direct_deps_config_paths = [
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]
deps = Deps(direct_deps_config_paths)
direct_library_deps = deps.Direct('java_library')
all_library_deps = deps.All('java_library')
direct_library_deps = DepsOfType('java_library', direct_deps_configs)
all_library_deps = DepsOfType('java_library', all_deps_configs)
direct_resources_deps = DepsOfType('android_resources', direct_deps_configs)
all_resources_deps = DepsOfType('android_resources', all_deps_configs)
direct_resources_deps = deps.Direct('android_resources')
all_resources_deps = deps.All('android_resources')
# Resources should be ordered with the highest-level dependency first so that
# overrides are done correctly.
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.
config = {
'deps_info': {
@ -265,10 +291,8 @@ def main(argv):
# An instrumentation test apk should exclude the dex files that are in the apk
# under test.
if options.type == 'android_apk' and options.tested_apk_config:
tested_apk_config_paths = GetAllDepsConfigsInOrder(
[options.tested_apk_config])
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 = Deps([options.tested_apk_config])
tested_apk_library_deps = tested_apk_deps.All('java_library')
tested_apk_deps_dex_files = [c['dex_path'] for c in tested_apk_library_deps]
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):
if options.depfile:
build_utils.WriteDepfile(
options.depfile,
all_deps_config_paths + build_utils.GetPythonDependencies())
deps.AllConfigPaths() + build_utils.GetPythonDependencies())
if __name__ == '__main__':