[Android] Multi-arch LibVLC & Medialibrary

Geoffrey Métais git at videolan.org
Fri Dec 7 14:11:06 CET 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Nov 26 17:34:29 2018 +0100| [8f6cc0f058bfefc7a3f682f9c3c3b7d6cd4f5fb9] | committer: Geoffrey Métais

Multi-arch LibVLC & Medialibrary

> https://code.videolan.org/videolan/vlc-android/commit/8f6cc0f058bfefc7a3f682f9c3c3b7d6cd4f5fb9
---

 compile-libvlc.sh         |  3 +--
 compile.sh                | 56 ++++++++++++++++++++++++++++++++---------------
 libvlc/build.gradle       | 52 +------------------------------------------
 medialibrary/build.gradle | 10 +++++++++
 4 files changed, 50 insertions(+), 71 deletions(-)

diff --git a/compile-libvlc.sh b/compile-libvlc.sh
index 9edab8f60..54a36a404 100755
--- a/compile-libvlc.sh
+++ b/compile-libvlc.sh
@@ -501,10 +501,9 @@ $ANDROID_NDK/ndk-build$OSCMD -C libvlc \
 
 checkfail "ndk-build libvlc failed"
 
-echo "Dumping dbg symbols info ${OUT_DBG_DIR}"
-
 cd ${SRC_DIR}
 OUT_DBG_DIR=.dbg/${ANDROID_ABI}
+echo "Dumping dbg symbols info ${OUT_DBG_DIR}"
 
 mkdir -p $OUT_DBG_DIR
 cp -a libvlc/jni/obj/local/${ANDROID_ABI}/*.so ${OUT_DBG_DIR}
diff --git a/compile.sh b/compile.sh
index 9ad91ca0c..70aeed774 100755
--- a/compile.sh
+++ b/compile.sh
@@ -102,6 +102,8 @@ elif [ "$ANDROID_ABI" = "x86" ]; then
     GRADLE_ABI="x86"
 elif [ "$ANDROID_ABI" = "x86_64" ]; then
     GRADLE_ABI="x86_64"
+elif [ "$ANDROID_ABI" = "all" ]; then
+    GRADLE_ABI="all"
 else
     diagnostic "Invalid arch specified: '$ANDROID_ABI'."
     diagnostic "Try --help for more information"
@@ -260,24 +262,42 @@ cd ..
 ############
 
 diagnostic "Configuring"
-OPTS="-a ${ANDROID_ABI}"
-if [ "$RELEASE" = 1 ]; then
-    OPTS="$OPTS release"
-fi
-if [ "$CHROME_OS" = 1 ]; then
-    OPTS="$OPTS -c"
-fi
-if [ "$ASAN" = 1 ]; then
-    OPTS="$OPTS --asan"
-fi
+compile() {
+    OPTS="-a $1"
+    if [ "$RELEASE" = 1 ]; then
+        OPTS="$OPTS release"
+    fi
+    if [ "$CHROME_OS" = 1 ]; then
+        OPTS="$OPTS -c"
+    fi
+    if [ "$ASAN" = 1 ]; then
+        OPTS="$OPTS --asan"
+    fi
 
-# Build LibVLC if asked for it, or needed by medialibrary
-if [ "$BUILD_MEDIALIB" != 1 -o ! -d "libvlc/jni/libs/$ANDROID_ABI" ]; then
-    GRADLE_ABI=$GRADLE_ABI ./compile-libvlc.sh $OPTS
-fi
+    # Build LibVLC if asked for it, or needed by medialibrary
+    if [ "$BUILD_MEDIALIB" != 1 -o ! -d "libvlc/jni/libs/$ANDROID_ABI" ]; then
+        ./compile-libvlc.sh $OPTS
+    fi
 
-if [ "$NO_ML" != 1 ]; then
-    GRADLE_ABI=$GRADLE_ABI ./compile-medialibrary.sh $OPTS
+    if [ "$NO_ML" != 1 ]; then
+        ./compile-medialibrary.sh $OPTS
+    fi
+}
+if [ "$ANDROID_ABI" = "all" ]; then
+    if [ -d libvlc/tmp ]; then
+        rm -rf libvlc/tmp
+    fi
+    mkdir libvlc/tmp
+    compile armeabi-v7a
+    mv libvlc/jni/libs/armeabi-v7a libvlc/tmp
+    compile arm64-v8a
+    mv libvlc/jni/libs/arm64-v8a libvlc/tmp
+    compile x86
+    mv libvlc/jni/libs/x86 libvlc/tmp
+    compile x86_64
+    mv libvlc/tmp/* libvlc/jni/libs
+else
+    compile $ANDROID_ABI
 fi
 
 ##################
@@ -294,11 +314,11 @@ if [ "$CHROME_OS" = 1 ]; then
     PLATFORM="Chrome"
 fi
 if [ "$BUILD_LIBVLC" = 1 ];then
-    ./gradlew -p libvlc assemble${BUILDTYPE}
+    GRADLE_ABI=$GRADLE_ABI ./gradlew -p libvlc assemble${BUILDTYPE}
     RUN=0
     CHROME_OS=0
 elif [ "$BUILD_MEDIALIB" = 1 ]; then
-    ./gradlew -p medialibrary assemble${BUILDTYPE}
+    GRADLE_ABI=$GRADLE_ABI ./gradlew -p medialibrary assemble${BUILDTYPE}
     RUN=0
     CHROME_OS=0
 else
diff --git a/libvlc/build.gradle b/libvlc/build.gradle
index 6bd0d190d..fd64983bc 100644
--- a/libvlc/build.gradle
+++ b/libvlc/build.gradle
@@ -41,65 +41,15 @@ android {
 
     // Make per-variant version code
     libraryVariants.all { variant ->
-        def vlcVersion = rootProject.ext.versionName
         //Custom APK name
         variant.outputs.each { output ->
             if (output.outputFileName != null && output.outputFileName.endsWith('.aar')) {
-                output.outputFileName = "libvlc-${vlcVersion}.aar"
+                output.outputFileName = "libvlc-${abi}-${library_version}.aar"
             }
         }
     }
 }
 
-/*
- * Include GDB files into apk
- */
-//afterEvaluate {
-//    Sync packageTask = project.getTasks().findByName("packageReleaseJniLibs")
-//    packageTask.include(['**/gdbserver', '**/gdb.setup'])
-//}
-
-//class BuildNative extends Exec {}
-//
-//tasks.withType(BuildNative){
-//    /*
-//    Properties set for Android Studio own shell.
-//    when you run gradlew from cli, OS shell env variables will be used
-//
-//    To be able to build from Android Studio, you have to set ndk.dir & sdk.dir
-//    properties in local.properties in the root folder, like this (for example):
-//    sdk.dir=/home/<username>/SDK/android-sdk-linux
-//    ndk.dir=/home/<username>/SDK/android-ndk-r10b
-//     */
-//    if (System.getenv('ANDROID_SDK') == null || System.getenv('ANDROID_NDK') == null) {
-//        Properties properties = new Properties()
-//        properties.load(project.rootProject.file('local.properties').newDataInputStream())
-//        environment 'ANDROID_NDK', properties.getProperty('ndk.dir')
-//        environment 'ANDROID_SDK', properties.getProperty('sdk.dir')
-//    }
-//    workingDir '..'
-//    commandLine './compile-libvlc.sh'
-//}
-//
-//task buildDebugARMv7(type:BuildNative) {
-//    args('-a', "armeabi-v7a")
-//}
-//task buildDebugARM64(type:BuildNative) {
-//    args('-a', "arm64-v8a")
-//}
-//task buildDebugx86(type:BuildNative) {
-//    args('-a', "x86")
-//}
-//task buildDebugx86_64(type:BuildNative) {
-//    args('-a', "x86_64")
-//}
-//task buildDebugMIPS(type:BuildNative) {
-//    args('-a', "mips")
-//}
-//task buildDebugMIPS64(type:BuildNative) {
-//    args('-a', "mips64")
-//}
-//
 task generateSources (type: Jar) {
     classifier = 'sources'
     from android.sourceSets.main.java.srcDirs
diff --git a/medialibrary/build.gradle b/medialibrary/build.gradle
index d518198b3..4c0836b64 100644
--- a/medialibrary/build.gradle
+++ b/medialibrary/build.gradle
@@ -71,6 +71,16 @@ android {
     dataBinding {
         enabled = true
     }
+
+    // Make per-variant version code
+    libraryVariants.all { variant ->
+        //Custom APK name
+        variant.outputs.each { output ->
+            if (output.outputFileName != null && output.outputFileName.endsWith('.aar')) {
+                output.outputFileName = "medialibrary-${abi}-${library_version}.aar"
+            }
+        }
+    }
 }
 
 task generateSources (type: Jar) {



More information about the Android mailing list