[Android] buildsystem: Use prebuilt libraries to propagage libvlc dependencies
Hugo Beauzée-Luyssen
git at videolan.org
Thu Jan 6 13:11:10 UTC 2022
vlc-android | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Mon Dec 6 11:42:46 2021 +0100| [7f4ac50cf91cd04446f1e035592701e026e3fe36] | committer: Nicolas Pomepuy
buildsystem: Use prebuilt libraries to propagage libvlc dependencies
> https://code.videolan.org/videolan/vlc-android/commit/7f4ac50cf91cd04446f1e035592701e026e3fe36
---
buildsystem/compile-libvlc.sh | 29 +++---------------------
buildsystem/compile-medialibrary.sh | 2 +-
buildsystem/compile.sh | 12 ----------
libvlc/jni/Android.mk | 44 ++++++++++++++++++++++++++++++++++++-
4 files changed, 47 insertions(+), 40 deletions(-)
diff --git a/buildsystem/compile-libvlc.sh b/buildsystem/compile-libvlc.sh
index 99f80b32d..0c96730fd 100755
--- a/buildsystem/compile-libvlc.sh
+++ b/buildsystem/compile-libvlc.sh
@@ -125,7 +125,6 @@ fi
VLC_BUILD_DIR="$(cd $VLC_SRC_DIR/; pwd)/build-android-${TARGET_TUPLE}"
VLC_OUT_PATH="$VLC_BUILD_DIR/ndk"
mkdir -p $VLC_OUT_PATH
-VLC_OUT_LDLIBS="-L$VLC_OUT_PATH/libs/${ANDROID_ABI} -lvlc"
#################
# NDK TOOLCHAIN #
@@ -659,29 +658,7 @@ echo -e "ndk-build vlc"
touch $VLC_OUT_PATH/dummy.cpp
-# This is ugly but it's better to use the linker from ndk-build that will use
-# the proper linkflags depending on ABI/API
-rm -rf $VLC_OUT_PATH/Android.mk
-cat << 'EOF' > $VLC_OUT_PATH/Android.mk
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-LOCAL_MODULE := libvlc
-LOCAL_SRC_FILES := libvlcjni-modules.c libvlcjni-symbols.c dummy.cpp
-LOCAL_LDFLAGS := -L$(VLC_CONTRIB)/lib
-LOCAL_LDLIBS := \
- $(VLC_MODULES) \
- $(VLC_BUILD_DIR)/lib/.libs/libvlc.a \
- $(VLC_BUILD_DIR)/src/.libs/libvlccore.a \
- $(VLC_BUILD_DIR)/compat/.libs/libcompat.a \
- $(VLC_CONTRIB_LDFLAGS) \
- -ldl -lz -lm -llog \
- -la52 -ljpeg \
- $(VLC_LDFLAGS)
-LOCAL_CXXFLAGS := -std=c++11
-include $(BUILD_SHARED_LIBRARY)
-EOF
-
-$NDK_BUILD -C $VLC_OUT_PATH/.. \
+$NDK_BUILD -C libvlc \
APP_STL="c++_shared" \
APP_CPPFLAGS="-frtti -fexceptions" \
VLC_SRC_DIR="$VLC_SRC_DIR" \
@@ -690,10 +667,10 @@ $NDK_BUILD -C $VLC_OUT_PATH/.. \
VLC_CONTRIB_LDFLAGS="$VLC_CONTRIB_LDFLAGS" \
VLC_MODULES="$VLC_MODULES" \
VLC_LDFLAGS="$VLC_LDFLAGS" \
- APP_BUILD_SCRIPT=ndk/Android.mk \
+ APP_BUILD_SCRIPT=jni/Android.mk \
APP_PLATFORM=android-${ANDROID_API} \
APP_ABI=${ANDROID_ABI} \
- NDK_PROJECT_PATH=ndk \
+ NDK_PROJECT_PATH=jni \
NDK_TOOLCHAIN_VERSION=clang \
NDK_DEBUG=${NDK_DEBUG}
avlc_checkfail "ndk-build libvlc failed"
diff --git a/buildsystem/compile-medialibrary.sh b/buildsystem/compile-medialibrary.sh
index 35a8d271d..d1de32993 100755
--- a/buildsystem/compile-medialibrary.sh
+++ b/buildsystem/compile-medialibrary.sh
@@ -168,7 +168,7 @@ avlc_checkfail "medialibrary: build failed"
cd ${SRC_DIR}
-MEDIALIBRARY_LDLIBS="$VLC_OUT_LDLIBS \
+MEDIALIBRARY_LDLIBS="-L$SRC_DIR/libvlc/jni/libs/${ANDROID_ABI}/ -lvlc \
-L$SRC_DIR/vlc/contrib/contrib-android-$TARGET_TUPLE/jpeg/.libs -ljpeg \
-L${NDK_LIB_DIR} -lc++abi"
diff --git a/buildsystem/compile.sh b/buildsystem/compile.sh
index 3fd05911e..ac02786dc 100755
--- a/buildsystem/compile.sh
+++ b/buildsystem/compile.sh
@@ -336,22 +336,10 @@ compile() {
AVLC_SOURCED=1 . buildsystem/compile-libvlc.sh
avlc_build
- $NDK_BUILD -C libvlc \
- VLC_SRC_DIR="$VLC_SRC_DIR" \
- VLC_BUILD_DIR="$VLC_BUILD_DIR" \
- VLC_OUT_LDLIBS="$VLC_OUT_LDLIBS" \
- APP_BUILD_SCRIPT=jni/Android.mk \
- APP_PLATFORM=android-${ANDROID_API} \
- APP_ABI=${ANDROID_ABI} \
- NDK_PROJECT_PATH=jni \
- NDK_TOOLCHAIN_VERSION=clang \
- NDK_DEBUG=${NDK_DEBUG}
-
if [ "$copy_tmp" = "--copy-tmp=libvlc" ];then
cp -r $VLC_OUT_PATH/libs/${ANDROID_ABI} libvlc/jni/libs/${ANDROID_ABI} build/tmp
fi
- cp -a $VLC_OUT_PATH/obj/local/${ANDROID_ABI}/*.so ${OUT_DBG_DIR}
cp -a ./libvlc/jni/obj/local/${ANDROID_ABI}/*.so ${OUT_DBG_DIR}
fi
diff --git a/libvlc/jni/Android.mk b/libvlc/jni/Android.mk
index 60c12081e..c1cd35eaa 100644
--- a/libvlc/jni/Android.mk
+++ b/libvlc/jni/Android.mk
@@ -1,5 +1,45 @@
LOCAL_PATH := $(call my-dir)
+# VLC's buildsystem resulting binaries
+include $(CLEAN_VARS)
+LOCAL_MODULE := libvlccompat
+LOCAL_SRC_FILES := $(VLC_BUILD_DIR)/compat/.libs/libcompat.a
+include $(PREBUILT_STATIC_LIBRARY)
+
+include $(CLEAN_VARS)
+LOCAL_MODULE := libvlccore
+LOCAL_SRC_FILES := $(VLC_BUILD_DIR)/src/.libs/libvlccore.a
+include $(PREBUILT_STATIC_LIBRARY)
+
+include $(CLEAN_VARS)
+LOCAL_MODULE := libvlc-native
+LOCAL_MODULE_FILENAME := libvlc
+LOCAL_SRC_FILES := $(VLC_BUILD_DIR)/lib/.libs/libvlc.a
+LOCAL_STATIC_LIBRARIES := libvlccore
+include $(PREBUILT_STATIC_LIBRARY)
+
+# libvlc static build with all its modules
+include $(CLEAR_VARS)
+LOCAL_MODULE := libvlc
+LOCAL_SRC_FILES := $(VLC_BUILD_DIR)/ndk/libvlcjni-modules.c \
+ $(VLC_BUILD_DIR)/ndk/libvlcjni-symbols.c \
+ $(VLC_BUILD_DIR)/ndk/dummy.cpp
+LOCAL_LDFLAGS := -L$(VLC_CONTRIB)/lib
+LOCAL_LDLIBS := \
+ $(VLC_MODULES) \
+ $(VLC_BUILD_DIR)/lib/.libs/libvlc.a \
+ $(VLC_BUILD_DIR)/src/.libs/libvlccore.a \
+ $(VLC_BUILD_DIR)/compat/.libs/libcompat.a \
+ $(VLC_CONTRIB_LDFLAGS) \
+ -ldl -lz -lm -llog \
+ -la52 -ljpeg \
+ $(VLC_LDFLAGS)
+LOCAL_CXXFLAGS := -std=c++11
+# This duplicates the libvlc* link flags, but it propagates the dependency
+# on the native build which is what we want overall
+LOCAL_STATIC_LIBRARIES := libvlccore libvlccompat libvlc-native
+include $(BUILD_SHARED_LIBRARY)
+
# libvlcjni
include $(CLEAR_VARS)
LOCAL_MODULE := libvlcjni
@@ -11,5 +51,7 @@ LOCAL_SRC_FILES += libvlcjni-dialog.c
LOCAL_SRC_FILES += std_logger.c
LOCAL_C_INCLUDES := $(VLC_SRC_DIR)/include $(VLC_BUILD_DIR)/include
LOCAL_CFLAGS := -std=c11
-LOCAL_LDLIBS := -llog $(VLC_OUT_LDLIBS)
+LOCAL_LDLIBS := -llog
+LOCAL_SHARED_LIBRARIES := libvlc
+
include $(BUILD_SHARED_LIBRARY)
More information about the Android
mailing list