Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
256 lines (237 sloc) 13.2 KB
language: cpp
dist: xenial
matrix:
include:
- env: os_build=android os_arch=arm android_api=16
- env: os_build=android os_arch=arm64 android_api=21
- env: os_build=android os_arch=x86 android_api=16
- env: os_build=android os_arch=x86_64 android_api=21
- env: os_build=linux os_arch=x86
- env: os_build=linux os_arch=x86_64
- env: os_build=windows os_arch=x86
- env: os_build=windows os_arch=x86_64
- os: osx
env: os_build=macosx os_arch=x86_64
branches:
only:
- master
before_install:
# boost: download and bootstrap
- wget -nv -O boost.zip https://dl.bintray.com/boostorg/release/1.70.0/source/boost_1_70_0.zip
- unzip -qq boost.zip
- cd boost_1_70_0
- ./bootstrap.sh
- cd ..
- export BOOST_ROOT=$PWD/boost_1_70_0
# openssl: download
- wget -nv -O openssl.tar.gz https://www.openssl.org/source/openssl-1.1.1b.tar.gz
- tar xzf openssl.tar.gz
- export OPENSSL_SOURCE=$PWD/openssl-1.1.1b
# fix source code
# this one avoid GDI dependency in windows
- if [ $os_build == "windows" ]; then
sed -i 's/if defined(_WIN32_WINNT) && _WIN32_WINNT>=0x0333/if 0/g' $OPENSSL_SOURCE/crypto/cryptlib.c;
sed -i 's/MessageBox.*//g' $OPENSSL_SOURCE/crypto/cryptlib.c;
fi
# libtorrent: download and checkout revision
- git clone https://github.com/arvidn/libtorrent
- cd libtorrent
- git checkout 4b268297c4cf7beefd6d90e45e2f5c2a2284a870
- cd ..
- export LIBTORRENT_ROOT=$PWD/libtorrent
# perform android specific modifications for posix calls
- if [ $os_build == "android" ]; then
cp swig/posix_wrapper.h $LIBTORRENT_ROOT/include/libtorrent;
sed -i '134c#include "libtorrent/posix_wrapper.h"' $LIBTORRENT_ROOT/src/file.cpp;
sed -i 's/ ::open(/posix_open(/g' $LIBTORRENT_ROOT/src/file.cpp;
sed -i '106c#include "libtorrent/posix_wrapper.h"' $LIBTORRENT_ROOT/src/path.cpp;
sed -i 's/ ::open(/posix_open(/g' $LIBTORRENT_ROOT/src/path.cpp;
sed -i 's/ ::stat(/posix_stat(/g' $LIBTORRENT_ROOT/src/path.cpp;
sed -i 's/ ::mkdir(/posix_mkdir(/g' $LIBTORRENT_ROOT/src/path.cpp;
sed -i 's/ ::remove(/posix_remove(/g' $LIBTORRENT_ROOT/src/path.cpp;
fi
# android ndk: download and create toolchain
- if [ $os_build == "android" ]; then
wget -nv -O android-ndk.zip https://dl.google.com/android/repository/android-ndk-r19c-linux-x86_64.zip;
echo "Extracting NDK...wait";
unzip -qq android-ndk.zip;
export NDK=$PWD/android-ndk-r19c;
$NDK/build/tools/make_standalone_toolchain.py --arch $os_arch --api $android_api --stl libc++ --install-dir android-toolchain;
export ANDROID_TOOLCHAIN=$PWD/android-toolchain;
fi
- if [[ $os_build == "linux" || $os_build == "windows" ]]; then
sudo apt-get install -qq g++-5;
fi
- if [[ $os_build == "linux" && $os_arch == "x86" ]]; then
sudo apt-get install -qq libc6-dev-i386;
sudo apt-get install -qq lib32gcc-5-dev;
sudo apt-get install -qq lib32stdc++-5-dev;
sudo ln -s /usr/include/asm-generic /usr/include/asm;
fi
# linux cross compilation tools for windows development
- if [[ $os_build == "windows" && $os_arch == "x86" ]]; then
sudo apt-get install -qq g++-mingw-w64-i686;
fi
- if [[ $os_build == "windows" && $os_arch == "x86_64" ]]; then
sudo apt-get install -qq g++-mingw-w64-x86-64;
fi
# install gradle in macOS to run the unit tests
- if [ $os_build == "macosx" ]; then
brew update > /dev/null && brew install gradle;
fi
# openssl
- 'export OPENSSL_NO_OPTS="no-afalgeng no-async no-autoalginit no-autoerrinit
no-capieng no-cms no-comp no-deprecated no-dgram no-dso no-dtls
no-dynamic-engine no-egd no-engine no-err no-filenames no-gost no-hw
no-makedepend no-multiblock no-nextprotoneg no-posix-io no-psk
no-rdrand no-sctp no-shared no-sock no-srp no-srtp no-static-engine
no-stdio no-threads no-ui-console no-zlib no-zlib-dynamic
-fno-strict-aliasing -fvisibility=hidden -Os"'
# android-arm
- if [[ $os_build == "android" && $os_arch == "arm" ]]; then
export CC=$ANDROID_TOOLCHAIN/bin/arm-linux-androideabi-clang;
export run_openssl_configure="./Configure linux-armv4 ${OPENSSL_NO_OPTS} -march=armv7-a -mfpu=neon -fPIC --prefix=$OPENSSL_SOURCE/../openssl";
fi
# android-arm64
- if [[ $os_build == "android" && $os_arch == "arm64" ]]; then
export CC=$ANDROID_TOOLCHAIN/bin/aarch64-linux-android-clang;
export run_openssl_configure="./Configure linux-aarch64 ${OPENSSL_NO_OPTS} -march=armv8-a+crypto -fPIC --prefix=$OPENSSL_SOURCE/../openssl";
fi
# android-x86
- if [[ $os_build == "android" && $os_arch == "x86" ]]; then
export CC=$ANDROID_TOOLCHAIN/bin/i686-linux-android-clang;
export run_openssl_configure="./Configure linux-elf ${OPENSSL_NO_OPTS} -fPIC -mstackrealign --prefix=$OPENSSL_SOURCE/../openssl";
fi
# android-x86_64
- if [[ $os_build == "android" && $os_arch == "x86_64" ]]; then
export CC=$ANDROID_TOOLCHAIN/bin/x86_64-linux-android-clang;
export run_openssl_configure="./Configure linux-x86_64 ${OPENSSL_NO_OPTS} -fPIC --prefix=$OPENSSL_SOURCE/../openssl";
fi
# linux-x86
- if [[ $os_build == "linux" && $os_arch == "x86" ]]; then
export CC=gcc-5;
export run_openssl_configure="./Configure linux-elf ${OPENSSL_NO_OPTS} -fPIC -m32 --prefix=$OPENSSL_SOURCE/../openssl";
fi
# linux-x86_64
- if [[ $os_build == "linux" && $os_arch == "x86_64" ]]; then
export CC=gcc-5;
export run_openssl_configure="./Configure linux-x86_64 ${OPENSSL_NO_OPTS} -fPIC --prefix=$OPENSSL_SOURCE/../openssl";
fi
# windows-x86
- if [[ $os_build == "windows" && $os_arch == "x86" ]]; then
export CC=i686-w64-mingw32-gcc-posix;
export run_openssl_configure="./Configure mingw ${OPENSSL_NO_OPTS} --prefix=$OPENSSL_SOURCE/../openssl";
fi
# windows-x86_64
- if [[ $os_build == "windows" && $os_arch == "x86_64" ]]; then
export CC=x86_64-w64-mingw32-gcc-posix;
export run_openssl_configure="./Configure mingw64 ${OPENSSL_NO_OPTS} --prefix=$OPENSSL_SOURCE/../openssl";
fi
# macosx
- if [ $os_build == "macosx" ]; then
export run_openssl_configure="./Configure darwin64-x86_64-cc ${OPENSSL_NO_OPTS} --prefix=$OPENSSL_SOURCE/../openssl";
fi
# libtorrent4j
# android-arm
- if [[ $os_build == "android" && $os_arch == "arm" ]]; then
export run_bjam="${BOOST_ROOT}/b2 --user-config=config/android-arm-config.jam variant=release toolset=clang-linux-arm target-os=android location=bin/release/android/armeabi-v7a";
export run_objcopy="${ANDROID_TOOLCHAIN}/bin/arm-linux-androideabi-objcopy --only-keep-debug bin/release/android/armeabi-v7a/libtorrent4j.so bin/release/android/armeabi-v7a/libtorrent4j.so.debug";
export run_strip="${ANDROID_TOOLCHAIN}/bin/arm-linux-androideabi-strip --strip-unneeded -x -g bin/release/android/armeabi-v7a/libtorrent4j.so";
export run_readelf="${ANDROID_TOOLCHAIN}/bin/arm-linux-androideabi-readelf -d bin/release/android/armeabi-v7a/libtorrent4j.so";
export PATH=$ANDROID_TOOLCHAIN/arm-linux-androideabi/bin:$PATH;
sed -i 's/RANLIB = ranlib/RANLIB = "${ANDROID_TOOLCHAIN}\/bin\/arm-linux-androideabi-ranlib"/g' ${BOOST_ROOT}/tools/build/src/tools/gcc.jam;
fi
# android-arm64
- if [[ $os_build == "android" && $os_arch == "arm64" ]]; then
export run_bjam="${BOOST_ROOT}/b2 --user-config=config/android-arm64-config.jam variant=release toolset=clang-arm64 target-os=android location=bin/release/android/arm64-v8a";
export run_objcopy="${ANDROID_TOOLCHAIN}/bin/aarch64-linux-android-objcopy --only-keep-debug bin/release/android/arm64-v8a/libtorrent4j.so bin/release/android/arm64-v8a/libtorrent4j.so.debug";
export run_strip="${ANDROID_TOOLCHAIN}/bin/aarch64-linux-android-strip --strip-unneeded -x bin/release/android/arm64-v8a/libtorrent4j.so";
export run_readelf="${ANDROID_TOOLCHAIN}/bin/aarch64-linux-android-readelf -d bin/release/android/arm64-v8a/libtorrent4j.so";
export PATH=$ANDROID_TOOLCHAIN/aarch64-linux-android/bin:$PATH;
sed -i 's/RANLIB = ranlib/RANLIB = "${ANDROID_TOOLCHAIN}\/bin\/aarch64-linux-android-ranlib"/g' ${BOOST_ROOT}/tools/build/src/tools/gcc.jam;
fi
# android-x86
- if [[ $os_build == "android" && $os_arch == "x86" ]]; then
export run_bjam="${BOOST_ROOT}/b2 --user-config=config/android-x86-config.jam variant=release toolset=clang-x86 target-os=android location=bin/release/android/x86";
export run_objcopy="${ANDROID_TOOLCHAIN}/bin/i686-linux-android-objcopy --only-keep-debug bin/release/android/x86/libtorrent4j.so bin/release/android/x86/libtorrent4j.so.debug";
export run_strip="${ANDROID_TOOLCHAIN}/bin/i686-linux-android-strip --strip-unneeded -x -g bin/release/android/x86/libtorrent4j.so";
export run_readelf="${ANDROID_TOOLCHAIN}/bin/i686-linux-android-readelf -d bin/release/android/x86/libtorrent4j.so";
export PATH=$ANDROID_TOOLCHAIN/i686-linux-android/bin:$PATH;
sed -i 's/RANLIB = ranlib/RANLIB = "${ANDROID_TOOLCHAIN}\/bin\/i686-linux-android-ranlib"/g' ${BOOST_ROOT}/tools/build/src/tools/gcc.jam;
fi
# android-x86_64
- if [[ $os_build == "android" && $os_arch == "x86_64" ]]; then
export run_bjam="${BOOST_ROOT}/b2 --user-config=config/android-x86_64-config.jam variant=release toolset=clang-x86_64 target-os=android location=bin/release/android/x86_64";
export run_objcopy="${ANDROID_TOOLCHAIN}/bin/x86_64-linux-android-objcopy --only-keep-debug bin/release/android/x86_64/libtorrent4j.so bin/release/android/x86_64/libtorrent4j.so.debug";
export run_strip="${ANDROID_TOOLCHAIN}/bin/x86_64-linux-android-strip --strip-unneeded -x bin/release/android/x86_64/libtorrent4j.so";
export run_readelf="${ANDROID_TOOLCHAIN}/bin/x86_64-linux-android-readelf -d bin/release/android/x86_64/libtorrent4j.so";
export PATH=$ANDROID_TOOLCHAIN/x86_64-linux-android/bin:$PATH;
sed -i 's/RANLIB = ranlib/RANLIB = "${ANDROID_TOOLCHAIN}\/bin\/x86_64-linux-android-ranlib"/g' ${BOOST_ROOT}/tools/build/src/tools/gcc.jam;
fi
# linux-x86
- if [[ $os_build == "linux" && $os_arch == "x86" ]]; then
export run_bjam="${BOOST_ROOT}/b2 --user-config=config/linux-x86-config.jam variant=release toolset=gcc-x86 target-os=linux location=bin/release/linux/x86";
export run_objcopy="objcopy --only-keep-debug bin/release/linux/x86/libtorrent4j.so bin/release/linux/x86/libtorrent4j.so.debug";
export run_strip="strip --strip-unneeded -x bin/release/linux/x86/libtorrent4j.so";
export run_readelf="readelf -d bin/release/linux/x86/libtorrent4j.so";
fi
# linux-x86_64
- if [[ $os_build == "linux" && $os_arch == "x86_64" ]]; then
export run_bjam="${BOOST_ROOT}/b2 --user-config=config/linux-x86_64-config.jam variant=release toolset=gcc-x86_64 target-os=linux location=bin/release/linux/x86_64";
export run_objcopy="objcopy --only-keep-debug bin/release/linux/x86_64/libtorrent4j.so bin/release/linux/x86_64/libtorrent4j.so.debug";
export run_strip="strip --strip-unneeded -x bin/release/linux/x86_64/libtorrent4j.so";
export run_readelf="readelf -d bin/release/linux/x86_64/libtorrent4j.so";
fi
# windows-x86
- if [[ $os_build == "windows" && $os_arch == "x86" ]]; then
sed -i 's/ JNICALL Java_org_libtorrent4j/ JNICALL _Java_org_libtorrent4j/g' swig/libtorrent_jni.cpp;
export run_bjam="${BOOST_ROOT}/b2 --user-config=config/windows-x86-config.jam variant=release toolset=gcc-x86 target-os=windows location=bin/release/windows/x86";
export run_strip="i686-w64-mingw32-strip --strip-unneeded -x bin/release/windows/x86/libtorrent4j.dll";
export run_readelf="eval objdump -p bin/release/windows/x86/libtorrent4j.dll | grep DLL";
fi
# windows-x86_64
- if [[ $os_build == "windows" && $os_arch == "x86_64" ]]; then
export run_bjam="${BOOST_ROOT}/b2 --user-config=config/windows-x86_64-config.jam variant=release toolset=gcc-x86_64 target-os=windows location=bin/release/windows/x86_64";
export run_strip="x86_64-w64-mingw32-strip --strip-unneeded -x bin/release/windows/x86_64/libtorrent4j.dll";
export run_readelf="eval objdump -p bin/release/windows/x86_64/libtorrent4j.dll | grep DLL";
fi
# macosx
- if [ $os_build == "macosx" ]; then
export run_bjam="${BOOST_ROOT}/b2 --user-config=config/macosx-x86_64-config.jam variant=release toolset=darwin-x86_64 target-os=darwin location=bin/release/macosx/x86_64";
export run_strip="strip -S -x bin/release/macosx/x86_64/libtorrent4j.dylib";
export run_readelf="otool -L bin/release/macosx/x86_64/libtorrent4j.dylib";
fi
script:
- cd $OPENSSL_SOURCE
- $run_openssl_configure
- echo "Compiling openssl...(remove &> /dev/null to see output)"
- make &> /dev/null
- make install_sw &> /dev/null
- cd ..
- export OPENSSL_ROOT=$PWD/openssl
- cd swig
- $run_bjam
- $run_objcopy
- $run_strip
- if [ $os_build == "macosx" ]; then
cd ..;
cp swig/bin/release/macosx/x86_64/libtorrent4j.dylib .;
gradle test;
cd swig;
fi
- $run_readelf
- cd ..
before_deploy:
- cd swig/bin
- find . -type f | egrep -v '.*\.so$|.*\.dll$|.*\.dylib$|.*\.debug$' | xargs rm
- find . -empty -type d | xargs rm -r
- cd ../..
deploy:
provider: s3
access_key_id: $S3_ACCESS_KEY
secret_access_key: $S3_SECRET_KEY
bucket: $S3_BUCKET
skip_cleanup: true
local_dir: swig/bin
on:
all_branches: true
You can’t perform that action at this time.