<commit_before>language: cpp

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
    - dist: trusty
      env: os_build=windows os_arch=x86
    - dist: trusty
      env: os_build=windows os_arch=x86_64
    - os: osx
      osx_image: xcode7.3
      env: os_build=macosx os_arch=x86_64

branches:
  only:
    - master

before_install:
# boost: download and bootstrap
  - wget -O boost.zip https://dl.bintray.com/boostorg/release/1.64.0/source/boost_1_64_0.zip
  - unzip -qq boost.zip
  - cd boost_1_64_0
  - ./bootstrap.sh
  - cd ..
  - export BOOST_ROOT=$PWD/boost_1_64_0

# openssl: download
  - wget -O openssl.tar.gz https://www.openssl.org/source/openssl-1.1.0f.tar.gz
  - tar xzf openssl.tar.gz
  - export OPENSSL_SOURCE=$PWD/openssl-1.1.0f
  # fix source code
  - if [ $os_build != "macosx" ]; then
      find $OPENSSL_SOURCE/crypto/sha/asm/ | egrep "armv4.*.pl" | xargs sed -i 's/.comm.*OPENSSL_armcap_P,4,4/.comm    OPENSSL_armcap_P,4,4\n.hidden  OPENSSL_armcap_P/g';
      find $OPENSSL_SOURCE/crypto | egrep "arm64cpuid.pl|ghashv8-armx.pl|aesv8-armx.pl" | xargs sed -i 's/.arch.*crypto//g';
      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 35491bc476876d22f1c4b9c970c97555bf1963ea
  - cd ..
  - export LIBTORRENT_ROOT=$PWD/libtorrent

# android ndk: download and create toolchain
  - if [ $os_build == "android" ]; then
      wget -O android-ndk.zip https://dl.google.com/android/repository/android-ndk-r15-linux-x86_64.zip;
      echo "Extracting NDK...wait";
      unzip -qq android-ndk.zip;
      export NDK=$PWD/android-ndk-r15;
      $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 == "android" && $os_arch == "arm" && $android_api == "16" ]]; then
      echo "unsigned long int getauxval(unsigned long int type) __attribute__((weak));" >> $PWD/android-toolchain/sysroot/usr/include/sys/auxv.h;
    fi

  - if [[ $os_build == "linux" || $os_build == "windows" ]]; then
      sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y;
      sudo apt-get update -qq;
      sudo apt-get install -qq g++-5;
    fi

  - if [[ $os_build == "linux" && $os_arch == "x86" ]]; then
      sudo add-apt-repository http://archive.ubuntu.com/ubuntu/ -y;
      sudo apt-get update -qq;
      sudo apt-get install -qq libc6-dev-i386;
      sudo apt-get install -qq lib32gcc-5-dev;
      sudo apt-get install -qq lib32stdc++-5-dev;
    fi

# linux cross compilation tools for windows development
# remove files related to libwinpthread dll
  - if [[ $os_build == "windows" ]]; then
      sudo apt-get install -qq mingw-w64;
      sudo add-apt-repository ppa:adrozdoff/mingw -y;
      sudo apt-get update -qq;
      sudo apt-get install -qq gcc-5-mingw-w64 g++-5-mingw-w64;
      sudo rm /usr/i686-w64-mingw32/lib/libwinpthread.dll.a;
      sudo rm /usr/i686-w64-mingw32/lib/libwinpthread-1.dll;
      sudo rm /usr/x86_64-w64-mingw32/lib/libwinpthread.dll.a;
      sudo rm /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll;
    fi

# install gradle in macOS to run the unit tests
  - if [ $os_build == "macosx" ]; then
      brew update > /dev/null && brew install --quiet gradle;
    fi

# openssl
  - 'export OPENSSL_NO_OPTS="no-afalgeng no-asan no-async no-autoalginit no-autoerrinit no-bf no-blake2
        no-camellia no-capieng no-cast no-chacha no-cmac no-cms no-comp no-crypto-mdebug
        no-crypto-mdebug-backtrace no-ct no-deprecated no-des no-dgram no-dh no-dsa no-dso
        no-dtls no-dynamic-engine no-ec no-ec2m no-ecdh no-ecdsa no-ec_nistp_64_gcc_128 no-egd
        no-engine no-err no-filenames no-fuzz-libfuzzer no-fuzz-afl no-gost no-heartbeats no-hw no-idea no-makedepend
        no-md2 no-md4 no-mdc2 no-msan no-multiblock no-nextprotoneg no-ocb no-ocsp no-pic no-poly1305
        no-posix-io no-psk no-rc2 no-rc4 no-rc5 no-rdrand no-rfc3779 no-rmd160
        no-scrypt no-sctp no-seed no-shared no-sock no-srp no-srtp no-ssl
        no-ssl-trace no-static-engine no-stdio no-threads no-tls no-ts no-ubsan no-ui no-unit-test
        no-whirlpool no-weak-ssl-ciphers no-zlib no-zlib-dynamic
        no-ssl3 no-tls1 no-tls1_1 no-tls1_2 no-dtls1 no-dtls1_2 -fno-strict-aliasing"'
  # 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 --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-5;
      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-5;
      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

# jlibtorrent
  # 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_strip="${ANDROID_TOOLCHAIN}/bin/arm-linux-androideabi-strip --strip-unneeded -x bin/release/android/armeabi-v7a/libjlibtorrent.so";
      export run_readelf="${ANDROID_TOOLCHAIN}/bin/arm-linux-androideabi-readelf -d bin/release/android/armeabi-v7a/libjlibtorrent.so";
      export PATH=$ANDROID_TOOLCHAIN/arm-linux-androideabi/bin:$PATH;
    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_strip="${ANDROID_TOOLCHAIN}/bin/aarch64-linux-android-strip --strip-unneeded -x bin/release/android/arm64-v8a/libjlibtorrent.so";
      export run_readelf="${ANDROID_TOOLCHAIN}/bin/aarch64-linux-android-readelf -d bin/release/android/arm64-v8a/libjlibtorrent.so";
      export PATH=$ANDROID_TOOLCHAIN/aarch64-linux-android/bin:$PATH;
    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_strip="${ANDROID_TOOLCHAIN}/bin/i686-linux-android-strip --strip-unneeded -x bin/release/android/x86/libjlibtorrent.so";
      export run_readelf="${ANDROID_TOOLCHAIN}/bin/i686-linux-android-readelf -d bin/release/android/x86/libjlibtorrent.so";
      export PATH=$ANDROID_TOOLCHAIN/i686-linux-android/bin:$PATH;
    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_strip="${ANDROID_TOOLCHAIN}/bin/x86_64-linux-android-strip --strip-unneeded -x bin/release/android/x86_64/libjlibtorrent.so";
      export run_readelf="${ANDROID_TOOLCHAIN}/bin/x86_64-linux-android-readelf -d bin/release/android/x86_64/libjlibtorrent.so";
      export PATH=$ANDROID_TOOLCHAIN/x86_64-linux-android/bin:$PATH;
    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_strip="strip --strip-unneeded -x bin/release/linux/x86/libjlibtorrent.so";
      export run_readelf="readelf -d bin/release/linux/x86/libjlibtorrent.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_strip="strip --strip-unneeded -x bin/release/linux/x86_64/libjlibtorrent.so";
      export run_readelf="readelf -d bin/release/linux/x86_64/libjlibtorrent.so";
    fi
  # windows-x86
  - if [[ $os_build == "windows" && $os_arch == "x86" ]]; then
      sed -i 's/ JNICALL Java_com_frostwire/ JNICALL _Java_com_frostwire/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/libjlibtorrent.dll";
      export run_readelf="eval objdump -p bin/release/windows/x86/jlibtorrent.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/libjlibtorrent.dll";
      export run_readelf="eval objdump -p bin/release/windows/x86_64/jlibtorrent.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/libjlibtorrent.dylib";
      export run_readelf="otool -L bin/release/macosx/x86_64/libjlibtorrent.dylib";
    fi

script:

  - cd $OPENSSL_SOURCE
  - $run_openssl_configure
  - echo "Compiling openssl...(remove &> /dev/null to see output)"
  - make &> /dev/null
  - make install &> /dev/null
  - cd ..
  - export OPENSSL_ROOT=$PWD/openssl

  - cd swig
  - $run_bjam
  - $run_strip
  - if [[ $os_build == "windows" && $os_arch == "x86" ]]; then
      mv bin/release/windows/x86/libjlibtorrent.dll bin/release/windows/x86/jlibtorrent.dll;
    fi
  - if [[ $os_build == "windows" && $os_arch == "x86_64" ]]; then
      mv bin/release/windows/x86_64/libjlibtorrent.dll bin/release/windows/x86_64/jlibtorrent.dll;
    fi
  - if [ $os_build == "macosx" ]; then
      cd ..;
      cp swig/bin/release/macosx/x86_64/libjlibtorrent.dylib .;
      gradle test;
      cd swig;
    fi
  - $run_readelf
  - cd ..

before_deploy:
  - cd swig/bin
  - find . -type f | egrep -v '.*\.so$|.*\.dll$|.*\.dylib$' | 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
<commit_msg>update to libtorrent master HEAD<commit_after>language: cpp

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
    - dist: trusty
      env: os_build=windows os_arch=x86
    - dist: trusty
      env: os_build=windows os_arch=x86_64
    - os: osx
      osx_image: xcode7.3
      env: os_build=macosx os_arch=x86_64

branches:
  only:
    - master

before_install:
# boost: download and bootstrap
  - wget -O boost.zip https://dl.bintray.com/boostorg/release/1.64.0/source/boost_1_64_0.zip
  - unzip -qq boost.zip
  - cd boost_1_64_0
  - ./bootstrap.sh
  - cd ..
  - export BOOST_ROOT=$PWD/boost_1_64_0

# openssl: download
  - wget -O openssl.tar.gz https://www.openssl.org/source/openssl-1.1.0f.tar.gz
  - tar xzf openssl.tar.gz
  - export OPENSSL_SOURCE=$PWD/openssl-1.1.0f
  # fix source code
  - if [ $os_build != "macosx" ]; then
      find $OPENSSL_SOURCE/crypto/sha/asm/ | egrep "armv4.*.pl" | xargs sed -i 's/.comm.*OPENSSL_armcap_P,4,4/.comm    OPENSSL_armcap_P,4,4\n.hidden  OPENSSL_armcap_P/g';
      find $OPENSSL_SOURCE/crypto | egrep "arm64cpuid.pl|ghashv8-armx.pl|aesv8-armx.pl" | xargs sed -i 's/.arch.*crypto//g';
      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 aa842948a3646d434eb1892a4a46262a22ee81ef
  - cd ..
  - export LIBTORRENT_ROOT=$PWD/libtorrent

# android ndk: download and create toolchain
  - if [ $os_build == "android" ]; then
      wget -O android-ndk.zip https://dl.google.com/android/repository/android-ndk-r15-linux-x86_64.zip;
      echo "Extracting NDK...wait";
      unzip -qq android-ndk.zip;
      export NDK=$PWD/android-ndk-r15;
      $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 == "android" && $os_arch == "arm" && $android_api == "16" ]]; then
      echo "unsigned long int getauxval(unsigned long int type) __attribute__((weak));" >> $PWD/android-toolchain/sysroot/usr/include/sys/auxv.h;
    fi

  - if [[ $os_build == "linux" || $os_build == "windows" ]]; then
      sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y;
      sudo apt-get update -qq;
      sudo apt-get install -qq g++-5;
    fi

  - if [[ $os_build == "linux" && $os_arch == "x86" ]]; then
      sudo add-apt-repository http://archive.ubuntu.com/ubuntu/ -y;
      sudo apt-get update -qq;
      sudo apt-get install -qq libc6-dev-i386;
      sudo apt-get install -qq lib32gcc-5-dev;
      sudo apt-get install -qq lib32stdc++-5-dev;
    fi

# linux cross compilation tools for windows development
# remove files related to libwinpthread dll
  - if [[ $os_build == "windows" ]]; then
      sudo apt-get install -qq mingw-w64;
      sudo add-apt-repository ppa:adrozdoff/mingw -y;
      sudo apt-get update -qq;
      sudo apt-get install -qq gcc-5-mingw-w64 g++-5-mingw-w64;
      sudo rm /usr/i686-w64-mingw32/lib/libwinpthread.dll.a;
      sudo rm /usr/i686-w64-mingw32/lib/libwinpthread-1.dll;
      sudo rm /usr/x86_64-w64-mingw32/lib/libwinpthread.dll.a;
      sudo rm /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll;
    fi

# install gradle in macOS to run the unit tests
  - if [ $os_build == "macosx" ]; then
      brew update > /dev/null && brew install --quiet gradle;
    fi

# openssl
  - 'export OPENSSL_NO_OPTS="no-afalgeng no-asan no-async no-autoalginit no-autoerrinit no-bf no-blake2
        no-camellia no-capieng no-cast no-chacha no-cmac no-cms no-comp no-crypto-mdebug
        no-crypto-mdebug-backtrace no-ct no-deprecated no-des no-dgram no-dh no-dsa no-dso
        no-dtls no-dynamic-engine no-ec no-ec2m no-ecdh no-ecdsa no-ec_nistp_64_gcc_128 no-egd
        no-engine no-err no-filenames no-fuzz-libfuzzer no-fuzz-afl no-gost no-heartbeats no-hw no-idea no-makedepend
        no-md2 no-md4 no-mdc2 no-msan no-multiblock no-nextprotoneg no-ocb no-ocsp no-pic no-poly1305
        no-posix-io no-psk no-rc2 no-rc4 no-rc5 no-rdrand no-rfc3779 no-rmd160
        no-scrypt no-sctp no-seed no-shared no-sock no-srp no-srtp no-ssl
        no-ssl-trace no-static-engine no-stdio no-threads no-tls no-ts no-ubsan no-ui no-unit-test
        no-whirlpool no-weak-ssl-ciphers no-zlib no-zlib-dynamic
        no-ssl3 no-tls1 no-tls1_1 no-tls1_2 no-dtls1 no-dtls1_2 -fno-strict-aliasing"'
  # 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 --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-5;
      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-5;
      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

# jlibtorrent
  # 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_strip="${ANDROID_TOOLCHAIN}/bin/arm-linux-androideabi-strip --strip-unneeded -x bin/release/android/armeabi-v7a/libjlibtorrent.so";
      export run_readelf="${ANDROID_TOOLCHAIN}/bin/arm-linux-androideabi-readelf -d bin/release/android/armeabi-v7a/libjlibtorrent.so";
      export PATH=$ANDROID_TOOLCHAIN/arm-linux-androideabi/bin:$PATH;
    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_strip="${ANDROID_TOOLCHAIN}/bin/aarch64-linux-android-strip --strip-unneeded -x bin/release/android/arm64-v8a/libjlibtorrent.so";
      export run_readelf="${ANDROID_TOOLCHAIN}/bin/aarch64-linux-android-readelf -d bin/release/android/arm64-v8a/libjlibtorrent.so";
      export PATH=$ANDROID_TOOLCHAIN/aarch64-linux-android/bin:$PATH;
    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_strip="${ANDROID_TOOLCHAIN}/bin/i686-linux-android-strip --strip-unneeded -x bin/release/android/x86/libjlibtorrent.so";
      export run_readelf="${ANDROID_TOOLCHAIN}/bin/i686-linux-android-readelf -d bin/release/android/x86/libjlibtorrent.so";
      export PATH=$ANDROID_TOOLCHAIN/i686-linux-android/bin:$PATH;
    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_strip="${ANDROID_TOOLCHAIN}/bin/x86_64-linux-android-strip --strip-unneeded -x bin/release/android/x86_64/libjlibtorrent.so";
      export run_readelf="${ANDROID_TOOLCHAIN}/bin/x86_64-linux-android-readelf -d bin/release/android/x86_64/libjlibtorrent.so";
      export PATH=$ANDROID_TOOLCHAIN/x86_64-linux-android/bin:$PATH;
    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_strip="strip --strip-unneeded -x bin/release/linux/x86/libjlibtorrent.so";
      export run_readelf="readelf -d bin/release/linux/x86/libjlibtorrent.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_strip="strip --strip-unneeded -x bin/release/linux/x86_64/libjlibtorrent.so";
      export run_readelf="readelf -d bin/release/linux/x86_64/libjlibtorrent.so";
    fi
  # windows-x86
  - if [[ $os_build == "windows" && $os_arch == "x86" ]]; then
      sed -i 's/ JNICALL Java_com_frostwire/ JNICALL _Java_com_frostwire/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/libjlibtorrent.dll";
      export run_readelf="eval objdump -p bin/release/windows/x86/jlibtorrent.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/libjlibtorrent.dll";
      export run_readelf="eval objdump -p bin/release/windows/x86_64/jlibtorrent.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/libjlibtorrent.dylib";
      export run_readelf="otool -L bin/release/macosx/x86_64/libjlibtorrent.dylib";
    fi

script:

  - cd $OPENSSL_SOURCE
  - $run_openssl_configure
  - echo "Compiling openssl...(remove &> /dev/null to see output)"
  - make &> /dev/null
  - make install &> /dev/null
  - cd ..
  - export OPENSSL_ROOT=$PWD/openssl

  - cd swig
  - $run_bjam
  - $run_strip
  - if [[ $os_build == "windows" && $os_arch == "x86" ]]; then
      mv bin/release/windows/x86/libjlibtorrent.dll bin/release/windows/x86/jlibtorrent.dll;
    fi
  - if [[ $os_build == "windows" && $os_arch == "x86_64" ]]; then
      mv bin/release/windows/x86_64/libjlibtorrent.dll bin/release/windows/x86_64/jlibtorrent.dll;
    fi
  - if [ $os_build == "macosx" ]; then
      cd ..;
      cp swig/bin/release/macosx/x86_64/libjlibtorrent.dylib .;
      gradle test;
      cd swig;
    fi
  - $run_readelf
  - cd ..

before_deploy:
  - cd swig/bin
  - find . -type f | egrep -v '.*\.so$|.*\.dll$|.*\.dylib$' | 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

{'fraction_non_alphanumeric': 0.14794878695836056, 'fraction_numerical': 0.04094736437387058, 'mean_word_length': 3.3444128946049774, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 8, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6360491', 'n_tokens_mistral': 10881, 'n_tokens_neox': 10037, 'n_words': 1724}