Skip to content

Commit

Permalink
travis build
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoArella authored and gavv committed May 27, 2020
1 parent 0502b15 commit 651cfe0
Show file tree
Hide file tree
Showing 24 changed files with 473 additions and 1 deletion.
39 changes: 39 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
language: java
dist: bionic

jdk:
- openjdk10
- openjdk11

jobs:
include:
- dist: xenial
jdk: openjdk10
- dist: xenial
jdk: openjdk11
- os: osx
osx_image: xcode10.1
jdk: openjdk10
- os: osx
osx_image: xcode10.1
jdk: openjdk11
- os: osx
osx_image: xcode11.3
jdk: openjdk10
- os: osx
osx_image: xcode11.3
jdk: openjdk11
- name: "android"
jdk: openjdk11
sudo: required
services:
- docker
env:
- DIST=android ANDROID_API=28 ANDROID_NDK_VERSION=21.1.6352462 ANDROID_BUILD_TOOLS_VERSION=28.0.3 ROC_BASE_DIR=$HOME/roc

before_install:
- if [ ! -z $DIST ]; then source scripts/travis/$DIST/env.sh && scripts/travis/$DIST/before_install.sh; else scripts/travis/$TRAVIS_OS_NAME/before_install.sh; fi
install:
- if [ ! -z $DIST ]; then scripts/travis/$DIST/install.sh; else scripts/travis/$TRAVIS_OS_NAME/install.sh; fi
script:
- if [ ! -z $DIST ]; then scripts/travis/$DIST/script.sh; else scripts/travis/$TRAVIS_OS_NAME/script.sh; fi
14 changes: 14 additions & 0 deletions android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
1 change: 1 addition & 0 deletions android/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
7 changes: 7 additions & 0 deletions android/app/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.github.rocproject.roc">

<application/>

</manifest>
74 changes: 74 additions & 0 deletions android/app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html

# Sets the minimum version of CMake required to build the native library.

cmake_minimum_required(VERSION 3.4.1)

set(ROC_JNI_BASE_DIR "../../roc_jni")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.

add_library( # Sets the name of the library.
roc-java

# Sets the library as a shared library.
SHARED

# Provides a relative path to your source file(s).
${ROC_JNI_BASE_DIR}/src/main/cpp/address.cpp
${ROC_JNI_BASE_DIR}/src/main/cpp/channel_set.cpp
${ROC_JNI_BASE_DIR}/src/main/cpp/common.cpp
${ROC_JNI_BASE_DIR}/src/main/cpp/context.cpp
${ROC_JNI_BASE_DIR}/src/main/cpp/family.cpp
${ROC_JNI_BASE_DIR}/src/main/cpp/fec_code.cpp
${ROC_JNI_BASE_DIR}/src/main/cpp/frame_encoding.cpp
${ROC_JNI_BASE_DIR}/src/main/cpp/logger.cpp
${ROC_JNI_BASE_DIR}/src/main/cpp/log_level.cpp
${ROC_JNI_BASE_DIR}/src/main/cpp/packet_encoding.cpp
${ROC_JNI_BASE_DIR}/src/main/cpp/port_type.cpp
${ROC_JNI_BASE_DIR}/src/main/cpp/protocol.cpp
${ROC_JNI_BASE_DIR}/src/main/cpp/receiver.cpp
${ROC_JNI_BASE_DIR}/src/main/cpp/resampler_profile.cpp
${ROC_JNI_BASE_DIR}/src/main/cpp/sender.cpp
)

include_directories(${ROC_JNI_BASE_DIR}/src/main/headers/
${ROC_JNI_BASE_DIR}/src/main/public/
)

target_include_directories(roc-java PRIVATE
${ROC_BASE_DIR}/include/${ANDROID_ABI}
)

# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.

find_library( # Sets the name of the path variable.
log-lib
# Specifies the name of the NDK library that
# you want CMake to locate.
log )

# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.
add_library(lib_roc SHARED IMPORTED)
set_target_properties(lib_roc PROPERTIES IMPORTED_LOCATION
${ROC_BASE_DIR}/lib/${ANDROID_ABI}/libroc.so)

target_link_libraries( # Specifies the target library.
roc-java

lib_roc
# Links the target library to the log library
# included in the NDK.
${log-lib} )
74 changes: 74 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
apply plugin: 'com.android.library'
apply plugin: "de.mannodermaus.android-junit5"

ext {
apiLevel = System.getProperty('ANDROID_API') ?: System.getenv('ANDROID_API')
buildToolsVersion = System.getProperty('ANDROID_BUILD_TOOLS_VERSION') ?: System.getenv('ANDROID_BUILD_TOOLS_VERSION')
androidNdkVersion = System.getProperty('ANDROID_NDK_VERSION') ?: System.getenv('ANDROID_NDK_VERSION')
ROC_BASE_DIR = System.getProperty('ROC_BASE_DIR') ?: System.getenv('ROC_BASE_DIR')
}

android {
compileSdkVersion "${apiLevel}".toInteger()
buildToolsVersion "${buildToolsVersion}"
ndkVersion "${androidNdkVersion}"

defaultConfig {
minSdkVersion 26
targetSdkVersion "${apiLevel}".toInteger()
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArgument "runnerBuilder", "de.mannodermaus.junit5.AndroidJUnit5Builder"

externalNativeBuild {
cmake {
arguments "-DROC_BASE_DIR=${ROC_BASE_DIR}"
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

packagingOptions {
exclude "META-INF/LICENSE*"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
java.srcDirs = ["${rootProject.projectDir.absolutePath}/../src/main/java", "src/main/java"]
// pack roc shared library into aar
jniLibs.srcDirs = ["${ROC_BASE_DIR}/lib"]
manifest.srcFile 'AndroidManifest.xml'
}

androidTest {
java.srcDirs = [ "${rootProject.projectDir.absolutePath}/../src/test/java", "src/test/java" ]
setRoot "${rootProject.projectDir.absolutePath}/../src/test"
}
}

externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

androidTestImplementation "androidx.test:runner:1.2.0"
androidTestImplementation "org.junit.jupiter:junit-jupiter-api:5.6.2"
androidTestImplementation "de.mannodermaus.junit5:android-test-core:1.2.0"
androidTestRuntimeOnly "de.mannodermaus.junit5:android-test-runner:1.2.0"
}
21 changes: 21 additions & 0 deletions android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
25 changes: 25 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
buildscript {
repositories {
google()
jcenter()
mavenCentral()

}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath "de.mannodermaus.gradle.plugins:android-junit5:1.5.2.0"
}
}

allprojects {
repositories {
google()
jcenter()
mavenCentral()

}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
20 changes: 20 additions & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

3 changes: 3 additions & 0 deletions android/gradlew
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env sh

exec "$(dirname "$0")/../gradlew" "$@"
2 changes: 2 additions & 0 deletions android/gradlew.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
call ..\gradlew.bat %*
1 change: 1 addition & 0 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ':app'
2 changes: 1 addition & 1 deletion roc_jni/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def getJniPaths() {
ext {
rocIncludePath = System.getProperty('ROC_INCLUDE_PATH') ?: System.getenv('ROC_INCLUDE_PATH')
rocLibraryPath = System.getProperty('ROC_LIBRARY_PATH') ?: System.getenv('ROC_LIBRARY_PATH')
CFLAGS = System.getProperty('CFLAGS') ? System.getProperty('CFLAGS').split(" ") : []
CFLAGS = System.getProperty('CFLAGS') ? System.getProperty('CFLAGS').split(" ") + "-std=c++11": ["-std=c++11"]
LDFLAGS = System.getProperty('LDFLAGS') ? System.getProperty('LDFLAGS').split(" ") + "-lroc" : ['-lroc']
}

Expand Down
50 changes: 50 additions & 0 deletions scripts/travis/android/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
FROM debian:stable

ENV DEBIAN_FRONTEND noninteractive

ARG NDK="21"
ARG API="28"

RUN apt-get update

# native compilers
RUN apt-get install -y g++

# tools
RUN apt-get install -y \
scons \
ragel \
gengetopt \
python \
unzip \
wget

# Roc dependencies
RUN apt-get install -y \
libtool \
intltool \
autoconf \
automake \
automake-1.15 \
pkg-config \
make \
cmake

# toolchain
RUN wget -q -O /tmp/ndk.zip \
"https://dl.google.com/android/repository/android-ndk-r${NDK}-linux-x86_64.zip" && \
( cd /tmp && unzip -qq ndk.zip -d /opt) && \
rm /tmp/ndk.zip

# for roc build
# use bash instead of default sh
RUN ["/bin/bash", "-c", "cd /opt/android-ndk-r${NDK}/toolchains/llvm/prebuilt/linux-x86_64/bin && \
for f in *androideabi*; do ln -s $f ${f/androideabi/android}; done && \
for f in *$API-clang; do ln -s $f ${f/$API/} && ln -s $f ${f/$API-clang/-gcc}; done && \
for f in *$API-clang++; do ln -s $f ${f/$API/}; done && \
ln -s armv7a-linux-android-clang arm-linux-android-clang && \
ln -s armv7a-linux-android-clang++ arm-linux-android-clang++ && \
ln -s armv7a-linux-android-gcc arm-linux-android-gcc"]

# path
ENV PATH="/opt/android-ndk-r${NDK}/toolchains/llvm/prebuilt/linux-x86_64/bin:${PATH}"
33 changes: 33 additions & 0 deletions scripts/travis/android/before_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
set -euxo pipefail

work_dir=$(pwd)

# setup android sdk tools cli
wget -q "https://dl.google.com/android/repository/commandlinetools-linux-6200805_latest.zip" -O cmd-tools.zip
mkdir -p $ANDROID_SDK_ROOT/cmdline-tools
unzip -qq cmd-tools.zip -d $ANDROID_SDK_ROOT/cmdline-tools

cd $ANDROID_SDK_ROOT/cmdline-tools/tools/bin
mkdir jaxb_lib
wget -q https://repo1.maven.org/maven2/javax/activation/activation/1.1.1/activation-1.1.1.jar -O jaxb_lib/activation.jar
wget -q https://repo1.maven.org/maven2/javax/xml/jaxb-impl/2.1/jaxb-impl-2.1.jar -O jaxb_lib/jaxb-impl.jar
wget -q https://repo1.maven.org/maven2/org/glassfish/jaxb/jaxb-xjc/2.3.2/jaxb-xjc-2.3.2.jar -O jaxb_lib/jaxb-xjc.jar
wget -q https://repo1.maven.org/maven2/org/glassfish/jaxb/jaxb-core/2.3.0.1/jaxb-core-2.3.0.1.jar -O jaxb_lib/jaxb-core.jar
wget -q https://repo1.maven.org/maven2/org/glassfish/jaxb/jaxb-jxc/2.3.2/jaxb-jxc-2.3.2.jar -O jaxb_lib/jaxb-jxc.jar
wget -q https://repo1.maven.org/maven2/org/glassfish/jaxb/jaxb-runtime/2.3.1/jaxb-runtime-2.3.1.jar -O jaxb_lib/jaxb-runtime.jar
wget -q https://repo1.maven.org/maven2/javax/xml/bind/jaxb-api/2.3.1/jaxb-api-2.3.1.jar -O jaxb_lib/jaxb-api.jar

# add jaxb to sdkmanager classpath
sed '/CLASSPATH=[$]APP_HOME/ a CLASSPATH=$CLASSPATH:$APP_HOME/bin/jaxb_lib/activation.jar:$APP_HOME/bin/jaxb_lib/jaxb-impl.jar:$APP_HOME/bin/jaxb_lib/jaxb-xjc.jar:$APP_HOME/bin/jaxb_lib/jaxb-runtime.jar:$APP_HOME/bin/jaxb_lib/jaxb-core.jar:$APP_HOME/bin/jaxb_lib/jaxb-jxc.jar:$APP_HOME/bin/jaxb_lib/jaxb-api.jar' sdkmanager > sdkmanager.tmp
chmod +x sdkmanager.tmp
mv -f sdkmanager.tmp sdkmanager

mkdir -p $HOME/.android && touch $HOME/.android/repositories.cfg

cd $work_dir
NDK=$(echo $ANDROID_NDK_VERSION | cut -d "." -f1)
docker build -t cross-linux-android:api$ANDROID_API \
-f scripts/travis/android/Dockerfile \
--build-arg NDK=$NDK \
--build-arg API=$ANDROID_API .
6 changes: 6 additions & 0 deletions scripts/travis/android/env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

export ANDROID_SDK_ROOT=$HOME/sdk
export ANDROID_NDK_ROOT=$ANDROID_SDK_ROOT/ndk-bundle
export PATH=$PATH:$ANDROID_SDK_ROOT/cmdline-tools/tools/bin

Loading

0 comments on commit 651cfe0

Please sign in to comment.