gn2bp: collect java sources
The current plan is to write a lightweight wrapper around Cronet that
serves as the Android API surface. If that holds true, we might get away
with putting all .java sources in a single jar. Otherwise, the API will
have to be put in a separate source jar.
Test: //net:net
Change-Id: I2bef893ebdf0a4390dfb634e715c60ccd94dc1fb
diff --git a/tools/gn2bp/gn_utils.py b/tools/gn2bp/gn_utils.py
index 5a84622..1aa352e 100644
--- a/tools/gn2bp/gn_utils.py
+++ b/tools/gn2bp/gn_utils.py
@@ -170,6 +170,7 @@
self.source_sets = {}
self.actions = {}
self.proto_libs = {}
+ self.java_sources = set()
def _get_response_file_contents(self, action_desc):
# response_file_contents are formatted as:
@@ -297,6 +298,18 @@
# java_library.
pass
+ # Collect java sources. Java sources are kept inside the __compile_java target.
+ # This target can be used for both host and target compilation; only add
+ # the sources if they are destined for the target (i.e. they are a
+ # dependency of the __dex target)
+ # Note: this skips prebuilt java dependencies. These will have to be
+ # added manually when building the jar.
+ if re.match('.*__dex$', target.name):
+ if re.match('.*__compile_java$', dep.name):
+ log.debug('Adding java sources for %s', dep.name)
+ java_srcs = [src for src in dep.inputs if os.path.splitext(src)[1] == '.java']
+ self.java_sources.update(java_srcs)
+
return target
def get_proto_exports(self, proto_desc):