gn2bp: rename _is_java_target to _is_java_group

In preparation for the CLs that follow.

Test: ./update_results.sh
Change-Id: Ib3154d842b68c68194a097aa0db65eba41b295e1
This commit is contained in:
Patrick Rohr
2022-12-12 20:19:26 -08:00
parent 17d4e4a41c
commit df3c20cdab

View File

@@ -260,11 +260,11 @@ class GnParser(object):
return ' '.join(formatted_flags)
def _is_java_target(self, target):
def _is_java_group(self, type_, target_name):
# Per https://chromium.googlesource.com/chromium/src/build/+/HEAD/android/docs/java_toolchain.md
# java target names must end in "_java".
# TODO: There are some other possible variations we might need to support.
return target.type == 'group' and re.match('.*_java$', target.name)
return type_ == 'group' and re.match('.*_java$', target_name)
def _get_arch(self, toolchain):
if toolchain == '//build/toolchain/android:android_clang_x86':
@@ -342,7 +342,8 @@ class GnParser(object):
elif target.type in LINKER_UNIT_TYPES:
self.linker_units[gn_target_name] = target
target.arch[arch].sources.update(desc.get('sources', []))
elif desc.get("script", "") in JAVA_BANNED_SCRIPTS or self._is_java_target(target):
elif (desc.get("script", "") in JAVA_BANNED_SCRIPTS
or self._is_java_group(target.type, target.name)):
# java_group identifies the group target generated by the android_library
# or java_library template. A java_group must not be added as a dependency, but sources are collected
log.debug('Found java target %s', target.name)