From b8fde5a13d60a98f6328a4d39a814a33db2e3fa5 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 11 Mar 2016 17:10:48 +0100 Subject: [PATCH] Use linphone-cmake-builder to compile the SDK. --- Makefile | 534 ------------------ README | 93 +-- liblinphone_tester/Makefile | 56 +- .../src/org/linphone/tester/Tester.java | 15 +- .../org/linphone/tester/WrapperTester.java | 3 +- prepare.py | 498 ++++++++++++++++ .../externals/build/ffmpeg/CMakeLists.txt | 43 ++ tests/ant.properties | 2 +- .../linphone/test/LinphoneTestManager.java | 2 +- 9 files changed, 619 insertions(+), 627 deletions(-) delete mode 100644 Makefile create mode 100755 prepare.py create mode 100644 submodules/externals/build/ffmpeg/CMakeLists.txt diff --git a/Makefile b/Makefile deleted file mode 100644 index be3caa4f8..000000000 --- a/Makefile +++ /dev/null @@ -1,534 +0,0 @@ -NDK_PATH=$(shell dirname `which ndk-build`) -NDK_MAJOR_VERSION=$(shell cat $(NDK_PATH)/RELEASE.TXT | sed "s/r\([0-9]\{1,2\}\).*/\1/") -SDK_PATH=$(shell dirname `which android`) -SDK_PLATFORM_TOOLS_PATH=$(shell dirname `which adb`) -ARM_COMPILER_PATH=`find "$(NDK_PATH)" -name "arm-linux-androideabi-gcc-4*" -print | tail -1` -ARM_TOOLCHAIN_PATH=$(shell dirname $(ARM_COMPILER_PATH))/arm-linux-androideabi- -X86_COMPILER_PATH=`find "$(NDK_PATH)" -name "i686-linux-android-gcc-4*" -print | tail -1` -X86_TOOLCHAIN_PATH=$(shell dirname $(X86_COMPILER_PATH))/i686-linux-android- -NUMCPUS=$(shell grep -c '^processor' /proc/cpuinfo 2>/dev/null || echo "4" ) -TOPDIR=$(shell pwd) -LIBLINPHONE_VERSION=$(shell cd submodules/linphone && git describe --always) -LINPHONE_ANDROID_DEBUG_VERSION=$(shell git describe --always) -BELLESIP_VERSION_SCRIPT:=cat submodules/belle-sip/configure.ac | grep "AC_INIT(" | sed -e "s/.*belle-sip\]//" | sed -e "s/].*//" | sed -e "s/.*\[//" -BELLESIP_VERSION=$(shell $(BELLESIP_VERSION_SCRIPT)) -ANDROID_MOST_RECENT_TARGET=$(shell android list target -c | grep -E 'android-[0-9]+' | tail -n1) -#We force target 19 because 21 creates binaries incompatible with older versions due to rand() function no longer inline (congrats to Google's developers) -NDKBUILD_TARGET=android-19 -#The NDK target used to compile external third parties (ffmpeg, x264) -EXTERNAL_MAKE_TARGET=14 -ARM_SYSROOT=${NDK_PATH}/platforms/android-$(EXTERNAL_MAKE_TARGET)/arch-arm -X86_SYSROOT=${NDK_PATH}/platforms/android-$(EXTERNAL_MAKE_TARGET)/arch-x86 -SQLITE_VERSION=3071700 -SQLITE_BASENAME=sqlite-amalgamation-$(SQLITE_VERSION) -SQLITE_URL=http://www.sqlite.org/2013/$(SQLITE_BASENAME).zip -ENABLE_GPL_THIRD_PARTIES=1 -#override CC variable to disable compiler specific FLAGS in configure using the system compiler instead of the android one -CC= -PACKAGE_NAME=$(shell sed -nE 's||\1|p' custom_rules.xml) -#default options, can be overidden using make OPTION=value . - -ifeq ($(ENABLE_GPL_THIRD_PARTIES),1) -BUILD_G729=1 -else -#x264 and g729 requires additional licensing agreements. -BUILD_X264=0 -BUILD_G729=0 -endif - -NDK_DEBUG=0 -BUILD_VIDEO=1 -BUILD_OPENH264=1 -BUILD_NON_FREE_CODECS=1 -ENABLE_OPENH264_DECODER=1 -BUILD_UPNP=1 -BUILD_AMRNB=full # 0, light or full -BUILD_AMRWB=0 # Has text relocation issue, don't use when targetting API 23 for now -BUILD_ZRTP=1 -BUILD_SILK=1 -BUILD_TUNNEL=0 -BUILD_WEBRTC_AECM=1 -BUILD_OPUS=1 -BUILD_MATROSKA=1 -BUILD_WEBRTC_ISAC=1 -BUILD_FOR_X86=1 -BUILD_FOR_ARM=1 -USE_JAVAH=1 -BUILD_TLS=1 -BUILD_SQLITE=1 -BUILD_CONTACT_HEADER=0 -BUILD_RTP_MAP=0 -BUILD_DONT_CHECK_HEADERS_IN_MESSAGE=0 -BUILD_ILBC=1 -BUILD_CODEC2=0 -BUILD_BCTOOLBOX_MBEDTLS=0 -LIBLINPHONE_EXTENDED_SRC_FILES= -LIBLINPHONE_EXTENDED_C_INCLUDES= -LIBLINPHONE_EXTENDED_CFLAGS= -APP_STL=stlport_static -ANT_SILENT=$(shell ant -h | grep -q -- -S && echo 1 || echo 0) - -# Checks -CHECK_MSG=$(shell ./check_tools.sh) - -ifneq ($(CHECK_MSG),) - $(error Some tools are missing.) -else - ifeq ($(BUILD_OPENH264),1) - ifneq ($(shell echo $(NDK_MAJOR_VERSION)\>=10 | bc),1) -$(error ndk version [$(NDK_MAJOR_VERSION)] not compatible with openh264.) - endif - endif - include check_tools.mk -endif - -OPENSSL_DIR=$(shell openssl version -d | sed "s/OPENSSLDIR: \"\(.*\)\"/\1/") -ifneq ($(shell ls $(OPENSSL_DIR)/certs),) - HTTPS_CA_DIR=$(OPENSSL_DIR)/certs -else - HTTPS_CA_DIR=$(OPENSSL_DIR) -endif - -ifeq ($(ANT_SILENT), 1) - ANT=ant -e -S -else - ANT=ant -e -endif - -# Temporary check: in case of MediastreamActivity.java file existing while it should not anymore, print an error message -# and abort build since otherwise java compilation will fail. -ifneq ($(shell ls ./submodules/linphone/mediastreamer2/java/src/org/linphone/mediastream/MediastreamerActivity.java 2>/dev/null),) -$(error ./submodules/linphone/mediastreamer2/java/src/org/linphone/mediastream/MediastreamerActivity.java found: please either remove it or move it to MediastreamActivity.java.ignored before continuing.) -endif - -ifeq ($(BUILD_NON_FREE_CODECS), 0) -BUILD_OPENH264=0 -ENABLE_OPENH264_DECODER=0 -BUILD_AMRNB=0 -BUILD_AMRWB=0 -BUILD_G729=0 -BUILD_X264=0 -endif - -all: update-project generate-apk -ifeq ($(ENABLE_GPL_THIRD_PARTIES),1) - @echo "***************************************************************************" - @echo "***** CAUTION, this liblinphone SDK is built using 3rd party GPL code *****" - @echo "***** Even if you acquired a proprietary license from Belledonne *****" - @echo "***** Communications, this SDK is GPL and GPL only. *****" - @echo "***** To disable 3rd party gpl code, please use: *****" - @echo "***** $$ make ENABLE_GPL_THIRD_PARTIES=0 *****" - @echo "***************************************************************************" -else - @echo - @echo "*****************************************************************" - @echo "***** Linphone SDK without 3rd party GPL software *****" - @echo "***** If you acquired a proprietary license from Belledonne *****" - @echo "***** Communications, this SDK can be used to create *****" - @echo "***** a proprietary linphone-based application. *****" - @echo "*****************************************************************" -endif - -install: install-apk run-linphone - - -#ffmpeg -ifeq ($(BUILD_VIDEO),1) -BUILD_FFMPEG_DEPS=$(FFMPEG_SRC_DIR)/non_versioned_soname_patch_applied.txt $(FFMPEG_BUILD_DIR)/arm/libffmpeg-linphone-arm.so -ifeq ($(BUILD_FOR_X86), 1) - BUILD_FFMPEG_DEPS+=$(FFMPEG_BUILD_DIR)/x86/libffmpeg-linphone-x86.so -endif -endif -FFMPEG_SRC_DIR=$(TOPDIR)/submodules/externals/ffmpeg -FFMPEG_BUILD_DIR=$(TOPDIR)/submodules/externals/build/ffmpeg -FFMPEG_CONFIGURE_OPTIONS=--target-os=linux --enable-cross-compile --enable-runtime-cpudetect \ - --disable-everything --disable-doc --disable-ffplay --disable-ffmpeg --disable-ffprobe --disable-ffserver \ - --disable-avdevice --disable-avfilter --disable-avformat --disable-swresample --disable-network \ - --enable-decoder=mjpeg --enable-encoder=mjpeg --enable-decoder=mpeg4 --enable-encoder=mpeg4 --enable-decoder=h264 \ - --enable-decoder=h263p --enable-encoder=h263p --enable-decoder=h263 --enable-encoder=h263 --extra-cflags="-w" \ - --disable-static --enable-shared --disable-symver -FFMPEG_ARM_CONFIGURE_OPTIONS=--build-suffix=-linphone-arm --arch=arm --sysroot=$(ARM_SYSROOT) --cross-prefix=$(ARM_TOOLCHAIN_PATH) --enable-pic -FFMPEG_X86_CONFIGURE_OPTIONS=--build-suffix=-linphone-x86 --arch=x86 --sysroot=$(X86_SYSROOT) --cross-prefix=$(X86_TOOLCHAIN_PATH) --disable-mmx --disable-sse2 --disable-ssse3 --extra-cflags='-O3' - -$(FFMPEG_SRC_DIR)/non_versioned_soname_patch_applied.txt: - @patch -p0 < $(TOPDIR)/patches/ffmpeg_non_versioned_soname.patch - touch $@ - -$(FFMPEG_BUILD_DIR)/arm/config.h: - mkdir -p $(FFMPEG_BUILD_DIR)/arm && \ - cd $(FFMPEG_BUILD_DIR)/arm && \ - $(FFMPEG_SRC_DIR)/configure $(FFMPEG_CONFIGURE_OPTIONS) $(FFMPEG_ARM_CONFIGURE_OPTIONS) - sed -i.bak 's/#define HAVE_SYSCTL 1/#define HAVE_SYSCTL 0/g' $(FFMPEG_BUILD_DIR)/arm/config.h - sed -i.bak 's/#define HAVE_GETHRTIME 1/#define HAVE_GETHRTIME 0/g' $(FFMPEG_BUILD_DIR)/arm/config.h - -$(FFMPEG_BUILD_DIR)/arm/libavcodec/libavcodec-linphone-arm.so: $(FFMPEG_BUILD_DIR)/arm/config.h - cd $(FFMPEG_BUILD_DIR)/arm && \ - make -j${NUMCPUS} \ - || ( echo "Build of ffmpeg for arm failed." ; exit 1 ) - -$(FFMPEG_BUILD_DIR)/arm/libffmpeg-linphone-arm.so: $(FFMPEG_BUILD_DIR)/arm/libavcodec/libavcodec-linphone-arm.so - cd $(FFMPEG_BUILD_DIR)/arm && \ - rm libavcodec/log2_tab.o && \ - $(ARM_TOOLCHAIN_PATH)gcc -lm -lz --sysroot=$(ARM_SYSROOT) -Wl,-soname,libffmpeg-linphone-arm.so,--no-undefined -Wl,-z,noexecstack -shared libavutil/*.o libavutil/arm/*.o libavcodec/*.o libavcodec/arm/*.o libswscale/*.o -o libffmpeg-linphone-arm.so - -$(FFMPEG_BUILD_DIR)/x86/config.h: - mkdir -p $(FFMPEG_BUILD_DIR)/x86 && \ - cd $(FFMPEG_BUILD_DIR)/x86 && \ - $(FFMPEG_SRC_DIR)/configure $(FFMPEG_CONFIGURE_OPTIONS) $(FFMPEG_X86_CONFIGURE_OPTIONS) - sed -i.bak 's/#define HAVE_SYSCTL 1/#define HAVE_SYSCTL 0/g' $(FFMPEG_BUILD_DIR)/x86/config.h - sed -i.bak 's/#define HAVE_GETHRTIME 1/#define HAVE_GETHRTIME 0/g' $(FFMPEG_BUILD_DIR)/x86/config.h - -$(FFMPEG_BUILD_DIR)/x86/libavcodec/libavcodec-linphone-x86.so: $(FFMPEG_BUILD_DIR)/x86/config.h - cd $(FFMPEG_BUILD_DIR)/x86 && \ - make -j${NUMCPUS} \ - || ( echo "Build of ffmpeg for x86 failed." ; exit 1 ) - -$(FFMPEG_BUILD_DIR)/x86/libffmpeg-linphone-x86.so: $(FFMPEG_BUILD_DIR)/x86/libavcodec/libavcodec-linphone-x86.so - cd $(FFMPEG_BUILD_DIR)/x86 && \ - rm libavcodec/log2_tab.o && \ - $(X86_TOOLCHAIN_PATH)gcc -lm -lz --sysroot=$(X86_SYSROOT) -Wl,-soname,libffmpeg-linphone-x86.so,--no-undefined -Wl,-z,noexecstack -shared libavutil/*.o libavutil/x86/*.o libavcodec/*.o libavcodec/x86/*.o libswscale/*.o -o libffmpeg-linphone-x86.so - -build-ffmpeg: $(BUILD_FFMPEG_DEPS) - -clean-ffmpeg: - rm -rf $(FFMPEG_BUILD_DIR)/arm && \ - rm -rf $(FFMPEG_BUILD_DIR)/x86 - -#x264 -ifeq ($(BUILD_VIDEO),1) -ifeq ($(BUILD_X264), 1) -BUILD_X264_DEPS=$(X264_SRC_DIR)/log2f_fix_patch_applied.txt $(X264_BUILD_DIR)/arm/libx264.a -ifeq ($(BUILD_FOR_X86), 1) - BUILD_X264_DEPS+=$(X264_BUILD_DIR)/x86/libx264.a -endif -endif - -X264_SRC_DIR=$(TOPDIR)/submodules/externals/x264 -X264_BUILD_DIR=$(TOPDIR)/submodules/externals/build/x264 -X264_CONFIGURE_OPTIONS=--enable-static -X264_ARM_CONFIGURE_OPTIONS=--host=arm-none-linux-gnueabi --sysroot=$(ARM_SYSROOT) --cross-prefix=$(ARM_TOOLCHAIN_PATH) --enable-pic -X264_X86_CONFIGURE_OPTIONS=--host=i686-linux-gnueabi --sysroot=$(X86_SYSROOT) --cross-prefix=$(X86_TOOLCHAIN_PATH) - -$(X264_SRC_DIR)/log2f_fix_patch_applied.txt: - @patch -p0 < $(TOPDIR)/patches/x264_log2f_fix.patch - touch $@ - -$(X264_BUILD_DIR)/arm/libx264.a: - mkdir -p $(X264_BUILD_DIR)/arm && \ - cd $(X264_SRC_DIR) && \ - $(X264_SRC_DIR)/configure $(X264_CONFIGURE_OPTIONS) $(X264_ARM_CONFIGURE_OPTIONS) && \ - make -j$(NUMCPUS) STRIP= && \ - cp libx264.a $(X264_BUILD_DIR)/arm/libx264.a && \ - make clean \ - || ( echo "Build of x264 for arm failed." ; exit 1 ) - -$(X264_BUILD_DIR)/x86/libx264.a: - mkdir -p $(X264_BUILD_DIR)/x86 && \ - cd $(X264_SRC_DIR) && \ - $(X264_SRC_DIR)/configure $(X264_CONFIGURE_OPTIONS) $(X264_X86_CONFIGURE_OPTIONS) && \ - make -j$(NUMCPUS) STRIP= && \ - cp libx264.a $(X264_BUILD_DIR)/x86/libx264.a && \ - make clean \ - || ( echo "Build of x264 for x86 failed." ; exit 1 ) - -endif -build-x264: $(BUILD_X264_DEPS) - -clean-x264: - rm -rf $(X264_BUILD_DIR)/arm && \ - rm -rf $(X264_BUILD_DIR)/x86 - -#codec2 -ifeq ($(BUILD_CODEC2),1) -CODEC2_SRC_DIR=$(TOPDIR)/submodules/externals/codec2 -CODEC2_BUILD_DIR=$(TOPDIR)/submodules/externals/build/codec2 -PREPARE_CODEC2_DEPS=codec2-install-headers -endif - -fetch-codec2: -ifneq "$(wildcard $(CODEC2_SRC_DIR) )" "" - # source directory for codec2 already exists, update it - svn up $(CODEC2_SRC_DIR) -else - #source directory for codec2 doesn't exist, create it and fetch the source from svn depot - mkdir $(CODEC2_SRC_DIR) - svn co https://svn.code.sf.net/p/freetel/code/codec2/branches/0.3/ $(CODEC2_SRC_DIR) -endif - -codec2-install-headers: fetch-codec2 - mkdir -p $(CODEC2_SRC_DIR)/include/codec2 - rsync -rvLpgoc $(CODEC2_SRC_DIR)/src/codec2.h $(CODEC2_SRC_DIR)/include/codec2/codec2.h - -prepare-codec2: $(PREPARE_CODEC2_DEPS) - -#openh264 -ifeq ($(BUILD_VIDEO),1) -ifeq ($(BUILD_OPENH264), 1) -BUILD_OPENH264_DEPS=build-openh264-arm -ifeq ($(BUILD_FOR_X86), 1) - BUILD_OPENH264_DEPS+=build-openh264-x86 -endif -endif -endif - -OPENH264_SRC_DIR=$(TOPDIR)/submodules/externals/openh264 -OPENH264_BUILD_DIR=$(TOPDIR)/submodules/externals/build/openh264 -OPENH264_BUILD_DIR_ARM=$(OPENH264_BUILD_DIR)/arm -OPENH264_BUILD_DIR_X86=$(OPENH264_BUILD_DIR)/x86 - -$(OPENH264_SRC_DIR)/patch.stamp: $(TOPDIR)/patches/openh264-permissive.patch - cd $(OPENH264_SRC_DIR) && patch -p1 < $(TOPDIR)/patches/openh264-permissive.patch && touch $(OPENH264_SRC_DIR)/patch.stamp - -openh264-patch: $(OPENH264_SRC_DIR)/patch.stamp - -openh264-install-headers: - mkdir -p $(OPENH264_SRC_DIR)/include/wels - rsync -rvLpgoc --exclude ".git" $(OPENH264_SRC_DIR)/codec/api/svc/* $(OPENH264_SRC_DIR)/include/wels/. - -copy-openh264-x86: openh264-install-headers - mkdir -p $(OPENH264_BUILD_DIR) - mkdir -p $(OPENH264_BUILD_DIR_X86) - cd $(OPENH264_BUILD_DIR_X86) \ - && rsync -rvLpgoc --exclude ".git" $(OPENH264_SRC_DIR)/* . - -copy-openh264-arm: openh264-install-headers - mkdir -p $(OPENH264_BUILD_DIR) - mkdir -p $(OPENH264_BUILD_DIR_ARM) - cd $(OPENH264_BUILD_DIR_ARM) \ - && rsync -rvLpgoc --exclude ".git" $(OPENH264_SRC_DIR)/* . - -build-openh264-x86: copy-openh264-x86 - cd $(OPENH264_BUILD_DIR_X86) && \ - make libraries -j$(NUMCPUS) OS=android ARCH=x86 NDKROOT=$(NDK_PATH) TARGET=$(NDKBUILD_TARGET) - -build-openh264-arm: copy-openh264-arm - cd $(OPENH264_BUILD_DIR_ARM) && \ - make libraries -j$(NUMCPUS) OS=android ARCH=arm NDKROOT=$(NDK_PATH) TARGET=$(NDKBUILD_TARGET) - -build-openh264: $(BUILD_OPENH264_DEPS) - -clean-openh264: - cd $(OPENH264_SRC_DIR) && git clean -dfx && git reset --hard - rm -rf $(OPENH264_BUILD_DIR_ARM) - rm -rf $(OPENH264_BUILD_DIR_X86) - -#libvpx -ifeq ($(BUILD_VIDEO),1) -BUILD_VPX_DEPS=$(LIBVPX_SRC_DIR)/configure_android_x86_patch_applied.txt $(LIBVPX_BUILD_DIR)/arm/libvpx.a -ifeq ($(BUILD_FOR_X86), 1) - BUILD_VPX_DEPS+=$(LIBVPX_BUILD_DIR)/x86/libvpx.a -endif -endif -LIBVPX_SRC_DIR=$(TOPDIR)/submodules/externals/libvpx -LIBVPX_BUILD_DIR=$(TOPDIR)/submodules/externals/build/libvpx -LIBVPX_CONFIGURE_OPTIONS=--disable-vp9 --disable-examples --disable-unit-tests --disable-postproc --enable-error-concealment --enable-pic - -$(LIBVPX_SRC_DIR)/configure_android_x86_patch_applied.txt: - cd $(LIBVPX_SRC_DIR) && patch -p1 < $(TOPDIR)/patches/libvpx_configure_android_x86.patch - touch $@ - -$(LIBVPX_BUILD_DIR)/arm/libvpx.a: - mkdir -p $(LIBVPX_BUILD_DIR)/arm && \ - cd $(LIBVPX_BUILD_DIR)/arm && \ - $(LIBVPX_SRC_DIR)/configure --target=armv7-android-gcc --extra-cflags="-mfloat-abi=softfp -mfpu=neon" --sdk-path=$(NDK_PATH) $(LIBVPX_CONFIGURE_OPTIONS) && \ - make -j${NUMCPUS} \ - || ( echo "Build of libvpx for arm failed." ; exit 1 ) - -$(LIBVPX_BUILD_DIR)/x86/libvpx.a: - mkdir -p $(LIBVPX_BUILD_DIR)/x86 && \ - cd $(LIBVPX_BUILD_DIR)/x86 && \ - $(LIBVPX_SRC_DIR)/configure --target=x86-android-gcc --sdk-path=$(NDK_PATH) $(LIBVPX_CONFIGURE_OPTIONS) && \ - make -j${NUMCPUS} \ - || ( echo "Build of libvpx for x86 failed." ; exit 1 ) - -build-vpx: $(BUILD_VPX_DEPS) - -clean-vpx: - cd $(LIBVPX_SRC_DIR) && git clean -dfx && git reset --hard - rm -rf submodules/externals/build/libvpx/arm && \ - rm -rf submodules/externals/build/libvpx/x86 - -#srtp -$(TOPDIR)/submodules/externals/srtp/config.h : $(TOPDIR)/submodules/externals/build/srtp/config.h - @cd $(TOPDIR)/submodules/externals/srtp/ && \ - cp ../build/srtp/config.h . \ - || ( echo "SRTP prepare state failed." ; exit 1 ) - -prepare-srtp: $(TOPDIR)/submodules/externals/srtp/config.h - -#ms2 -prepare-mediastreamer2: - @cd $(TOPDIR)/submodules/linphone/mediastreamer2/src/ && \ - eval `cat Makefile.am | grep xxd | grep yuv2rgb.vs | sed 's/\$$(abs_builddir)/./'` && \ - eval `cat Makefile.am | grep xxd | grep yuv2rgb.fs | sed 's/\$$(abs_builddir)/./'` && \ - if ! [ -e yuv2rgb.vs.h ]; then echo "yuv2rgb.vs.h creation error (do you have 'xxd' application installed ?)"; exit 1; fi && \ - if ! [ -e yuv2rgb.fs.h ]; then echo "yuv2rgb.fs.h creation error (do you have 'xxd' application installed ?)"; exit 1; fi - -#antlr3 -ANLTR3_SRC_DIR=$(TOPDIR)/submodules/externals/antlr3/runtime/C/include/ -ANTLR3_BUILD_DIR=$(ANTLR3_SRC_DIR) -$(ANLTR3_SRC_DIR)/antlr3config.h: $(TOPDIR)/submodules/externals/build/antlr3/antlr3config.h - cp $(TOPDIR)/submodules/externals/build/antlr3/antlr3config.h $(ANLTR3_SRC_DIR) -prepare-antlr3: $(ANLTR3_SRC_DIR)/antlr3config.h - -%.tokens: %.g - $(ANTLR) -make -fo $(dir $^) $^ - -#Belle-sip -BELLESIP_SRC_DIR=$(TOPDIR)/submodules/belle-sip -BELLESIP_BUILD_DIR=$(BELLESIP_SRC_DIR) -prepare-belle-sip: $(BELLESIP_SRC_DIR)/src/grammars/belle_sip_message.tokens $(BELLESIP_SRC_DIR)/src/grammars/belle_sdp.tokens - -#CUnit -prepare-cunit: $(TOPDIR)/submodules/externals/cunit/CUnit/Headers/*.h - [ -d $(TOPDIR)/submodules/externals/build/cunit/CUnit ] || mkdir $(TOPDIR)/submodules/externals/build/cunit/CUnit - cp $^ $(TOPDIR)/submodules/externals/build/cunit/CUnit - -$(TOPDIR)/res/raw/rootca.pem: - HTTPS_CA_DIR=$(HTTPS_CA_DIR) $(TOPDIR)/submodules/linphone/scripts/mk-ca-bundle.pl $@ - -prepare-liblinphone_tester: $(TOPDIR)/submodules/linphone/tester/tester_hosts $(TOPDIR)/res/raw/rootca.pem $(TOPDIR)/submodules/linphone/tester/messages.db - rm -rf liblinphone_tester/assets/config_files - mkdir -p liblinphone_tester/assets/config_files - for file in $^; do \ - cp -rf $$file $(TOPDIR)/liblinphone_tester/assets/config_files/. \ - ;done - cp -rf $(TOPDIR)/submodules/linphone/tester/certificates $(TOPDIR)/liblinphone_tester/assets/config_files - cp -rf $(TOPDIR)/submodules/linphone/tester/sounds $(TOPDIR)/liblinphone_tester/assets/config_files - cp -rf $(TOPDIR)/submodules/linphone/tester/images $(TOPDIR)/liblinphone_tester/assets/config_files - cp -rf $(TOPDIR)/submodules/linphone/tester/rcfiles $(TOPDIR)/liblinphone_tester/assets/config_files - cp -rf $(TOPDIR)/submodules/linphone/tester/vcards $(TOPDIR)/liblinphone_tester/assets/config_files - -#Matroska2 -MATROSKA_SRC_DIR=$(TOPDIR)/submodules/externals/libmatroska-c -MATROSKA_BUILD_DIR=$(TOPDIR)/submodules/externals/build/libmatroska-c -ifeq ($(BUILD_MATROSKA), 1) -prepare-matroska2: $(MATROSKA_SRC_DIR)/patch_applied.txt -else -prepare-matroska2: -endif - -$(MATROSKA_SRC_DIR)/patch_applied.txt: $(MATROSKA_BUILD_DIR)/fix_libmatroska2.patch - cd $(MATROSKA_SRC_DIR); patch -p1 < $<; touch $@ - -#Build targets -prepare-sources: build-ffmpeg build-x264 build-openh264 build-vpx prepare-srtp prepare-mediastreamer2 prepare-antlr3 prepare-belle-sip $(TOPDIR)/res/raw/rootca.pem prepare-matroska2 prepare-codec2 - -GENERATE_OPTIONS = NDK_DEBUG=$(NDK_DEBUG) BUILD_FOR_X86=$(BUILD_FOR_X86) \ - BUILD_AMRNB=$(BUILD_AMRNB) BUILD_AMRWB=$(BUILD_AMRWB) BUILD_SILK=$(BUILD_SILK) BUILD_G729=$(BUILD_G729) BUILD_OPUS=$(BUILD_OPUS) BUILD_CODEC2=$(BUILD_CODEC2)\ - BUILD_VIDEO=$(BUILD_VIDEO) BUILD_X264=$(BUILD_X264) BUILD_OPENH264=$(BUILD_OPENH264) ENABLE_OPENH264_DECODER=$(ENABLE_OPENH264_DECODER) BUILD_MATROSKA=$(BUILD_MATROSKA) \ - BUILD_UPNP=$(BUILD_UPNP) BUILD_ZRTP=$(BUILD_ZRTP) BUILD_WEBRTC_AECM=$(BUILD_WEBRTC_AECM) BUILD_WEBRTC_ISAC=$(BUILD_WEBRTC_ISAC) BUILD_ILBC=$(BUILD_ILBC) \ - BUILD_FOR_ARM=$(BUILD_FOR_ARM) BUILD_NON_FREE_CODECS=$(BUILD_NON_FREE_CODECS) - - -LIBLINPHONE_OPTIONS = $(GENERATE_OPTIONS) \ - LIBLINPHONE_VERSION=$(LIBLINPHONE_VERSION) BELLESIP_VERSION=$(BELLESIP_VERSION) USE_JAVAH=$(USE_JAVAH) \ - BUILD_TUNNEL=$(BUILD_TUNNEL) BUILD_TLS=$(BUILD_TLS) BUILD_SQLITE=$(BUILD_SQLITE) \ - BUILD_CONTACT_HEADER=$(BUILD_CONTACT_HEADER) BUILD_RTP_MAP=$(BUILD_RTP_MAP) \ - LIBLINPHONE_EXTENDED_SRC_FILES="$(LIBLINPHONE_EXTENDED_SRC_FILES)" \ - LIBLINPHONE_EXTENDED_C_INCLUDES="$(LIBLINPHONE_EXTENDED_C_INCLUDES)" \ - LIBLINPHONE_EXTENDED_CFLAGS="$(LIBLINPHONE_EXTENDED_CFLAGS)" \ - APP_STL="$(APP_STL)" \ - BUILD_DONT_CHECK_HEADERS_IN_MESSAGE=$(BUILD_DONT_CHECK_HEADERS_IN_MESSAGE) - -MEDIASTREAMER2_OPTIONS = $(GENERATE_OPTIONS) BUILD_MEDIASTREAMER2_SDK=1 - - -generate-libs: prepare-sources javah - $(NDK_PATH)/ndk-build $(LIBLINPHONE_OPTIONS) -j$(NUMCPUS) TARGET_PLATFORM=$(NDKBUILD_TARGET) - -generate-mediastreamer2-libs: prepare-sources - @cd $(TOPDIR)/submodules/linphone/mediastreamer2/java && \ - $(NDK_PATH)/ndk-build $(MEDIASTREAMER2_OPTIONS) -j$(NUMCPUS) TARGET_PLATFORM=$(NDKBUILD_TARGET) - -update-project: $(TOPDIR)/res/raw/rootca.pem - $(SDK_PATH)/android update project --path . --target $(ANDROID_MOST_RECENT_TARGET) - $(SDK_PATH)/android update test-project --path tests -m . - $(SDK_PATH)/android update project --path liblinphone_tester --target $(ANDROID_MOST_RECENT_TARGET) - -update-mediastreamer2-project: - @cd $(TOPDIR)/submodules/linphone/mediastreamer2/java && \ - $(SDK_PATH)/android update project --path . --target $(ANDROID_MOST_RECENT_TARGET) - -liblinphone_tester: update-project prepare-sources prepare-cunit prepare-liblinphone_tester javah - $(NDK_PATH)/ndk-build -C liblinphone_tester $(LIBLINPHONE_OPTIONS) -j$(NUMCPUS) TARGET_PLATFORM=$(NDKBUILD_TARGET) - $(MAKE) -C liblinphone_tester - -javah: - $(ANT) javah - -generate-apk: java-clean generate-libs - echo "version.name=$(LINPHONE_ANDROID_DEBUG_VERSION)" > default.properties - $(ANT) debug - -generate-mediastreamer2-apk: java-clean generate-mediastreamer2-libs - @cd $(TOPDIR)/submodules/linphone/mediastreamer2/java && \ - echo "version.name=$(LINPHONE_ANDROID_DEBUG_VERSION)" > default.properties && \ - $(ANT) debug - -uninstall: - adb uninstall $(PACKAGE_NAME) - -install-apk: - ant installd - -release: update-project - $(MAKE) java-clean - patch -p1 < release.patch - cat ant.properties | grep version.name > default.properties - $(MAKE) generate-libs - $(ANT) release - patch -Rp1 < release.patch - -run-linphone: - ant run - -run-liblinphone-tests: liblinphone_tester - $(MAKE) -C liblinphone_tester run-all-tests - -run-basic-tests: update-project - $(ANT) partial-clean - $(MAKE) -C tests run-basic-tests ANT_SILENT=$(ANT_SILENT) - -run-all-tests: update-project - $(ANT) partial-clean - $(MAKE) -C tests run-all-tests ANT_SILENT=$(ANT_SILENT) - -clean-ndk-build: - - $(NDK_PATH)/ndk-build clean $(LIBLINPHONE_OPTIONS) - $(ANT) clean - @if [ -f $(TOPDIR)/submodules/linphone/mediastreamer2/java/project.properties ]; then \ - cd $(TOPDIR)/submodules/linphone/mediastreamer2/java && $(ANT) clean; \ - fi - -.NOTPARALLEL clean-native: clean-ndk-build clean-ffmpeg clean-x264 clean-openh264 clean-vpx - - -java-clean: - $(ANT) clean - -clean: clean-native java-clean - patch -Rp1 -f < release.patch || echo "patch already cleaned" - rm -f AndroidManifest.xml.rej - rm -f AndroidManifest.xml.orig - - -.PHONY: clean install-apk run-linphone - -generate-sdk: liblinphone-android-sdk - -liblinphone-android-sdk: generate-apk - $(ANT) liblinphone-android-sdk - -linphone-android-sdk: generate-apk - $(ANT) linphone-android-sdk - -mediastreamer2-sdk: update-mediastreamer2-project generate-mediastreamer2-apk - @cd $(TOPDIR)/submodules/linphone/mediastreamer2/java && \ - $(ANT) mediastreamer2-sdk - -pull-transifex: - tx pull -af - -push-transifex: - tx push -s -f --no-interactive diff --git a/README b/README index eeee2734a..779491944 100644 --- a/README +++ b/README @@ -9,21 +9,23 @@ To build liblinphone for Android, you must: ------------------------------------------- 0) download the Android sdk with platform-tools and tools updated to latest revision (at least API 16 is needed), then add both 'tools' and 'platform-tools' folders in your path. 1) download the Android ndk (=r10c) from google and add it to your path (no symlink !!!). -2) install yasm, nasm, curl, ant, rsync, autoconf, automake, aclocal, libtool, pkgconfig, bc, perl-LWP-Protocol-https, patch, vim-common +2) install yasm, nasm, ant, python, cmake On 64 bits linux systems you'll need the ia32-libs package With the latest Debian (multiarch), you need this: dpkg --add-architecture i386 aptitude update aptitude install libstdc++6:i386 libgcc1:i386 zlib1g:i386 libncurses5:i386 -3) run the Makefile script in the top level directory. This will download iLBC source files and convert some assembly files in VP8 project. +3) run `./prepare.py` in the top level directory. This will configure the build and generate a Makefile in the top level directory. + Some options can be passed to choose what you want to include in the build and the platforms for which you want to build. Use `./prepare.py --help` to see what these options are. +4) run the Makefile script in the top level directory. $ make -4) (Optional) To install the generated apk into a plugged device, run +5) (Optional) To install the generated apk into a plugged device, run $ make install -5) (Optional) To generate a liblinphone SDK zip containing a full jar and native libraries, run +6) (Optional) To generate a liblinphone SDK zip containing a full jar and native libraries, run $ make liblinphone-android-sdk -6) (Optional) To generate a libmediastreamer2 SDK zip containing a full jar and native libraries, run +7) (Optional) To generate a libmediastreamer2 SDK zip containing a full jar and native libraries, run $ make mediastreamer2-sdk -7) (Optional) To generate a signed apk to publish on the Google Play, run +8) (Optional) To generate a signed apk to publish on the Google Play, run $ make release Make sure you filled the ant.properties values for version.name, key.store and key.alias in order to correctly sign the generated apk. You also may want to create a file name ant_password.properties with the following: @@ -51,8 +53,7 @@ Simply run $ make liblinphone_tester This will be build everything, generate an apk, and install it on the connected device if any. -You can speed up the compilation by using ccache (compiler cache, see https://ccache.samba.org/). Simply export: -export NDK_CCACHE=ccache +You can speed up the compilation by using ccache (compiler cache, see https://ccache.samba.org/). Give the "-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache" options to the prepare.py script. TROUBLESHOOTING *************** @@ -73,77 +74,7 @@ Caused by: java.lang.UnsatisfiedLinkError: Couldn't load linphone-armeabi-v7a: f BUILD OPTIONS ************* -Some options can be passed to make, like "make SOME_OPTION=SOME_VALUE". +The build options are to be passed to the prepare.py script. +For example to enable the x264 encoder give the "-DENABLE_X264=YES" to prepare.py. -ENABLE_GPL_THIRD_PARTIES - values: 0 (GPL third parties disabled) or 1 (GPL third parties enabled), default value: 1 - GPL third parties are: X264 and G729 - -BUILD_VIDEO - values: 0 (no video) or 1 (video enabled), default value: 1 - -BUILD_OPENH264 - values: 0 (don't build openH264) or 1 (build openH264), default value: 1 - -ENABLE_OPENH264_DECODER - values: 0 (disable openh264 decoder) or 1 (enable openh264 decoder), default value: 1 - -BUILD_X264 - values: 0 (don't build x264) or 1 (build x264), default value: 0 - -BUILD_AMRNB - values: 0 (don't build amrnb codec), light (try to use amrnb codec from android), full (build your own amrnb codec), default value: full - -BUILD_AMRWB - values: 0 (don't build amrwb codec), 1 (build your own amrwb codec): default value: 1 - -BUILD_ZRTP - values: 0 (don't support ZRTP), 1 (support ZRTP), default value: 1 - -BUILD_SILK - values: 0 (don't build silk plugin), 1 (build silk) [silk is Skype nonfree patented audio codec], default value: 1 - -BUILD_G729 - values: 0 (don't build g729 plugin), 1 (build g729) [g729 is nonfree patented audio codec, contact Sipro lab for more details] - default value: 1 - -BUILD_TUNNEL - values: 0 (don't build tunnel), 1 (build tunnel) [requires a non-free tunnel implementation in submodules/linphone/tunnel] - default value: 0 - -BUILD_WEBRTC_AECM - values: 0 (don't build echo canceler), 1 (build echo canceler) - default value: 1 - -USE_JAVAH - values: 0 (don't generate header), 1 (generate header for linphone_core_jni) [used to check errors at liblinphone compilation] - default value: 1 - -BUILD_FOR_X86 - values: 0 (don't generate liblinphone libraries for x86 architecture), 1 (build liblinphone libraries for x86 architecture) - default value: 1 - -BUILD_SQLITE - values: 0 (don't build sqlite3), 1 (build sqlite3) [used to store chat messages inside liblinphone] - default value: 1 - -BUILD_TLS - values: 0 (don't build tls), 1 (do build tls), default value: 1 - -BUILD_WEBRTC_ISAC - values: 0 (don't build isac), 1 (do build isac), default value: 1 - -BUILD_OPUS - values: 0 (don't build opus), 1 (do build opus), default value: 1 - -BUILD_UPNP - values: 0 (don't build upnp), 1 (do build upnp), default value: 1 - -BUILD_MATROSKA - values: 0 (don't build matroska and ebml), 1 (do build matroska and ebml), default value: 0 - -BUILD_ILBC - values: 0 (don't build iLBC), 1 (do build iLBC), default value: 1 - -BUILD_CODEC2 - values: 0 (don't build codec2 support), 1 (do build codec2 support), default value: 0 +The available options can be listed with the `./prepare.py --list-features` diff --git a/liblinphone_tester/Makefile b/liblinphone_tester/Makefile index 42b2637c1..1754d87d3 100644 --- a/liblinphone_tester/Makefile +++ b/liblinphone_tester/Makefile @@ -1,5 +1,59 @@ -all: +ANDROID_MOST_RECENT_TARGET=$(shell android list target -c | grep -E 'android-[0-9]+' | tail -n1) + +all: update-project copy-files ant debug install run-all-tests: all ant test + +update-project: + android update project --path . --target $(ANDROID_MOST_RECENT_TARGET) + +copy-libs: + rm -rf libs/armeabi + mkdir -p assets/config_files + if test -d "../liblinphone-sdk/android-arm"; then \ + mkdir -p libs/armeabi && \ + cp -f ../liblinphone-sdk/android-arm/lib/lib*-armeabi.so libs/armeabi && \ + cp -f ../liblinphone-sdk/android-arm/lib/mediastreamer/plugins/*.so libs/armeabi && \ + cp -f ../liblinphone-sdk/android-arm/share/linphone/rootca.pem assets/config_files; \ + fi + if test -f "../liblinphone-sdk/android-arm/bin/gdbserver"; then \ + cp -f ../liblinphone-sdk/android-arm/bin/gdbserver libs/armeabi && \ + cp -f ../liblinphone-sdk/android-arm/bin/gdb.setup libs/armeabi; \ + fi + rm -rf libs/armeabi-v7a + if test -d "../liblinphone-sdk/android-armv7"; then \ + mkdir -p libs/armeabi-v7a && \ + cp -f ../liblinphone-sdk/android-armv7/lib/lib*-armeabi-v7a.so libs/armeabi-v7a && \ + cp -f ../liblinphone-sdk/android-armv7/lib/mediastreamer/plugins/*.so libs/armeabi-v7a && \ + cp -f ../liblinphone-sdk/android-armv7/share/linphone/rootca.pem assets/config_files; \ + fi + if test -f "../liblinphone-sdk/android-armv7/bin/gdbserver"; then \ + cp -f ../liblinphone-sdk/android-armv7/bin/gdbserver libs/armeabi-v7a && \ + cp -f ../liblinphone-sdk/android-armv7/bin/gdb.setup libs/armeabi-v7a; \ + fi + rm -rf libs/x86 + if test -d "../liblinphone-sdk/android-x86"; then \ + mkdir -p libs/x86 && \ + cp -f ../liblinphone-sdk/android-x86/lib/lib*-x86.so libs/x86 && \ + cp -f ../liblinphone-sdk/android-x86/lib/mediastreamer/plugins/*.so libs/x86 && \ + cp -f ../liblinphone-sdk/android-x86/share/linphone/rootca.pem assets/config_files; \ + fi + if test -f "../liblinphone-sdk/android-x86/bin/gdbserver"; then \ + cp -f ../liblinphone-sdk/android-x86/bin/gdbserver libs/x86 && \ + cp -f ../liblinphone-sdk/android-x86/bin/gdb.setup libs/x86; \ + fi + +copy-files: ../submodules/linphone/tester/tester_hosts ../submodules/linphone/tester/messages.db + $(MAKE) copy-libs + rm -rf assets/config_files + mkdir -p assets/config_files + for file in $^; do \ + cp -rf $$file assets/config_files/. ; \ + done + cp -rf ../submodules/linphone/tester/certificates assets/config_files + cp -rf ../submodules/linphone/tester/images assets/config_files + cp -rf ../submodules/linphone/tester/rcfiles assets/config_files + cp -rf ../submodules/linphone/tester/sounds assets/config_files + cp -rf ../submodules/linphone/tester/vcards assets/config_files diff --git a/liblinphone_tester/src/org/linphone/tester/Tester.java b/liblinphone_tester/src/org/linphone/tester/Tester.java index 59c3887b3..049c4405e 100644 --- a/liblinphone_tester/src/org/linphone/tester/Tester.java +++ b/liblinphone_tester/src/org/linphone/tester/Tester.java @@ -25,23 +25,22 @@ public class Tester { } static { - System.loadLibrary("cunit"); List cpuabis=Version.getCpuAbis(); String ffmpegAbi; boolean libLoaded=false; Throwable firstException=null; for (String abi : cpuabis){ Log.i("LinphoneCoreFactoryImpl","Trying to load liblinphone for " + abi); - ffmpegAbi=abi; - // FFMPEG (audio/video) - if (abi.startsWith("armeabi")) { - ffmpegAbi="arm"; - } - loadOptionalLibrary("ffmpeg-linphone-"+ffmpegAbi); + loadOptionalLibrary("ffmpeg-linphone-" + abi); //Main library try { + System.loadLibrary("bctoolbox-" + abi); + System.loadLibrary("bctoolbox-tester-" + abi); + System.loadLibrary("ortp-" + abi); + System.loadLibrary("mediastreamer_base-" + abi); + System.loadLibrary("mediastreamer_voip-" + abi); System.loadLibrary("linphone-" + abi); - System.loadLibrary("linphone_tester-" + abi); + System.loadLibrary("linphonetester-" + abi); Log.i("LinphoneCoreFactoryImpl","Loading done with " + abi); libLoaded=true; diff --git a/liblinphone_tester/src/org/linphone/tester/WrapperTester.java b/liblinphone_tester/src/org/linphone/tester/WrapperTester.java index 0ecfb5c30..20ef7e782 100644 --- a/liblinphone_tester/src/org/linphone/tester/WrapperTester.java +++ b/liblinphone_tester/src/org/linphone/tester/WrapperTester.java @@ -99,7 +99,8 @@ public class WrapperTester extends AndroidTestCase { protected void setUp() throws Exception { // TODO Auto-generated method stub super.setUp(); - mCore = LinphoneCoreFactory.instance().createLinphoneCore(new LinphoneCoreListenerBase(),null); + LinphoneCoreFactory.instance().setDebugMode(true, "WrapperTester"); + mCore = LinphoneCoreFactory.instance().createLinphoneCore(new LinphoneCoreListenerBase(),getContext()); } @Override diff --git a/prepare.py b/prepare.py new file mode 100755 index 000000000..1affb11b0 --- /dev/null +++ b/prepare.py @@ -0,0 +1,498 @@ +#!/usr/bin/env python + +############################################################################ +# prepare.py +# Copyright (C) 2016 Belledonne Communications, Grenoble France +# +############################################################################ +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################ + +import argparse +import os +import platform +import re +import shutil +import sys +import tempfile +from logging import error, warning, info, INFO, basicConfig +from subprocess import Popen, PIPE +from distutils.spawn import find_executable +sys.dont_write_bytecode = True +sys.path.insert(0, 'submodules/cmake-builder') +try: + import prepare +except Exception as e: + error( + "Could not find prepare module: {}, probably missing submodules/cmake-builder? Try running:\ngit submodule update --init --recursive".format(e)) + exit(1) + + +class AndroidTarget(prepare.Target): + + def __init__(self, arch): + prepare.Target.__init__(self, 'android-' + arch) + current_path = os.path.dirname(os.path.realpath(__file__)) + self.config_file = 'configs/config-android.cmake' + self.toolchain_file = 'toolchains/toolchain-android-' + arch + '.cmake' + self.output = 'liblinphone-sdk/android-' + arch + self.additional_args = [ + '-DCMAKE_INSTALL_MESSAGE=LAZY', + '-DLINPHONE_BUILDER_EXTERNAL_SOURCE_PATH=' + current_path + '/submodules' + ] + + def clean(self): + if os.path.isdir('WORK'): + shutil.rmtree('WORK', ignore_errors=False, onerror=self.handle_remove_read_only) + if os.path.isdir('liblinphone-sdk'): + shutil.rmtree('liblinphone-sdk', ignore_errors=False, onerror=self.handle_remove_read_only) + +class AndroidArmTarget(AndroidTarget): + + def __init__(self): + AndroidTarget.__init__(self, 'arm') + self.additional_args += [ '-DENABLE_VIDEO=NO' ] + +class AndroidArmv7Target(AndroidTarget): + + def __init__(self): + AndroidTarget.__init__(self, 'armv7') + +class AndroidX86Target(AndroidTarget): + + def __init__(self): + AndroidTarget.__init__(self, 'x86') + +targets = { + 'arm': AndroidArmTarget(), + 'armv7': AndroidArmv7Target(), + 'x86': AndroidX86Target() +} +platforms = ['all', 'arm', 'armv7', 'x86'] + + + +class PlatformListAction(argparse.Action): + + def __call__(self, parser, namespace, values, option_string=None): + if values: + for value in values: + if value not in platforms: + message = ("invalid platform: {0!r} (choose from {1})".format(value, ', '.join([repr(platform) for platform in platforms]))) + raise argparse.ArgumentError(self, message) + setattr(namespace, self.dest, values) + + +def gpl_disclaimer(platforms): + cmakecache = 'WORK/android-{arch}/cmake/CMakeCache.txt'.format(arch=platforms[0]) + gpl_third_parties_enabled = "ENABLE_GPL_THIRD_PARTIES:BOOL=YES" in open( + cmakecache).read() or "ENABLE_GPL_THIRD_PARTIES:BOOL=ON" in open(cmakecache).read() + + if gpl_third_parties_enabled: + warning("\n***************************************************************************" + "\n***************************************************************************" + "\n***** CAUTION, this liblinphone SDK is built using 3rd party GPL code *****" + "\n***** Even if you acquired a proprietary license from Belledonne *****" + "\n***** Communications, this SDK is GPL and GPL only. *****" + "\n***** To disable 3rd party gpl code, please use: *****" + "\n***** $ ./prepare.py -DENABLE_GPL_THIRD_PARTIES=NO *****" + "\n***************************************************************************" + "\n***************************************************************************") + else: + warning("\n***************************************************************************" + "\n***************************************************************************" + "\n***** Linphone SDK without 3rd party GPL software *****" + "\n***** If you acquired a proprietary license from Belledonne *****" + "\n***** Communications, this SDK can be used to create *****" + "\n***** a proprietary linphone-based application. *****" + "\n***************************************************************************" + "\n***************************************************************************") + + +def check_is_installed(binary, prog='it', warn=True): + if not find_executable(binary): + if warn: + error("Could not find {}. Please install {}.".format(binary, prog)) + return False + return True + + +def check_tools(): + ret = 0 + + #at least FFmpeg requires no whitespace in sources path... + if " " in os.path.dirname(os.path.realpath(__file__)): + error("Invalid location: path should not contain any spaces.") + ret = 1 + + ret |= not check_is_installed('cmake') + + if not os.path.isdir("submodules/linphone/mediastreamer2/src") or not os.path.isdir("submodules/linphone/oRTP/src"): + error("Missing some git submodules. Did you run:\n\tgit submodule update --init --recursive") + ret = 1 + + return ret + + +def generate_makefile(platforms, generator): + arch_targets = "" + for arch in platforms: + arch_targets += """ +{arch}: {arch}-build + +{arch}-build: +\t{generator} WORK/android-{arch}/cmake +\t@echo "Done" +""".format(arch=arch, generator=generator) + makefile = """ +archs={archs} +TOPDIR=$(shell pwd) +LINPHONE_ANDROID_VERSION=$(shell git describe --always) +ANDROID_MOST_RECENT_TARGET=$(shell android list target -c | grep -E 'android-[0-9]+' | tail -n1) +ANT_SILENT=$(shell ant -h | grep -q -- -S && echo 1 || echo 0) +PACKAGE_NAME=$(shell sed -nE 's||\\1|p' custom_rules.xml) + +.PHONY: all +.NOTPARALLEL: all generate-apk generate-mediastreamer2-apk install release + +all: update-project generate-apk + +build: $(addsuffix -build, $(archs)) + +clean: java-clean + +install: install-apk run-linphone + +java-clean: +\tant clean + +$(TOPDIR)/res/raw/rootca.pem: +\tcp liblinphone-sdk/android-{first_arch}/share/linphone/rootca.pem $@ + +copy-libs: +\trm -rf libs/armeabi +\tif test -d "liblinphone-sdk/android-arm"; then \\ +\t\tmkdir -p libs/armeabi && \\ +\t\tcp -f liblinphone-sdk/android-arm/lib/lib*-armeabi.so libs/armeabi && \\ +\t\tcp -f liblinphone-sdk/android-arm/lib/mediastreamer/plugins/*.so libs/armeabi; \\ +\tfi +\tif test -f "liblinphone-sdk/android-arm/bin/gdbserver"; then \\ +\t\tcp -f liblinphone-sdk/android-arm/bin/gdbserver libs/armeabi && \\ +\t\tcp -f liblinphone-sdk/android-arm/bin/gdb.setup libs/armeabi; \\ +\tfi +\trm -rf libs/armeabi-v7a +\tif test -d "liblinphone-sdk/android-armv7"; then \\ +\t\tmkdir -p libs/armeabi-v7a && \\ +\t\tcp -f liblinphone-sdk/android-armv7/lib/lib*-armeabi-v7a.so libs/armeabi-v7a && \\ +\t\tcp -f liblinphone-sdk/android-armv7/lib/mediastreamer/plugins/*.so libs/armeabi-v7a; \\ +\tfi +\tif test -f "liblinphone-sdk/android-armv7/bin/gdbserver"; then \\ +\t\tcp -f liblinphone-sdk/android-armv7/bin/gdbserver libs/armeabi-v7a && \\ +\t\tcp -f liblinphone-sdk/android-armv7/bin/gdb.setup libs/armeabi-v7a; \\ +\tfi +\trm -rf libs/x86 +\tif test -d "liblinphone-sdk/android-x86"; then \\ +\t\tmkdir -p libs/x86 && \\ +\t\tcp -f liblinphone-sdk/android-x86/lib/lib*-x86.so libs/x86 && \\ +\t\tcp -f liblinphone-sdk/android-x86/lib/mediastreamer/plugins/*.so libs/x86; \\ +\tfi +\tif test -f "liblinphone-sdk/android-x86/bin/gdbserver"; then \\ +\t\tcp -f liblinphone-sdk/android-x86/bin/gdbserver libs/x86 && \\ +\t\tcp -f liblinphone-sdk/android-x86/bin/gdb.setup libs/x86; \\ +\tfi + +update-project: +\tandroid update project --path . --target $(ANDROID_MOST_RECENT_TARGET) +\tandroid update test-project --path tests -m . + +update-mediastreamer2-project: +\t@cd $(TOPDIR)/submodules/linphone/mediastreamer2/java && \\ +\tandroid update project --path . --target $(ANDROID_MOST_RECENT_TARGET) + +generate-apk: java-clean build copy-libs $(TOPDIR)/res/raw/rootca.pem update-project +\techo "version.name=$(LINPHONE_ANDROID_VERSION)" > default.properties && \\ +\tant debug + +generate-mediastreamer2-apk: java-clean build copy-libs update-mediastreamer2-project +\t@cd $(TOPDIR)/submodules/linphone/mediastreamer2/java && \\ +\techo "version.name=$(LINPHONE_ANDROID_VERSION)" > default.properties && \\ +\tant debug + +install-apk: +\tant installd + +uninstall: +\tadb uninstall $(PACKAGE_NAME) + +release: java-clean build copy-libs supdate-project +\tpatch -p1 < release.patch +\tcat ant.properties | grep version.name > default.properties +\tant release +\tpatch -Rp1 < release.patch + +generate-sdk: liblinphone-android-sdk + +liblinphone-android-sdk: generate-apk +\tant liblinphone-android-sdk + +linphone-android-sdk: generate-apk +\tant linphone-android-sdk + +mediastreamer2-sdk: generate-mediastreamer2-apk +\t@cd $(TOPDIR)/submodules/linphone/mediastreamer2/java && \\ +\tant mediastreamer2-sdk + +liblinphone_tester: +\t$(MAKE) -C liblinphone_tester + +run-linphone: +\tant run + +run-liblinphone-tests: +\t$(MAKE) -C liblinphone_tester run-all-tests + +run-basic-tests: update-project +\tant partial-clean +\t$(MAKE) -C tests run-basic-tests ANT_SILENT=$(ANT_SILENT) + +run-all-tests: update-project +\tant partial-clean +\t$(MAKE) -C tests run-all-tests ANT_SILENT=$(ANT_SILENT) + + +pull-transifex: +\ttx pull -af + +push-transifex: +\ttx push -s -f --no-interactive + +{arch_targets} + +help-prepare-options: +\t@echo "prepare.py was previously executed with the following options:" +\t@echo " {options}" + +help: help-prepare-options +\t@echo "" +\t@echo "(please read the README.md file first)" +\t@echo "" +\t@echo "Available architectures: {archs}" +\t@echo "" +\t@echo "Available targets:" +\t@echo "" +\t@echo " * all or generate-apk: builds all architectures and creates the linphone application APK" +\t@echo " * generate-sdk: builds all architectures and creates the liblinphone SDK" +\t@echo " * install: install the linphone application APK (run this only after generate-apk)" +\t@echo " * uninstall: uninstall the linphone application" +\t@echo "" +""".format(archs=' '.join(platforms), arch_opts='|'.join(platforms), + first_arch=platforms[0], options=' '.join(sys.argv), + arch_targets=arch_targets, generator=generator) + f = open('Makefile', 'w') + f.write(makefile) + f.close() + gpl_disclaimer(platforms) + + +def list_features_with_args(debug, additional_args): + tmpdir = tempfile.mkdtemp(prefix="linphone-android") + tmptarget = AndroidArmv7Target() + tmptarget.abs_cmake_dir = tmpdir + + option_regex = re.compile("ENABLE_(.*):(.*)=(.*)") + options = {} + ended = True + build_type = 'Debug' if debug else 'Release' + + for line in Popen(tmptarget.cmake_command(build_type, False, True, additional_args, verbose=False), + cwd=tmpdir, shell=False, stdout=PIPE).stdout.readlines(): + match = option_regex.match(line) + if match is not None: + (name, typeof, value) = match.groups() + options["ENABLE_{}".format(name)] = value + ended &= (value == 'ON') + shutil.rmtree(tmpdir) + return (options, ended) + + +def list_features(debug, args): + additional_args = args + options = {} + info("Searching for available features...") + # We have to iterate multiple times to activate ALL options, so that options depending + # of others are also listed (cmake_dependent_option macro will not output options if + # prerequisite is not met) + while True: + (options, ended) = list_features_with_args(debug, additional_args) + if ended: + break + else: + additional_args = [] + # Activate ALL available options + for k in options.keys(): + additional_args.append("-D{}=ON".format(k)) + + # Now that we got the list of ALL available options, we must correct default values + # Step 1: all options are turned off by default + for x in options.keys(): + options[x] = 'OFF' + # Step 2: except options enabled when running with default args + (options_tmp, ended) = list_features_with_args(debug, args) + final_dict = dict(options.items() + options_tmp.items()) + + notice_features = "Here are available features:" + for k, v in final_dict.items(): + notice_features += "\n\t{}={}".format(k, v) + info(notice_features) + info("To enable some feature, please use -DENABLE_SOMEOPTION=ON (example: -DENABLE_OPUS=ON)") + info("Similarly, to disable some feature, please use -DENABLE_SOMEOPTION=OFF (example: -DENABLE_OPUS=OFF)") + + +def main(argv=None): + basicConfig(format="%(levelname)s: %(message)s", level=INFO) + + if argv is None: + argv = sys.argv + argparser = argparse.ArgumentParser( + description="Prepare build of Linphone and its dependencies.") + argparser.add_argument( + '-ac', '--all-codecs', help="Enable all codecs, including the non-free ones", action='store_true') + argparser.add_argument( + '-c', '-C', '--clean', help="Clean a previous build instead of preparing a build.", action='store_true') + argparser.add_argument( + '-d', '--debug', help="Prepare a debug build, eg. add debug symbols and use no optimizations.", action='store_true') + argparser.add_argument( + '-dv', '--debug-verbose', help="Activate ms_debug logs.", action='store_true') + argparser.add_argument( + '--disable-gpl-third-parties', help="Disable GPL third parties such as FFMpeg, x264.", action='store_true') + argparser.add_argument( + '--enable-non-free-codecs', help="Enable non-free codecs such as OpenH264, MPEG4, etc.. Final application must comply with their respective license (see README.md).", action='store_true') + argparser.add_argument( + '-f', '--force', help="Force preparation, even if working directory already exist.", action='store_true') + argparser.add_argument( + '-G', '--generator', help="CMake build system generator (default: Unix Makefiles, use cmake -h to get the complete list).", default='Unix Makefiles', dest='generator') + argparser.add_argument( + '-L', '--list-cmake-variables', help="List non-advanced CMake cache variables.", action='store_true', dest='list_cmake_variables') + argparser.add_argument( + '-lf', '--list-features', help="List optional features and their default values.", action='store_true', dest='list_features') + argparser.add_argument( + '-t', '--tunnel', help="Enable Tunnel.", action='store_true') + argparser.add_argument('platform', nargs='*', action=PlatformListAction, default=[ + 'arm', 'armv7', 'x86'], help="The platform to build for (default is 'arm armv7 x86'). Space separated architectures in list: {0}.".format(', '.join([repr(platform) for platform in platforms]))) + + args, additional_args2 = argparser.parse_known_args() + + additional_args = ["-G", args.generator] + + if check_tools() != 0: + return 1 + + if args.debug_verbose is True: + additional_args += ["-DENABLE_DEBUG_LOGS=YES"] + if args.enable_non_free_codecs is True: + additional_args += ["-DENABLE_NON_FREE_CODECS=YES"] + if args.all_codecs is True: + additional_args += ["-DENABLE_GPL_THIRD_PARTIES=YES"] + additional_args += ["-DENABLE_NON_FREE_CODECS=YES"] + additional_args += ["-DENABLE_AMRNB=YES"] + additional_args += ["-DENABLE_AMRWB=YES"] + additional_args += ["-DENABLE_BV16=YES"] + additional_args += ["-DENABLE_CODEC2=YES"] + additional_args += ["-DENABLE_G729=YES"] + additional_args += ["-DENABLE_GSM=YES"] + additional_args += ["-DENABLE_ILBC=YES"] + additional_args += ["-DENABLE_ISAC=YES"] + additional_args += ["-DENABLE_OPUS=YES"] + additional_args += ["-DENABLE_SILK=YES"] + additional_args += ["-DENABLE_SPEEX=YES"] + additional_args += ["-DENABLE_FFMPEG=YES"] + additional_args += ["-DENABLE_H263=YES"] + additional_args += ["-DENABLE_H263P=YES"] + additional_args += ["-DENABLE_MPEG4=YES"] + additional_args += ["-DENABLE_OPENH264=YES"] + additional_args += ["-DENABLE_VPX=YES"] + additional_args += ["-DENABLE_X264=YES"] + if args.disable_gpl_third_parties is True: + additional_args += ["-DENABLE_GPL_THIRD_PARTIES=NO"] + + if args.tunnel or os.path.isdir("submodules/tunnel"): + if not os.path.isdir("submodules/tunnel"): + info("Tunnel wanted but not found yet, trying to clone it...") + p = Popen("git clone gitosis@git.linphone.org:tunnel.git submodules/tunnel".split(" ")) + p.wait() + if p.returncode != 0: + error("Could not clone tunnel. Please see http://www.belledonne-communications.com/voiptunnel.html") + return 1 + warning("Tunnel enabled, disabling GPL third parties.") + additional_args += ["-DENABLE_TUNNEL=YES", "-DENABLE_GPL_THIRD_PARTIES=OFF"] + + # User's options are priority upon all automatic options + additional_args += additional_args2 + + if args.list_features: + list_features(args.debug, additional_args) + return 0 + + selected_platforms_dup = [] + for platform in args.platform: + if platform == 'all': + selected_platforms_dup += ['arm', 'armv7', 'x86'] + else: + selected_platforms_dup += [platform] + # unify platforms but keep provided order + selected_platforms = [] + for x in selected_platforms_dup: + if x not in selected_platforms: + selected_platforms.append(x) + + if os.path.isdir('WORK') and not args.clean and not args.force: + warning("Working directory WORK already exists. Please remove it (option -C or -c) before re-executing CMake " + "to avoid conflicts between executions, or force execution (option -f) if you are aware of consequences.") + if os.path.isfile('Makefile'): + Popen("make help-prepare-options".split(" ")) + return 0 + + for platform in selected_platforms: + target = targets[platform] + + if args.clean: + target.clean() + else: + retcode = prepare.run(target, args.debug, False, args.list_cmake_variables, args.force, additional_args) + if retcode != 0: + return retcode + + if args.clean: + if os.path.isfile('Makefile'): + os.remove('Makefile') + elif selected_platforms: + # only generated makefile if we are using Ninja or Makefile + if args.generator.endswith('Ninja'): + if not check_is_installed("ninja", "it"): + return 1 + generate_makefile(selected_platforms, 'ninja -C') + info("You can now run 'make' to build.") + elif args.generator.endswith("Unix Makefiles"): + generate_makefile(selected_platforms, '$(MAKE) -C') + info("You can now run 'make' to build.") + else: + warning("Not generating meta-makefile for generator {}.".format(target.generator)) + + return 0 + +if __name__ == "__main__": + sys.exit(main()) diff --git a/submodules/externals/build/ffmpeg/CMakeLists.txt b/submodules/externals/build/ffmpeg/CMakeLists.txt new file mode 100644 index 000000000..405312520 --- /dev/null +++ b/submodules/externals/build/ffmpeg/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# CMakeLists.txt +# Copyright (C) 2016 Belledonne Communications, Grenoble France +# +############################################################################ +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################ + +cmake_minimum_required(VERSION 3.0) +project(ffmpegandroid LANGUAGES C) + +include(GNUInstallDirs) + + +find_library(AVCODEC_LIBRARY avcodec) +find_library(AVUTIL_LIBRARY avutil) +find_library(SWRESAMPLE_LIBRARY swresample) +find_library(SWSCALE_LIBRARY swscale) + +add_library(ffmpeg-linphone-${CMAKE_SYSTEM_PROCESSOR} MODULE) +target_link_libraries(ffmpeg-linphone-${CMAKE_SYSTEM_PROCESSOR} LINK_PRIVATE "m" "-Wl,-whole-archive" ${AVCODEC_LIBRARY} ${AVUTIL_LIBRARY} ${SWRESAMPLE_LIBRARY} ${SWSCALE_LIBRARY} "-Wl,-no-whole-archive") +set_target_properties(ffmpeg-linphone-${CMAKE_SYSTEM_PROCESSOR} PROPERTIES LINKER_LANGUAGE C) + +install(TARGETS ffmpeg-linphone-${CMAKE_SYSTEM_PROCESSOR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE +) diff --git a/tests/ant.properties b/tests/ant.properties index 15f57bb33..7f387c9fd 100644 --- a/tests/ant.properties +++ b/tests/ant.properties @@ -15,5 +15,5 @@ # 'key.alias' for the name of the key to use. # The password will be asked during the build when you use the 'release' target. -tested.project.dir=. +tested.project.dir=../ test.runner=com.zutubi.android.junitreport.JUnitReportTestRunner diff --git a/tests/src/org/linphone/test/LinphoneTestManager.java b/tests/src/org/linphone/test/LinphoneTestManager.java index 8774e2712..b4caa9655 100644 --- a/tests/src/org/linphone/test/LinphoneTestManager.java +++ b/tests/src/org/linphone/test/LinphoneTestManager.java @@ -479,7 +479,7 @@ public class LinphoneTestManager implements LinphoneCoreListener{ // TODO Auto-generated method stub } - + @Override public void friendListCreated(LinphoneCore lc, LinphoneFriendList list) { // TODO Auto-generated method stub