Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix jni prefix patch #26

Merged
merged 4 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/VERSION
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
WEBRTC_BUILD_VERSION=125.6422.0.0
WEBRTC_VERSION=125.6422.0
WEBRTC_READABLE_VERSION=M125.6422@{#0}
WEBRTC_COMMIT=9225e0498b0457d74cae2a8bb8aa93fbd0e88552
WEBRTC_COMMIT=46226b524cf2445bbb34e9c0ccfbcfd3bee7e4a9
70 changes: 57 additions & 13 deletions build/patches/jni_prefix.patch
Original file line number Diff line number Diff line change
Expand Up @@ -266,15 +266,27 @@ index be0ee6ca43b..8f90d4f6c33 100644
sb.append(f"""\
// This file was generated by
diff --git a/third_party/jni_zero/java_types.py b/third_party/jni_zero/java_types.py
index 06708f70ab3..65c1b29ee8d 100644
index 06708f70ab3..a4df349a492 100644
--- a/third_party/jni_zero/java_types.py
+++ b/third_party/jni_zero/java_types.py
@@ -129,7 +129,7 @@ class JavaClass:
return JavaClass(f'{prefix}/{self._fqn}', self)
@@ -62,6 +62,7 @@ class JavaClass:
_fqn: str
# This is only meaningful if make_prefix have been called on the original class.
_class_without_prefix: 'JavaClass' = None
+ _prefix: str = None

def __post_init__(self):
assert '.' not in self._fqn, f'{self._fqn} should have / and $, but not .'
@@ -126,10 +127,10 @@ class JavaClass:
if not prefix:
return self
prefix = prefix.replace('.', '/')
- return JavaClass(f'{prefix}/{self._fqn}', self)
+ return JavaClass(f'{prefix}/{self._fqn}', self, prefix)

def make_nested(self, name):
- return JavaClass(f'{self._fqn}${name}')
+ return JavaClass(f'{self.class_without_prefix._fqn}${name}')
+ return JavaClass(f'{self.class_without_prefix._fqn}${name}').make_prefixed(self._prefix)


@dataclasses.dataclass(frozen=True)
Expand Down Expand Up @@ -310,17 +322,49 @@ index 46d9619789e..4b7e721f716 100644
_name = get_path_info(_name, "name") + "_jni.h"
outputs += [ "$_jni_output_dir/$_name" ]
diff --git a/third_party/jni_zero/parse.py b/third_party/jni_zero/parse.py
index 33203b9848e..f627ed0f8ee 100644
index 33203b9848e..ffd92a2e135 100644
--- a/third_party/jni_zero/parse.py
+++ b/third_party/jni_zero/parse.py
@@ -382,7 +382,10 @@ def _do_parse(filename, *, package_prefix):

if package_prefix:
outer_class = outer_class.make_prefixed(package_prefix)
+ print("inner classes: ")
@@ -342,13 +342,15 @@ _IMPORT_REGEX = re.compile(r'^import\s+([^\s*]+);', flags=re.MULTILINE)
_IMPORT_CLASS_NAME_REGEX = re.compile(r'^(.*?)\.([A-Z].*)')


-def _parse_imports(contents):
+def _parse_imports(contents, package_prefix):
# Regex skips static imports as well as wildcard imports.
names = _IMPORT_REGEX.findall(contents)
for name in names:
m = _IMPORT_CLASS_NAME_REGEX.match(name)
if m:
package, class_name = m.groups()
+ if package.startswith('org.webrtc'):
+ package = package_prefix + '.org.webrtc'
yield java_types.JavaClass(
package.replace('.', '/') + '/' + class_name.replace('.', '$'))

@@ -385,7 +387,7 @@ def _do_parse(filename, *, package_prefix):
nested_classes = [c.make_prefixed(package_prefix) for c in nested_classes]
+ for c in nested_classes:
+ print(c.full_name_with_slashes, c.class_without_prefix.full_name_with_slashes)

type_resolver = java_types.TypeResolver(outer_class)
for java_class in _parse_imports(contents):
- for java_class in _parse_imports(contents):
+ for java_class in _parse_imports(contents, package_prefix):
type_resolver.add_import(java_class)
for java_class in nested_classes:
type_resolver.add_nested_class(java_class)
@@ -415,6 +417,7 @@ def _do_parse(filename, *, package_prefix):


def parse_java_file(filename, *, package_prefix=None):
+ print("parse_java_file: ", filename)
try:
return _do_parse(filename, package_prefix=package_prefix)
except ParseError as e:
@@ -431,6 +434,7 @@ _JAVAP_METHOD_REGEX = re.compile(


def parse_javap(filename, contents):
+ print("parse_javap: ", filename)
contents = _remove_generics(contents)
match = _JAVAP_CLASS_REGEX.search(contents)
if not match:

Loading