Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit b525daa

Browse files
committed
Bug 1540820 - Don't write generated JNI wrappers for every Java-level change. r=agi
This was fallout from Bug 1509572, which moved the "invalidation smarts" to Gradle. Unfortunately, those smarts are not smart enough: there are many situations where the annotations might change (a new method) but where they don't actually change (a new method that isn't annotated with @JNITarget). Since we don't want to spend the time to make the "invalidation smarts" truly smart, we need to bring back this little bit of Bug 1509572. While we're here, we ensure that there is only one JNI wrapper generation task for GeckoView and Fennec, regardless of variant. Right now, those are named like: - geckoview:generateJNIWrappersForGeneratedWithGeckoBinariesDebug - app:generateJNIWrappersForFennecWithoutGeckoBinariesDebug See https://bugzilla.mozilla.org/show_bug.cgi?id=1509539#c1 for some discussion of these JNI wrapper generation tasks. Differential Revision: https://phabricator.services.mozilla.com/D26427 --HG-- extra : moz-landing-system : lando
1 parent 44fd876 commit b525daa

3 files changed

Lines changed: 21 additions & 2 deletions

File tree

mobile/android/annotations/src/main/java/org/mozilla/gecko/annotationProcessors/AnnotationProcessor.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,21 @@ private static String getHeaderGuardName(final String name) {
170170
private static int writeOutputFile(final String name, final StringBuilder content) {
171171
final byte[] contentBytes = content.toString().getBytes(StandardCharsets.UTF_8);
172172

173+
try {
174+
final byte[] existingBytes = Files.readAllBytes(new File(name).toPath());
175+
if (Arrays.equals(contentBytes, existingBytes)) {
176+
return 0;
177+
}
178+
} catch (FileNotFoundException e) {
179+
// Pass.
180+
} catch (NoSuchFileException e) {
181+
// Pass.
182+
} catch (IOException e) {
183+
System.err.println("Unable to read " + name + ". Perhaps a permissions issue?");
184+
e.printStackTrace(System.err);
185+
return 1;
186+
}
187+
173188
try (FileOutputStream outStream = new FileOutputStream(name)) {
174189
outStream.write(contentBytes);
175190
} catch (IOException e) {

mobile/android/app/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,9 @@ android.applicationVariants.all { variant ->
382382
}
383383

384384
android.applicationVariants.all { variant ->
385-
configureApplicationVariantWithJNIWrappers(variant, "Fennec")
385+
if (variant.name == mozconfig.substs.GRADLE_ANDROID_APP_VARIANT_NAME) {
386+
configureApplicationVariantWithJNIWrappers(variant, "Fennec")
387+
}
386388
}
387389

388390
if (gradle.startParameter.taskNames.any { it.endsWith('UnitTest') }) {

mobile/android/geckoview/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,9 @@ android.libraryVariants.all { variant ->
309309
}
310310

311311
android.libraryVariants.all { variant ->
312-
configureLibraryVariantWithJNIWrappers(variant, "Generated")
312+
if (variant.name == mozconfig.substs.GRADLE_ANDROID_GECKOVIEW_VARIANT_NAME) {
313+
configureLibraryVariantWithJNIWrappers(variant, "Generated")
314+
}
313315
}
314316

315317
apply plugin: 'maven-publish'

0 commit comments

Comments
 (0)