gn2bp: mark java targets as java_group
According to the docs, java target names are (somewhat) guaranteed to end in _java. There are some other variations that are allowlisted, though it is currently unclear if those need to be supported for our purposes. Test: //net:net Change-Id: I0647dac6a078790e23509d437628aed0d8d62f77
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -20,6 +20,7 @@ import collections
|
|||||||
import errno
|
import errno
|
||||||
import filecmp
|
import filecmp
|
||||||
import json
|
import json
|
||||||
|
import logging as log
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
@@ -185,6 +186,13 @@ class GnParser(object):
|
|||||||
|
|
||||||
return ' '.join(formatted_flags)
|
return ' '.join(formatted_flags)
|
||||||
|
|
||||||
|
def _is_java_target(self, target):
|
||||||
|
# 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 re.match('.*_java$', target.name)
|
||||||
|
|
||||||
|
|
||||||
def get_target(self, gn_target_name):
|
def get_target(self, gn_target_name):
|
||||||
"""Returns a Target object from the fully qualified GN target name.
|
"""Returns a Target object from the fully qualified GN target name.
|
||||||
|
|
||||||
@@ -243,6 +251,11 @@ class GnParser(object):
|
|||||||
elif target.type == 'copy':
|
elif target.type == 'copy':
|
||||||
# TODO: copy rules are not currently implemented.
|
# TODO: copy rules are not currently implemented.
|
||||||
self.actions[gn_target_name] = target
|
self.actions[gn_target_name] = target
|
||||||
|
elif target.type == 'group' and self._is_java_target(target):
|
||||||
|
# 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)
|
||||||
|
target.type = 'java_group'
|
||||||
|
|
||||||
# Default for 'public' is //* - all headers in 'sources' are public.
|
# Default for 'public' is //* - all headers in 'sources' are public.
|
||||||
# TODO(primiano): if a 'public' section is specified (even if empty), then
|
# TODO(primiano): if a 'public' section is specified (even if empty), then
|
||||||
|
|||||||
Reference in New Issue
Block a user