From bcbacaa4281be0362b00a91b03d88578a0c8c2c4 Mon Sep 17 00:00:00 2001 From: davidliu Date: Tue, 11 Jun 2024 23:05:11 +0900 Subject: [PATCH] M125 Build and fixes (#25) * fix android webrtc version patch * jni_prefix.patch fixes * More fix android_webrtc_version.patch * temp remove jni_generator and rules since they no longer exist * Reimplement jni prefixing * Build m125 * Fix build * Fix build * Fix build --- build/VERSION | 8 +- build/android/Dockerfile | 1 + build/android_prefixed/Dockerfile | 1 + build/patches/android_webrtc_version.patch | 4 +- build/patches/jni_prefix.patch | 386 +++++++-------------- build/run.py | 6 +- 6 files changed, 132 insertions(+), 274 deletions(-) diff --git a/build/VERSION b/build/VERSION index fc0ed78..7b2ac60 100644 --- a/build/VERSION +++ b/build/VERSION @@ -1,4 +1,4 @@ -WEBRTC_BUILD_VERSION=114.5735.11.0 -WEBRTC_VERSION=114.5735.11 -WEBRTC_READABLE_VERSION=M114.5735@{#11} -WEBRTC_COMMIT=9316c0301071f7727fe35ee42cf824a575916f51 +WEBRTC_BUILD_VERSION=125.6422.0.0 +WEBRTC_VERSION=125.6422.0 +WEBRTC_READABLE_VERSION=M125.6422@{#0} +WEBRTC_COMMIT=9225e0498b0457d74cae2a8bb8aa93fbd0e88552 diff --git a/build/android/Dockerfile b/build/android/Dockerfile index dfe76fd..bf6ad1e 100644 --- a/build/android/Dockerfile +++ b/build/android/Dockerfile @@ -17,6 +17,7 @@ RUN /root/scripts/apt_install_x86_64.sh \ && sudo apt-get install -y build-essential ENV LC_ALL=C.UTF-8 RUN cd /root && python3 run.py build $PACKAGE_NAME --commit "${COMMIT_HASH}" +ENV PATH="${PATH}:/root/_source/${PACKAGE_NAME}/depot_tools" RUN cd /root && python3 run.py package $PACKAGE_NAME RUN mv $PACKAGE_DIR/webrtc.tar.gz / diff --git a/build/android_prefixed/Dockerfile b/build/android_prefixed/Dockerfile index c4127df..7d7031e 100644 --- a/build/android_prefixed/Dockerfile +++ b/build/android_prefixed/Dockerfile @@ -17,6 +17,7 @@ RUN /root/scripts/apt_install_x86_64.sh \ && sudo apt-get install -y build-essential ENV LC_ALL=C.UTF-8 RUN cd /root && python3 run.py build $PACKAGE_NAME --commit "${COMMIT_HASH}" +ENV PATH="${PATH}:/root/_source/${PACKAGE_NAME}/depot_tools" RUN cd /root && python3 run.py package $PACKAGE_NAME RUN mv $PACKAGE_DIR/webrtc.tar.gz / diff --git a/build/patches/android_webrtc_version.patch b/build/patches/android_webrtc_version.patch index 9183621..d975ac6 100644 --- a/build/patches/android_webrtc_version.patch +++ b/build/patches/android_webrtc_version.patch @@ -2,11 +2,11 @@ diff --git a/sdk/android/BUILD.gn b/sdk/android/BUILD.gn index 2d511e2eac..637ffa5168 100644 --- a/sdk/android/BUILD.gn +++ b/sdk/android/BUILD.gn -@@ -162,6 +162,7 @@ if (is_android) { +@@ -156,6 +156,7 @@ if (is_android) { sources = [ "api/org/webrtc/Predicate.java", "api/org/webrtc/RefCounted.java", + "api/org/webrtc/WebrtcBuildVersion.java", + "src/java/org/webrtc/ApplicationContextProvider.java", "src/java/org/webrtc/CalledByNative.java", "src/java/org/webrtc/CalledByNativeUnchecked.java", - "src/java/org/webrtc/Histogram.java", diff --git a/build/patches/jni_prefix.patch b/build/patches/jni_prefix.patch index 8c9b958..f3660fe 100644 --- a/build/patches/jni_prefix.patch +++ b/build/patches/jni_prefix.patch @@ -1,74 +1,3 @@ -diff --git a/modules/audio_device/android/audio_manager.cc b/modules/audio_device/android/audio_manager.cc -index 0b55496619..4fedd79167 100644 ---- a/modules/audio_device/android/audio_manager.cc -+++ b/modules/audio_device/android/audio_manager.cc -@@ -74,7 +74,7 @@ AudioManager::AudioManager() - {"nativeCacheAudioParameters", "(IIIZZZZZZZIIJ)V", - reinterpret_cast(&webrtc::AudioManager::CacheAudioParameters)}}; - j_native_registration_ = j_environment_->RegisterNatives( -- "org/webrtc/voiceengine/WebRtcAudioManager", native_methods, -+ "livekit/org/webrtc/voiceengine/WebRtcAudioManager", native_methods, - arraysize(native_methods)); - j_audio_manager_.reset( - new JavaAudioManager(j_native_registration_.get(), -diff --git a/modules/audio_device/android/audio_record_jni.cc b/modules/audio_device/android/audio_record_jni.cc -index 919eabb983..012891ca14 100644 ---- a/modules/audio_device/android/audio_record_jni.cc -+++ b/modules/audio_device/android/audio_record_jni.cc -@@ -102,7 +102,7 @@ AudioRecordJni::AudioRecordJni(AudioManager* audio_manager) - {"nativeDataIsRecorded", "(IJ)V", - reinterpret_cast(&webrtc::AudioRecordJni::DataIsRecorded)}}; - j_native_registration_ = j_environment_->RegisterNatives( -- "org/webrtc/voiceengine/WebRtcAudioRecord", native_methods, -+ "livekit/org/webrtc/voiceengine/WebRtcAudioRecord", native_methods, - arraysize(native_methods)); - j_audio_record_.reset( - new JavaAudioRecord(j_native_registration_.get(), -diff --git a/modules/audio_device/android/audio_track_jni.cc b/modules/audio_device/android/audio_track_jni.cc -index 5afa1ec252..5a3b1396c9 100644 ---- a/modules/audio_device/android/audio_track_jni.cc -+++ b/modules/audio_device/android/audio_track_jni.cc -@@ -112,7 +112,7 @@ AudioTrackJni::AudioTrackJni(AudioManager* audio_manager) - {"nativeGetPlayoutData", "(IJ)V", - reinterpret_cast(&webrtc::AudioTrackJni::GetPlayoutData)}}; - j_native_registration_ = j_environment_->RegisterNatives( -- "org/webrtc/voiceengine/WebRtcAudioTrack", native_methods, -+ "livekit/org/webrtc/voiceengine/WebRtcAudioTrack", native_methods, - arraysize(native_methods)); - j_audio_track_.reset( - new JavaAudioTrack(j_native_registration_.get(), -diff --git a/modules/audio_device/android/build_info.cc b/modules/audio_device/android/build_info.cc -index 916be8244e..f5164f1470 100644 ---- a/modules/audio_device/android/build_info.cc -+++ b/modules/audio_device/android/build_info.cc -@@ -17,7 +17,7 @@ namespace webrtc { - BuildInfo::BuildInfo() - : j_environment_(JVM::GetInstance()->environment()), - j_build_info_( -- JVM::GetInstance()->GetClass("org/webrtc/voiceengine/BuildInfo")) {} -+ JVM::GetInstance()->GetClass("livekit/org/webrtc/voiceengine/BuildInfo")) {} - - std::string BuildInfo::GetStringFromJava(const char* name) { - jmethodID id = j_build_info_.GetStaticMethodId(name, "()Ljava/lang/String;"); -diff --git a/modules/utility/source/jvm_android.cc b/modules/utility/source/jvm_android.cc -index ee9930bcaa..5c9e14b45c 100644 ---- a/modules/utility/source/jvm_android.cc -+++ b/modules/utility/source/jvm_android.cc -@@ -27,10 +27,10 @@ struct { - const char* name; - jclass clazz; - } loaded_classes[] = { -- {"org/webrtc/voiceengine/BuildInfo", nullptr}, -- {"org/webrtc/voiceengine/WebRtcAudioManager", nullptr}, -- {"org/webrtc/voiceengine/WebRtcAudioRecord", nullptr}, -- {"org/webrtc/voiceengine/WebRtcAudioTrack", nullptr}, -+ {"livekit/org/webrtc/voiceengine/BuildInfo", nullptr}, -+ {"livekit/org/webrtc/voiceengine/WebRtcAudioManager", nullptr}, -+ {"livekit/org/webrtc/voiceengine/WebRtcAudioRecord", nullptr}, -+ {"livekit/org/webrtc/voiceengine/WebRtcAudioTrack", nullptr}, - }; - - // Android's FindClass() is trickier than usual because the app-specific diff --git a/modules/video_coding/codecs/test/android_codec_factory_helper.cc b/modules/video_coding/codecs/test/android_codec_factory_helper.cc index d1be684cbb..812c3eb5dc 100644 --- a/modules/video_coding/codecs/test/android_codec_factory_helper.cc @@ -98,10 +27,10 @@ index d1be684cbb..812c3eb5dc 100644 env, env->NewObject(factory_class.obj(), factory_constructor, nullptr /* shared_context */)); diff --git a/sdk/android/BUILD.gn b/sdk/android/BUILD.gn -index 494b43f6d3..1a63c66558 100644 +index 7c05290942..7f9b9012d3 100644 --- a/sdk/android/BUILD.gn +++ b/sdk/android/BUILD.gn -@@ -1308,6 +1308,7 @@ if (current_os == "linux" || is_android) { +@@ -1333,6 +1333,7 @@ if (current_os == "linux" || is_android) { sources = [ "api/org/webrtc/Metrics.java" ] namespace = "webrtc::jni" jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" @@ -109,7 +38,7 @@ index 494b43f6d3..1a63c66558 100644 } # Generated JNI for public JNI targets, matching order of targets -@@ -1322,6 +1323,7 @@ if (current_os == "linux" || is_android) { +@@ -1347,6 +1348,7 @@ if (current_os == "linux" || is_android) { ] namespace = "webrtc::jni" jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" @@ -117,7 +46,7 @@ index 494b43f6d3..1a63c66558 100644 } generate_jni("generated_video_jni") { -@@ -1352,12 +1354,14 @@ if (current_os == "linux" || is_android) { +@@ -1377,12 +1379,14 @@ if (current_os == "linux" || is_android) { ] namespace = "webrtc::jni" jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" @@ -132,7 +61,7 @@ index 494b43f6d3..1a63c66558 100644 } generate_jni("generated_libvpx_vp8_jni") { -@@ -1368,6 +1372,7 @@ if (current_os == "linux" || is_android) { +@@ -1393,6 +1397,7 @@ if (current_os == "linux" || is_android) { namespace = "webrtc::jni" jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" @@ -140,7 +69,7 @@ index 494b43f6d3..1a63c66558 100644 } generate_jni("generated_libvpx_vp9_jni") { -@@ -1378,6 +1383,7 @@ if (current_os == "linux" || is_android) { +@@ -1403,6 +1408,7 @@ if (current_os == "linux" || is_android) { namespace = "webrtc::jni" jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" @@ -148,7 +77,7 @@ index 494b43f6d3..1a63c66558 100644 } generate_jni("generated_libaom_av1_encoder_jni") { -@@ -1385,6 +1391,7 @@ if (current_os == "linux" || is_android) { +@@ -1410,6 +1416,7 @@ if (current_os == "linux" || is_android) { namespace = "webrtc::jni" jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" @@ -156,7 +85,7 @@ index 494b43f6d3..1a63c66558 100644 } generate_jni("generated_dav1d_jni") { -@@ -1392,6 +1399,7 @@ if (current_os == "linux" || is_android) { +@@ -1417,6 +1424,7 @@ if (current_os == "linux" || is_android) { namespace = "webrtc::jni" jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" @@ -164,7 +93,7 @@ index 494b43f6d3..1a63c66558 100644 } generate_jni("generated_swcodecs_jni") { -@@ -1402,6 +1410,7 @@ if (current_os == "linux" || is_android) { +@@ -1427,6 +1435,7 @@ if (current_os == "linux" || is_android) { namespace = "webrtc::jni" jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" @@ -172,7 +101,7 @@ index 494b43f6d3..1a63c66558 100644 } generate_jni("generated_peerconnection_jni") { -@@ -1443,12 +1452,14 @@ if (current_os == "linux" || is_android) { +@@ -1469,12 +1478,14 @@ if (current_os == "linux" || is_android) { ] namespace = "webrtc::jni" jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" @@ -187,7 +116,7 @@ index 494b43f6d3..1a63c66558 100644 } generate_jni("generated_builtin_audio_codecs_jni") { -@@ -1458,6 +1469,7 @@ if (current_os == "linux" || is_android) { +@@ -1484,6 +1495,7 @@ if (current_os == "linux" || is_android) { ] namespace = "webrtc::jni" jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" @@ -195,7 +124,7 @@ index 494b43f6d3..1a63c66558 100644 } # Generated JNI for native API targets -@@ -1469,6 +1481,7 @@ if (current_os == "linux" || is_android) { +@@ -1496,6 +1508,7 @@ if (current_os == "linux" || is_android) { ] namespace = "webrtc::jni" jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" @@ -203,7 +132,7 @@ index 494b43f6d3..1a63c66558 100644 } # Generated JNI for internal targets. -@@ -1476,12 +1489,14 @@ if (current_os == "linux" || is_android) { +@@ -1503,12 +1516,14 @@ if (current_os == "linux" || is_android) { generate_jni("generated_logging_jni") { sources = [ "src/java/org/webrtc/JNILogging.java" ] jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" @@ -218,7 +147,7 @@ index 494b43f6d3..1a63c66558 100644 } generate_jni("generated_java_audio_device_module_native_jni") { -@@ -1491,6 +1506,7 @@ if (current_os == "linux" || is_android) { +@@ -1518,6 +1533,7 @@ if (current_os == "linux" || is_android) { ] namespace = "webrtc::jni" jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" @@ -227,10 +156,10 @@ index 494b43f6d3..1a63c66558 100644 } diff --git a/sdk/android/api/org/webrtc/PeerConnectionFactory.java b/sdk/android/api/org/webrtc/PeerConnectionFactory.java -index 1817d41beb..1c7bfbf480 100644 +index 762ad3b678..6cb2000788 100644 --- a/sdk/android/api/org/webrtc/PeerConnectionFactory.java +++ b/sdk/android/api/org/webrtc/PeerConnectionFactory.java -@@ -89,7 +89,7 @@ public class PeerConnectionFactory { +@@ -91,7 +91,7 @@ public class PeerConnectionFactory { private String fieldTrials = ""; private boolean enableInternalTracer; private NativeLibraryLoader nativeLibraryLoader = new NativeLibrary.DefaultLoader(); @@ -257,18 +186,19 @@ index 4e5781027a..5d17a87c50 100644 namespace webrtc { diff --git a/sdk/android/src/jni/simulcast_video_encoder.cc b/sdk/android/src/jni/simulcast_video_encoder.cc -index da31fbbfa5..a9385d8b6c 100644 +index 6874c1821b..1cf8cceda5 100644 --- a/sdk/android/src/jni/simulcast_video_encoder.cc +++ b/sdk/android/src/jni/simulcast_video_encoder.cc -@@ -15,7 +15,13 @@ extern "C" { +@@ -15,7 +15,14 @@ extern "C" { #endif // (VideoEncoderFactory primary, VideoEncoderFactory fallback, VideoCodecInfo info) --JNIEXPORT jlong JNICALL Java_org_webrtc_SimulcastVideoEncoder_nativeCreateEncoder(JNIEnv *env, jclass klass, jobject primary, jobject fallback, jobject info) { +-JNIEXPORT jlong JNICALL Java_org_webrtc_SimulcastVideoEncoder_nativeCreateEncoder(JNIEnv *env, jclass klass, jlong webrtcEnvRef, jobject primary, jobject fallback, jobject info) { +JNI_FUNCTION_DECLARATION(jlong, + SimulcastVideoEncoder_nativeCreateEncoder, + JNIEnv *env, + jclass klass, ++ jlong webrtcEnvRef, + jobject primary, + jobject fallback, + jobject info) { @@ -276,195 +206,121 @@ index da31fbbfa5..a9385d8b6c 100644 JavaParamRef info_ref(info); SdpVideoFormat format = VideoCodecInfoToSdpVideoFormat(env, info_ref); diff --git a/tools_webrtc/android/build_aar.py b/tools_webrtc/android/build_aar.py -index d910b39a7c..d0e970cfaa 100755 +index b442358283..5900e11935 100755 --- a/tools_webrtc/android/build_aar.py +++ b/tools_webrtc/android/build_aar.py -@@ -250,7 +250,7 @@ def BuildAar(archs, - Collect(aar_file, build_dir, arch, unstripped) +@@ -252,7 +252,7 @@ def BuildAar(archs, + Collect(aar_file, build_dir, arch, unstripped) - license_dir = os.path.dirname(os.path.realpath(output_file)) -- GenerateLicenses(license_dir, build_dir, archs) -+ #GenerateLicenses(license_dir, build_dir, archs) + license_dir = os.path.dirname(os.path.realpath(output_file)) +- GenerateLicenses(license_dir, build_dir, archs) ++ #GenerateLicenses(license_dir, build_dir, archs) - if not ext_build_dir: - shutil.rmtree(build_dir, True) + if not ext_build_dir: + shutil.rmtree(build_dir, True) diff --git a/webrtc.gni b/webrtc.gni -index 5e4a5d3c81..c9cb039432 100644 +index 969cdbd2be..16095bbd4f 100644 --- a/webrtc.gni +++ b/webrtc.gni -@@ -240,6 +240,11 @@ declare_args() { - # "warn": RTC_LOGs a message with LS_WARNING severity if the field trial +@@ -255,6 +255,10 @@ declare_args() { # hasn't been registered. rtc_strict_field_trials = "" -+ + + if (is_android) { + android_package_prefix = "livekit" + } + - } - - if (!build_with_mozilla) { -diff --git a/base/android/jni_generator/jni_generator.py b/base/android/jni_generator/jni_generator.py -index b739c86d1..028932256 100755 ---- a/base/android/jni_generator/jni_generator.py -+++ b/base/android/jni_generator/jni_generator.py -@@ -333,6 +333,7 @@ class JniParams(object): - def __init__(self, fully_qualified_class): - self._fully_qualified_class = 'L' + fully_qualified_class - self._package = '/'.join(fully_qualified_class.split('/')[:-1]) -+ print("JNI Params: %s, %s" % (self._fully_qualified_class, self._package)) - self._imports = [] - self._inner_classes = [] - self._implicit_imports = [] -@@ -392,6 +393,7 @@ class JniParams(object): - if param in pod_param_map: - return prefix + pod_param_map[param] - if '/' in param: -+ print("using param directly: %s" % param) - # Coming from javap, use the fully qualified param directly. - return prefix + 'L' + param + ';' - -@@ -414,6 +416,10 @@ class JniParams(object): - 'Inner class (%s) can not be imported ' - 'and used by JNI (%s). Please import the outer ' - 'class and use Outer.Inner instead.' % (qualified_name, param)) -+ print("import: %s" % qualified_name) -+ -+ if qualified_name.startswith('Lorg/webrtc'): -+ return prefix + qualified_name.replace('Lorg/webrtc', 'Llivekit/org/webrtc', 1) + ';' - return prefix + qualified_name + ';' - - # Is it an inner class from an outer class import? (e.g. referencing -@@ -424,6 +430,9 @@ class JniParams(object): - inner = components[-1] - for qualified_name in self._imports: - if qualified_name.endswith('/' + outer): -+ print("outer import: %s" % qualified_name) -+ if qualified_name.startswith('Lorg/webrtc'): -+ return (prefix + qualified_name.replace('Lorg/webrtc', 'Llivekit/org/webrtc', 1) + '$' + inner + ';') - return (prefix + qualified_name + '$' + inner + ';') - raise SyntaxError('Inner class (%s) can not be ' - 'used directly by JNI. Please import the outer ' -@@ -433,6 +442,7 @@ class JniParams(object): - - self._CheckImplicitImports(param) - -+ print("type not found: using: %s" % param) - # Type not found, falling back to same package as this class. - return (prefix + 'L' + self._package + '/' + param + ';') - -@@ -471,6 +481,7 @@ class JniParams(object): - items += [self.JavaToJni(param.datatype) for param in params] - items += [')'] - items += [self.JavaToJni(returns)] -+ print('"java sig: {}"'.format(''.join(items))) - return '"{}"'.format(''.join(items)) - - @staticmethod -@@ -480,6 +491,7 @@ class JniParams(object): - if index == -1: - prefix = 'descriptor: ' - index = signature_line.index(prefix) -+ print('"signature: %s"' % signature_line[index + len(prefix):]) - return '"%s"' % signature_line[index + len(prefix):] - - @staticmethod -@@ -573,6 +585,11 @@ def EscapeClassName(fully_qualified_class): - escaped = fully_qualified_class.replace('_', '_1') - return escaped.replace('/', '_').replace('$', '_00024') - -+def RemovePrefixClassName(class_name, package_prefix): -+ if package_prefix: -+ if class_name.startswith(package_prefix + "/"): -+ return class_name[len(package_prefix + "/"):] -+ return class_name - - def GetRegistrationFunctionName(fully_qualified_class): - """Returns the register name with a given class.""" -@@ -1121,7 +1138,7 @@ const char kClassPath_${JAVA_CLASS}[] = \ - class_getter = """\ - #ifndef ${JAVA_CLASS}_clazz_defined - #define ${JAVA_CLASS}_clazz_defined --inline jclass ${JAVA_CLASS}_clazz(JNIEnv* env) { -+inline jclass ${ORIGINAL_CLASS}_clazz(JNIEnv* env) { - return base::android::LazyGetClass(env, kClassPath_${JAVA_CLASS}, \ - ${MAYBE_SPLIT_NAME_ARG}&g_${JAVA_CLASS}_clazz); - } -@@ -1141,6 +1158,8 @@ JNI_REGISTRATION_EXPORT std::atomic g_${JAVA_CLASS}_clazz(nullptr); - values = { - 'JAVA_CLASS': - EscapeClassName(full_clazz), -+ 'ORIGINAL_CLASS': -+ EscapeClassName(RemovePrefixClassName(full_clazz, self.package_prefix)), - 'MAYBE_SPLIT_NAME_ARG': - (('"%s", ' % self.split_name) if self.split_name else '') - } -@@ -1461,6 +1480,7 @@ ${PROFILING_ENTERED_NATIVE}\ - return { - 'JAVA_CLASS_ONLY': java_class_only, - 'JAVA_CLASS': EscapeClassName(java_class), -+ 'ORIGINAL_CLASS': EscapeClassName(RemovePrefixClassName(java_class, self.options.package_prefix)), - 'RETURN_TYPE': return_type, - 'OPTIONAL_ERROR_RETURN': optional_error_return, - 'RETURN_DECLARATION': return_declaration, -@@ -1495,9 +1515,9 @@ ${FUNCTION_SIGNATURE} {""") - template = Template(""" - static std::atomic g_${JAVA_CLASS}_${METHOD_ID_VAR_NAME}(nullptr); - ${FUNCTION_HEADER} -- jclass clazz = ${JAVA_CLASS}_clazz(env); -+ jclass clazz = ${ORIGINAL_CLASS}_clazz(env); - CHECK_CLAZZ(env, ${FIRST_PARAM_IN_CALL}, -- ${JAVA_CLASS}_clazz(env)${OPTIONAL_ERROR_RETURN}); -+ ${ORIGINAL_CLASS}_clazz(env)${OPTIONAL_ERROR_RETURN}); - - jni_generator::JniJavaCallContext${CHECK_EXCEPTION} call_context; - call_context.Init< -@@ -1697,6 +1717,14 @@ See SampleForTests.java for more details. - build_utils.Touch(args.stamp) - sys.exit(0) - -+ if args.package_prefix: -+ print('Package Prefix found!', args.package_prefix) -+ else: -+ print('no package prefix') -+ -+ if args.enable_jni_multiplexing: -+ print('jni multiplexing') -+ - if output_names: - # Remove existing headers so that moving .java source files but not updating - # the corresponding C++ include will be a compile failure (otherwise -diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni -index a3eccbff7..96ceb74ad 100644 ---- a/build/config/android/rules.gni -+++ b/build/config/android/rules.gni -@@ -163,6 +163,7 @@ if (enable_java_templates) { - TESTONLY_AND_VISIBILITY + [ - "deps", - "public_deps", -+ "package_prefix", - ]) + # If different from "", symbols exported with RTC_OBJC_EXPORT will be prefixed + # with this string. + # See the definition of RTC_OBJC_TYPE_PREFIX in the code. +diff --git a/third_party/jni_zero/codegen/header_common.py b/third_party/jni_zero/codegen/header_common.py +index be0ee6ca43b..8f90d4f6c33 100644 +--- a/third_party/jni_zero/codegen/header_common.py ++++ b/third_party/jni_zero/codegen/header_common.py +@@ -13,7 +13,8 @@ def class_accessors(java_classes, module_name): + for java_class in java_classes: + if java_class in (java_types.OBJECT_CLASS, java_types.STRING_CLASS): + continue +- escaped_name = common.escape_class_name(java_class.full_name_with_slashes) ++ print("header accessor: ", java_class.class_without_prefix.full_name_with_slashes) ++ escaped_name = common.escape_class_name(java_class.class_without_prefix.full_name_with_slashes) + # #ifdef needed when multple .h files are #included that common classes. + sb.append(f"""\ + #ifndef {escaped_name}_clazz_defined +@@ -42,7 +43,7 @@ def class_accessor_expression(java_class): + if java_class == java_types.STRING_CLASS: + return 'jni_zero::g_string_class' + +- escaped_name = common.escape_class_name(java_class.full_name_with_slashes) ++ escaped_name = common.escape_class_name(java_class.class_without_prefix.full_name_with_slashes) + return f'{escaped_name}_clazz(env)' + + +@@ -52,7 +53,7 @@ def header_preamble(script_name, + user_includes, + header_guard=None): + if header_guard is None: +- header_guard = java_class.full_name_with_slashes.replace('/', '_') + '_JNI' ++ header_guard = java_class.class_without_prefix.full_name_with_slashes.replace('/', '_') + '_JNI' + sb = [] + 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 +--- 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) + + def make_nested(self, name): +- return JavaClass(f'{self._fqn}${name}') ++ return JavaClass(f'{self.class_without_prefix._fqn}${name}') + + + @dataclasses.dataclass(frozen=True) +diff --git a/third_party/jni_zero/jni_zero.gni b/third_party/jni_zero/jni_zero.gni +index 46d9619789e..4b7e721f716 100644 +--- a/third_party/jni_zero/jni_zero.gni ++++ b/third_party/jni_zero/jni_zero.gni +@@ -100,6 +100,7 @@ template("_invoke_jni_zero") { + # require_native_mocks: Enforce that any native calls using + # org.jni_zero.NativeMethods must have a mock set + # (optional). ++# package_prefix: package prefix to add to jni + # enable_native_mocks: Allow native calls using + # org.jni_zero.NativeMethods to be mocked in tests + # (optional). +@@ -267,6 +268,7 @@ template("generate_jni_impl") { + "deps", + "metadata", + "public_deps", ++ "package_prefix", + ]) if (!defined(public_deps)) { public_deps = [] -@@ -183,6 +184,13 @@ if (enable_java_templates) { - rebase_path(_jni_generator_include, _jni_output_dir), - ] - -+ if(defined(package_prefix)) { -+ args += [ -+ "--package_prefix", -+ package_prefix -+ ] +@@ -343,6 +345,10 @@ template("generate_jni_impl") { + args += [ "--split-name=${invoker.split_name}" ] + } + ++ if (defined(package_prefix)) { ++ args += [ "--package-prefix=${package_prefix}" ] + } + - if (defined(invoker.classes)) { - if (is_robolectric) { - not_needed(invoker, [ "jar_file" ]) -@@ -291,6 +299,7 @@ if (enable_java_templates) { - # sources: list of .java files to generate jni for - # namespace: Specify the namespace for the generated header file. - # deps, public_deps: As normal -+ # package_prefix: package prefix to add to jni - # - # Example - # # Target located in base/BUILD.gn. + foreach(_name, _input_names) { + _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 +--- 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: ") + 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): diff --git a/build/run.py b/build/run.py index 76712aa..4922261 100644 --- a/build/run.py +++ b/build/run.py @@ -794,9 +794,9 @@ def generate_version_info(webrtc_src_dir, webrtc_package_dir): (['.'], ''), (['build'], 'BUILD'), (['buildtools'], 'BUILDTOOLS'), - (['buildtools', 'third_party', 'libc++', 'trunk'], 'BUILDTOOLS_THIRD_PARTY_LIBCXX_TRUNK'), - (['buildtools', 'third_party', 'libc++abi', 'trunk'], 'BUILDTOOLS_THIRD_PARTY_LIBCXXABI_TRUNK'), - (['buildtools', 'third_party', 'libunwind', 'trunk'], 'BUILDTOOLS_THIRD_PARTY_LIBUNWIND_TRUNK'), + (['third_party', 'libc++', 'src'], 'THIRD_PARTY_LIBCXX_SRC'), + (['third_party', 'libc++abi', 'src'], 'THIRD_PARTY_LIBCXXABI_SRC'), + (['third_party', 'libunwind', 'src'], 'THIRD_PARTY_LIBUNWIND_SRC'), (['third_party'], 'THIRD_PARTY'), (['tools'], 'TOOLS'), ]