summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohannad Farrag <aymanm@google.com>2024-01-04 16:06:07 +0000
committerMohannad Farrag <aymanm@google.com>2024-01-17 11:42:32 +0000
commit211520f1421f226410ec79ad5d2d27df254c778f (patch)
tree411df679af67230e0628fc9596ebb34dc82c1905
parent63f55a56e9b3ea66f59c7b8fc6263682c80e76fc (diff)
downloadcronet-211520f1421f226410ec79ad5d2d27df254c778f.tar.gz
Generate java component of netty4
This is just a java_import target that points to a JAR which contains all of the necessary classes. Bug: 319629150 Bug: 304217500 Change-Id: Ic577cce9920aa245bba228985bd318299f1e2a58
-rw-r--r--android/tools/gn2bp/Android.bp.swp16
-rwxr-xr-xandroid/tools/gn2bp/gen_android_bp29
-rw-r--r--android/tools/gn2bp/gn_utils.py8
3 files changed, 41 insertions, 12 deletions
diff --git a/android/tools/gn2bp/Android.bp.swp b/android/tools/gn2bp/Android.bp.swp
index 9e0e84e48..b74fedab4 100644
--- a/android/tools/gn2bp/Android.bp.swp
+++ b/android/tools/gn2bp/Android.bp.swp
@@ -12388,6 +12388,7 @@ java_library {
"cronet_aml_components_cronet_android_cronet_impl_all_java__testing",
"cronet_aml_net_android_net_java_test_support__testing",
"cronet_aml_third_party_jni_zero_jni_zero_java__testing",
+ "cronet_aml_third_party_netty4_netty_all_java__testing",
"junit",
"truth",
],
@@ -52557,6 +52558,21 @@ cc_library_static {
},
}
+// GN: //third_party/netty4:netty_all_java__testing
+java_import {
+ name: "cronet_aml_third_party_netty4_netty_all_java__testing",
+ defaults: [
+ "cronet_aml_defaults",
+ ],
+ visibility: [
+ "//external/cronet:__subpackages__",
+ "//packages/modules/Connectivity:__subpackages__",
+ ],
+ jars: [
+ "third_party/netty4/src/jar/all-in-one/netty-all-4.1.9.Final.jar",
+ ],
+}
+
// GN: //third_party/netty-tcnative:netty-tcnative-so__testing
cc_library_shared {
name: "cronet_aml_third_party_netty_tcnative_netty_tcnative_so__testing",
diff --git a/android/tools/gn2bp/gen_android_bp b/android/tools/gn2bp/gen_android_bp
index ba0eb2263..9da200241 100755
--- a/android/tools/gn2bp/gen_android_bp
+++ b/android/tools/gn2bp/gen_android_bp
@@ -61,6 +61,7 @@ DEFAULT_TESTS = [
'//net/android:net_test_support_provider_java',
'//net/android:net_tests_java',
'//third_party/netty-tcnative:netty-tcnative-so',
+ '//third_party/netty4:netty_all_java',
]
EXTRAS_ANDROID_BP_FILE = "Android.extras.bp"
@@ -382,8 +383,6 @@ _builtin_deps = {
add_androidx_ui_automator_java_deps,
'//third_party/hamcrest:hamcrest_java':
add_hamcrest_java_deps,
- '//third_party/netty4:netty_all_java':
- always_disable,
'//third_party/androidx:androidx_activity_activity_java':
add_androidx_activity_activity,
'//third_party/androidx:androidx_fragment_fragment_java':
@@ -583,6 +582,7 @@ class Module(object):
self.visibility = set()
self.gn_type = None
self.jarjar_rules = ""
+ self.jars = set()
def to_string(self, output):
if self.comment:
@@ -638,6 +638,7 @@ class Module(object):
self._output_field(output, 'default_visibility')
self._output_field(output, 'visibility')
self._output_field(output, 'jarjar_rules')
+ self._output_field(output, 'jars')
if self.rtti:
self._output_field(output, 'rtti')
@@ -681,7 +682,7 @@ class Module(object):
return self.type == "cc_genrule"
def has_input_files(self):
- if self.type == "java_library":
+ if self.type in ["java_library", "java_import"]:
return True
if len(self.srcs) > 0:
return True
@@ -1642,14 +1643,18 @@ def create_modules_from_target(blueprint, gn, gn_target_name, is_descendant_of_j
# leaf node.
return None
elif target.type == 'java_library':
- module = Module('java_library', bp_module_name, gn_target_name)
- # Don't remove GEN_JNI from those modules as they have the real GEN_JNI that we want to include
- if gn_target_name not in ['//components/cronet/android:cronet_jni_registration_java',
- '//components/cronet/android:cronet_jni_registration_java__testing',
- '//components/cronet/android:cronet_tests_jni_registration_java__testing']:
- module.jarjar_rules = REMOVE_GEN_JNI_JARJAR_RULES_FILE
- module.min_sdk_version = 30
- module.apex_available = [tethering_apex]
+ if target.jar_path:
+ module = Module('java_import', bp_module_name, gn_target_name)
+ module.jars.add(target.jar_path)
+ else:
+ module = Module('java_library', bp_module_name, gn_target_name)
+ # Don't remove GEN_JNI from those modules as they have the real GEN_JNI that we want to include
+ if gn_target_name not in ['//components/cronet/android:cronet_jni_registration_java',
+ '//components/cronet/android:cronet_jni_registration_java__testing',
+ '//components/cronet/android:cronet_tests_jni_registration_java__testing']:
+ module.jarjar_rules = REMOVE_GEN_JNI_JARJAR_RULES_FILE
+ module.min_sdk_version = 30
+ module.apex_available = [tethering_apex]
else:
raise Exception('Unknown target %s (%s)' % (target.name, target.type))
@@ -1799,7 +1804,7 @@ def create_modules_from_target(blueprint, gn, gn_target_name, is_descendant_of_j
module_target.srcs.update(dep_module.genrule_srcs)
module_target.shared_libs.update(dep_module.genrule_shared_libs)
module_target.header_libs.update(dep_module.genrule_header_libs)
- elif dep_module.type == 'java_library':
+ elif dep_module.type in ['java_library', 'java_import']:
if module.type not in ["cc_library_static"]:
# This is needed to go around the case where `url` component depends
# on `url_java`.
diff --git a/android/tools/gn2bp/gn_utils.py b/android/tools/gn2bp/gn_utils.py
index 7f778c5bd..188d706d6 100644
--- a/android/tools/gn2bp/gn_utils.py
+++ b/android/tools/gn2bp/gn_utils.py
@@ -209,6 +209,9 @@ class GnParser(object):
# Deps for JNI Registration. Those are not added to deps so that
# the generated module would not depend on those deps.
self.jni_registration_java_deps = set()
+ # Path to the java jar path. This is used if the java library is
+ # an import of a JAR like `android_java_prebuilt` targets in GN
+ self.jar_path = ""
# Properties to forward access to common arch.
# TODO: delete these after the transition has been completed.
@@ -462,6 +465,11 @@ class GnParser(object):
if not java_source.startswith("//out") and java_source not in JAVA_FILES_TO_IGNORE:
sources.add(java_source)
target.sources.update(sources)
+ # Metadata attributes must be list, for jar_path, it is always a list
+ # of size one, the first element is an empty string if `jar_path` is not
+ # defined otherwise it is a path.
+ if metadata.get("jar_path", [""])[0]:
+ target.jar_path = label_to_path(metadata["jar_path"][0])
deps = metadata.get("all_deps", {})
log.info('Found Java Target %s', target.name)
elif target.script == "//build/android/gyp/aidl.py":