gn2bp: Duplicate modules reachable from test targets
* The current testing situation for Cronet is dire due to the presence of Cronet on the platform, As cronet is on the platform, we can't run any unit-tests as they'll link against the platform version and not the statically-linked cronet. We could avoid this by jarjaring the code however this is impossible. * It's impossible to jar-jar the code as the C++ code which does JNI expects jar-jared java classes. So the only possible solution here would be to duplicate the C++ modules, one for testing(with no jarjar) and another for platform(with jarjar) * Java sources/actions are not collected for testing modules until a proper solution has been figured out. Test: None Change-Id: I20bbad13d83e9e3c7956f028f3f0493b24d0f8bc
This commit is contained in:
parent
fc05430542
commit
edb2fd014b
3 changed files with 18468 additions and 7193 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -217,12 +217,20 @@ def enable_zlib(module, arch):
|
|||
builtin_deps = {
|
||||
'//buildtools/third_party/libunwind:libunwind':
|
||||
lambda m, a: None, # disable libunwind
|
||||
'//buildtools/third_party/libunwind:libunwind__testing':
|
||||
lambda m, a: None, # disable libunwind
|
||||
'//net/data/ssl/chrome_root_store:gen_root_store_inc':
|
||||
lambda m, a: None,
|
||||
'//net/data/ssl/chrome_root_store:gen_root_store_inc__testing':
|
||||
lambda m, a: None,
|
||||
'//net/tools/root_store_tool:root_store_tool':
|
||||
lambda m, a: None,
|
||||
'//net/tools/root_store_tool:root_store_tool__testing':
|
||||
lambda m, a: None,
|
||||
'//third_party/zlib:zlib':
|
||||
enable_zlib,
|
||||
'//third_party/zlib:zlib__testing':
|
||||
enable_zlib,
|
||||
}
|
||||
|
||||
experimental_android_deps = {
|
||||
|
|
@ -1283,7 +1291,8 @@ def create_action_module(blueprint, target, genrule_type):
|
|||
'''
|
||||
# TODO: Handle this target correctly, this target generates java_genrule but this target has
|
||||
# different value for cpu-family arg between archs
|
||||
if target.name == '//build/android:native_libraries_gen':
|
||||
if target.name in ['//build/android:native_libraries_gen',
|
||||
'//build/android:native_libraries_gen__testing']:
|
||||
module = create_action_module_internal(target, genrule_type, target.arch['android_arm'])
|
||||
blueprint.add_module(module)
|
||||
return module
|
||||
|
|
@ -1336,7 +1345,7 @@ def set_module_include_dirs(module, cflags, include_dirs):
|
|||
if d not in local_include_dirs_denylist]
|
||||
|
||||
|
||||
def create_modules_from_target(blueprint, gn, gn_target_name):
|
||||
def create_modules_from_target(blueprint, gn, gn_target_name, is_test_target):
|
||||
"""Generate module(s) for a given GN target.
|
||||
|
||||
Given a GN target name, generate one or more corresponding modules into a
|
||||
|
|
@ -1462,7 +1471,7 @@ def create_modules_from_target(blueprint, gn, gn_target_name):
|
|||
builtin_deps[dep_name](module, None)
|
||||
continue
|
||||
|
||||
dep_module = create_modules_from_target(blueprint, gn, dep_name)
|
||||
dep_module = create_modules_from_target(blueprint, gn, dep_name, is_test_target)
|
||||
|
||||
if dep_module is None:
|
||||
continue
|
||||
|
|
@ -1517,7 +1526,7 @@ def create_modules_from_target(blueprint, gn, gn_target_name):
|
|||
if dep_name in builtin_deps:
|
||||
builtin_deps[dep_name](module, arch_name)
|
||||
continue
|
||||
dep_module = create_modules_from_target(blueprint, gn, dep_name)
|
||||
dep_module = create_modules_from_target(blueprint, gn, dep_name, is_test_target)
|
||||
# Arch-specific dependencies currently only include cc_library_static.
|
||||
# Revisit this approach once we need to support more target types.
|
||||
if dep_module.type == 'cc_library_static':
|
||||
|
|
@ -1660,7 +1669,7 @@ def update_jni_registration_module(module, gn):
|
|||
for source in get_non_api_java_sources(gn)
|
||||
if source.endswith('.java')])
|
||||
|
||||
def create_blueprint_for_targets(gn, targets):
|
||||
def create_blueprint_for_targets(gn, targets, test_targets):
|
||||
"""Generate a blueprint for a list of GN targets."""
|
||||
blueprint = Blueprint()
|
||||
|
||||
|
|
@ -1704,7 +1713,10 @@ def create_blueprint_for_targets(gn, targets):
|
|||
blueprint.add_module(defaults)
|
||||
|
||||
for target in targets:
|
||||
create_modules_from_target(blueprint, gn, target)
|
||||
create_modules_from_target(blueprint, gn, target, is_test_target=False)
|
||||
|
||||
for test_target in test_targets:
|
||||
create_modules_from_target(blueprint, gn, test_target + gn_utils.TESTING_SUFFIX, is_test_target=True)
|
||||
|
||||
java_api_module = create_java_api_module(blueprint, gn)
|
||||
java_module = create_java_module(blueprint, gn)
|
||||
|
|
@ -1819,14 +1831,16 @@ def main():
|
|||
if args.verbose:
|
||||
log.basicConfig(format='%(levelname)s:%(funcName)s:%(message)s', level=log.DEBUG)
|
||||
|
||||
targets = args.targets or DEFAULT_TARGETS + DEFAULT_TESTS
|
||||
targets = args.targets or DEFAULT_TARGETS
|
||||
gn = gn_utils.GnParser(builtin_deps)
|
||||
for desc_file in args.desc:
|
||||
with open(desc_file) as f:
|
||||
desc = json.load(f)
|
||||
for target in targets:
|
||||
gn.parse_gn_desc(desc, target, is_test_target=target in DEFAULT_TESTS)
|
||||
blueprint = create_blueprint_for_targets(gn, targets)
|
||||
gn.parse_gn_desc(desc, target)
|
||||
for test_target in DEFAULT_TESTS:
|
||||
gn.parse_gn_desc(desc, test_target, is_test_target=True)
|
||||
blueprint = create_blueprint_for_targets(gn, targets, DEFAULT_TESTS)
|
||||
project_root = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||
tool_name = os.path.relpath(os.path.abspath(__file__), project_root)
|
||||
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ ODR_VIOLATION_IGNORE_TARGETS = {
|
|||
}
|
||||
ARCH_REGEX = r'(android_x86_64|android_x86|android_arm|android_arm64|host)'
|
||||
RESPONSE_FILE = '{{response_file_name}}'
|
||||
TESTING_SUFFIX = "__testing"
|
||||
AIDL_INCLUDE_DIRS_REGEX = r'--includes=\[(.*)\]'
|
||||
|
||||
def repo_root():
|
||||
|
|
@ -339,6 +340,9 @@ class GnParser(object):
|
|||
if self._is_java_group(type_, target_name):
|
||||
java_group_name = target_name
|
||||
|
||||
if is_test_target:
|
||||
target_name += TESTING_SUFFIX
|
||||
|
||||
target = self.all_targets.get(target_name)
|
||||
if target is None:
|
||||
target = GnParser.Target(target_name, type_)
|
||||
|
|
|
|||
Loading…
Reference in a new issue