From ce4d35e75755ca7484e228aff62a90f550b02c13 Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Wed, 25 Oct 2023 06:44:39 -0700 Subject: [PATCH] Fix missing native dependencies on packaged artifacts (#2748) Summary: ## Motivation (required) Latest versions of Fresco have missing .so files due to a race condition on Gradle tasks. I'm imposing a task dependencies on `ndk_build_*` steps and `preBuild` steps to prevent this. Fixes https://github.com/facebook/fresco/issues/2722 Fixes https://github.com/facebook/fresco/issues/2747 ## Test Plan (required) I've tested this against `./gradlew publishToMavenLocal` upon clean build. Here the output: ``` $ unzip -l ~/.m2/repository/com/facebook/fresco/nativeimagetranscoder/3.1.1/nativeimagetranscoder-3.1.1.aar Archive: /Users/ncor/.m2/repository/com/facebook/fresco/nativeimagetranscoder/3.1.1/nativeimagetranscoder-3.1.1.aar Length Date Time Name --------- ---------- ----- ---- 7297 02-01-1980 00:00 R.txt 216 02-01-1980 00:00 AndroidManifest.xml 6034 02-01-1980 00:00 classes.jar 121 02-01-1980 00:00 META-INF/com/android/build/gradle/aar-metadata.properties 0 02-01-1980 00:00 jni/ 0 02-01-1980 00:00 jni/arm64-v8a/ 475392 02-01-1980 00:00 jni/arm64-v8a/libnative-imagetranscoder.so 0 02-01-1980 00:00 jni/armeabi-v7a/ 271736 02-01-1980 00:00 jni/armeabi-v7a/libnative-imagetranscoder.so 0 02-01-1980 00:00 jni/x86/ 557648 02-01-1980 00:00 jni/x86/libnative-imagetranscoder.so 0 02-01-1980 00:00 jni/x86_64/ 621000 02-01-1980 00:00 jni/x86_64/libnative-imagetranscoder.so --------- ------- 1939444 13 files ``` Pull Request resolved: https://github.com/facebook/fresco/pull/2748 Reviewed By: passy Differential Revision: D50641344 Pulled By: cortinico fbshipit-source-id: c518b4cf4e418dcec1ac30a78c03a649d5c66c13 --- animated-gif/build.gradle | 1 + imagepipeline-native/build.gradle | 5 +++++ native-filters/build.gradle | 4 ++++ native-imagetranscoder/build.gradle | 5 ++++- static-webp/build.gradle | 6 ++++++ 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/animated-gif/build.gradle b/animated-gif/build.gradle index 8bcd739428..1895cfe018 100644 --- a/animated-gif/build.gradle +++ b/animated-gif/build.gradle @@ -60,6 +60,7 @@ android { } } ndkLibs.each { lib -> makeNdkTasks lib[0], lib[1] } + preBuild.dependsOn("ndk_build_gifimage") } apply plugin: "com.vanniktech.maven.publish" diff --git a/imagepipeline-native/build.gradle b/imagepipeline-native/build.gradle index 61c78c6804..5e0a6d2fa1 100644 --- a/imagepipeline-native/build.gradle +++ b/imagepipeline-native/build.gradle @@ -71,6 +71,11 @@ android { } } ndkLibs.each { lib -> makeNdkTasks lib[0], lib[1] } + preBuild.dependsOn( + "ndk_build_bitmaps", + "ndk_build_imagepipeline", + "ndk_build_memchunk" + ) } apply plugin: "com.vanniktech.maven.publish" diff --git a/native-filters/build.gradle b/native-filters/build.gradle index 0a1c078a27..01d3877361 100644 --- a/native-filters/build.gradle +++ b/native-filters/build.gradle @@ -75,6 +75,10 @@ android { abortOnError false } ndkLibs.each { lib -> makeNdkTasks lib[0], lib[1] } + preBuild.dependsOn( + "ndk_build_filters", + "ndk_build_native-filters" + ) } apply plugin: "com.vanniktech.maven.publish" diff --git a/native-imagetranscoder/build.gradle b/native-imagetranscoder/build.gradle index f09527b411..61bdc75726 100644 --- a/native-imagetranscoder/build.gradle +++ b/native-imagetranscoder/build.gradle @@ -48,7 +48,6 @@ task fetchNativeDeps(dependsOn: [copyLibjpeg]) { } android { - def ndkLibs = [ ['native-imagetranscoder', [copyLibjpeg]]] @@ -76,6 +75,10 @@ android { abortOnError false } ndkLibs.each { lib -> makeNdkTasks lib[0], lib[1] } + preBuild.dependsOn( + "ndk_build_native-imagetranscoder", + "copyLibjpeg" + ) } apply plugin: "com.vanniktech.maven.publish" diff --git a/static-webp/build.gradle b/static-webp/build.gradle index c0d867b295..f2478a0055 100644 --- a/static-webp/build.gradle +++ b/static-webp/build.gradle @@ -57,6 +57,12 @@ android { abortOnError false } ndkLibs.each { lib -> makeNdkTasks lib[0], lib[1] } + preBuild.dependsOn( + "ndk_build_static-webp", + "copyLibjpeg", + "copyLibpng", + "copyLibwebp" + ) } apply plugin: "com.vanniktech.maven.publish"