Skip to content
This repository has been archived by the owner on May 16, 2020. It is now read-only.

[travis] add linux appimage and android apk #258

Merged
merged 2 commits into from
Nov 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.DS_Store
orion.pro.user*
build
libs
android/gradle*
android/local*
android/build*
Expand Down
62 changes: 42 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,59 @@
os:
- osx

env:
- QTBREWVER=5.9

dist: trusty
language: cpp

compiler:
- clang


matrix:
fast_finish: false
include:
- os: osx
env:
- PLATFORM=osx
- BACKEND=multimedia
compiler: clang

- os: linux
env:
- PLATFORM=linux
- BACKEND=mpv
compiler: gcc

- os: linux
env:
- PLATFORM=android
- BACKEND=multimedia
compiler: gcc

cache:
apt: true
directories:
- $HOME/Library/Caches/Homebrew
- $HOME/mpv

before_install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository -y ppa:apt-fast/stable && sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt-get update && sudo apt-get -y -qq install apt-fast; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-fast -y install g++-7 > /dev/null; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 90; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 90; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install qt5 jq; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then pip2 install dmgbuild; fi

install:
- ci/prepare_$PLATFORM.sh
- source ci/$PLATFORM.env
- cd $TRAVIS_BUILD_DIR

script:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export QTDIR=$(brew info --json=v1 qt | jq -r '.[0].bottle.stable.cellar + "/" + .[0].name + "/" + .[0].installed[0].version'); fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export ORIONCONFIG=multimedia; fi
- $QTDIR/bin/qmake orion.pro CONFIG+=$ORIONCONFIG
- make
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then bash distfiles/deploy_mac.sh; fi
- mkdir -p artifacts
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then dmgbuild -s distfiles/settings.py "Orion $TRAVIS_TAG" "orion-$TRAVIS_TAG.dmg"; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then mv "orion-$TRAVIS_TAG.dmg" artifacts/; fi

- $QTDIR/bin/qmake orion.pro CONFIG+=$BACKEND
- make -j2
- mkdir -p artifacts && ci/deploy_$PLATFORM.sh $TRAVIS_BUILD_DIR/artifacts

deploy:
- provider: releases
# To use this, create a Github token with the "public_repo" permission, and create an env var GITHUB_API_KEY in the Travis' project settings, making sure "Display value in build log" is set to OFF
api_key: '$GITHUB_API_KEY'
file: 'artifacts/orion-$TRAVIS_TAG.dmg'
file:
- 'artifacts/orion-$PLATFORM-$TRAVIS_TAG.dmg'
- 'artifacts/orion-$PLATFORM-$TRAVIS_TAG.AppImage'
- 'artifacts/orion-$PLATFORM-$TRAVIS_TAG.apk'
skip_cleanup: true
prerelease: true
on:
Expand Down
2 changes: 1 addition & 1 deletion android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<manifest package="app.orion.android" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.6.1" android:versionCode="6" android:installLocation="auto">
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="Orion" android:icon="@drawable/icon">
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="Orion" android:icon="@drawable/logo">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="com.orion.MainActivity" android:label="Orion" android:screenOrientation="unspecified" android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
Expand Down
34 changes: 34 additions & 0 deletions ci/build_mpv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
set -e -x

sudo apt-fast -y install nasm xorg-dev libwayland-dev libgl1-mesa-dev libegl1-mesa-dev fontconfig libfribidi-dev yasm libxinerama-dev libxrandr-dev libasound2-dev libpulse-dev libjack-dev libvdpau-dev libva-dev libva-egl1 libva-x11-1 libva1 > /dev/null

export MPV_DIR=$HOME/mpv
export MPV_BUILD=$MPV_DIR/mpv-build

if [ -f $MPV_DIR/libmpv.so ]; then
cd $MPV_DIR
else
echo "libmpv not found. make."
rm -rf $MPV_BUILD

git clone https://github.com/mpv-player/mpv-build.git $MPV_BUILD

git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git $MPV_BUILD/nv-codec-headers
cd $MPV_BUILD/nv-codec-headers
make && sudo make install

cd $MPV_BUILD
echo --enable-libmpv-shared > mpv_options
./rebuild -j2

cd $MPV_DIR && mkdir include
cp -f -r $MPV_BUILD/mpv/libmpv $MPV_DIR/include/mpv
cp -f $MPV_BUILD/mpv/build/libmpv.so $MPV_DIR/libmpv.so

rm -rf $MPV_BUILD
fi

sudo ln -sf $MPV_DIR/include/mpv /usr/include/mpv
sudo ln -sf $MPV_DIR/libmpv.so /usr/lib/libmpv.so
sudo ln -sf $MPV_DIR/libmpv.so /usr/lib/libmpv.so.1
8 changes: 8 additions & 0 deletions ci/deploy_android.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -e -x
ARTIFACTS=$1

# deploy
make install INSTALL_ROOT=$PWD
$QTDIR/bin/androiddeployqt --output $PWD
mv $PWD/bin/QtApp-debug.apk $ARTIFACTS/orion-$PLATFORM-$TRAVIS_TAG.apk
File renamed without changes.
11 changes: 11 additions & 0 deletions ci/deploy_linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -e -x
ARTIFACTS=$1

# deploy
wget -q https://github.com/probonopd/linuxdeployqt/releases/download/5/linuxdeployqt-5-x86_64.AppImage -O linuxdeployqt.AppImage
chmod a+x linuxdeployqt.AppImage
cp -f distfiles/Orion.desktop Orion.desktop
cp -f distfiles/orion.svg orion.svg
./linuxdeployqt.AppImage distfiles/Orion.desktop -qmldir=./src/qml -qmake=$QTDIR/bin/qmake -appimage -bundle-non-qt-libs -verbose=1
mv *-x86_64.AppImage $ARTIFACTS/orion-$PLATFORM-$TRAVIS_TAG.AppImage
6 changes: 5 additions & 1 deletion distfiles/deploy_mac.sh → ci/deploy_osx.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash
set -e -x

ARTIFACTS=$1

# macdeploy
$QTDIR/bin/macdeployqt orion.app -qmldir=./src/qml

Expand All @@ -11,5 +13,7 @@ cp -r $QTDIR/qml/QtQml orion.app/Contents/Resources/qml
cp -r $QTDIR/qml/QtQuick orion.app/Contents/Resources/qml
cp -r $QTDIR/qml/QtQuick.2 orion.app/Contents/Resources/qml

sh distfiles/fixlibs.sh orion.app
sh ci/deploy_fixlibs_osx.sh orion.app

dmgbuild -s distfiles/settings.py "Orion $TRAVIS_TAG" "orion-$TRAVIS_TAG.dmg"
mv ./orion-$TRAVIS_TAG.dmg $ARTIFACTS/orion-$PLATFORM-$TRAVIS_TAG.dmg
32 changes: 32 additions & 0 deletions ci/install_qt5.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
set -e -x

# https://github.com/benlau/qtci

if [[ ! -d $HOME/Qt ]]; then mkdir $HOME/Qt; fi

cd $HOME/Qt

export QT_VERSION=$1
ENVFILE=qt-${QT_VERSION}.env

sudo apt-fast -y install axel libssl-dev libssl1.0.0 > /dev/null

if [[ ! -f ./${ENVFILE} ]]; then
wget -q https://raw.githubusercontent.com/mrgreywater/qtci/master/bin/extract-qt-installer
chmod +x extract-qt-installer

INSTALLER=qt-opensource-linux-x64-${QT_VERSION}.run
axel --quiet -n 16 https://download.qt.io/archive/qt/$(echo ${QT_VERSION} |cut -d "." -f-2)/${QT_VERSION}/${INSTALLER}

./extract-qt-installer --list-packages $PWD/$INSTALLER
./extract-qt-installer $PWD/$INSTALLER $PWD
else
rm -f ./$ENVFILE
fi

cat << EOM > $ENVFILE
export QTDIR=$PWD/${QT_VERSION}/gcc_64
export PATH=$QTDIR/bin:$PATH
EOM

35 changes: 35 additions & 0 deletions ci/prepare_android.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

set -e

BASE_DIR=$PWD

export QT_CI_PACKAGES="qt.qt5.5101.android_armv7"
$TRAVIS_BUILD_DIR/ci/install_qt5.sh 5.10.1

export NDK_VERSION=r17c
export ANDROID_DIR=$HOME/android
export PACKAGES=platform-tool,build-tools-22.0.1,android-19

mkdir -p $ANDROID_DIR && cd $ANDROID_DIR

sudo apt-fast install -y p7zip openjdk-7-jdk ant lib32z1-dev lib32stdc++6 > /dev/null
sudo update-alternatives --display java
sudo update-alternatives --set java /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java

wget -q https://raw.githubusercontent.com/benlau/qtci/master/bin/install-android-sdk
chmod +x install-android-sdk

echo "install android sdk, ndk."
./install-android-sdk $PACKAGES > /dev/null

mkdir -p $TRAVIS_BUILD_DIR/libs
wget -nv -c https://github.com/ph4r05/android-openssl/blob/master/jni/openssl/arch-armeabi-v7a/lib/libcrypto.so?raw=true -O $TRAVIS_BUILD_DIR/libs/libcrypto.so
wget -nv -c https://github.com/ph4r05/android-openssl/blob/master/jni/openssl/arch-armeabi-v7a/lib/libssl.so?raw=true -O $TRAVIS_BUILD_DIR/libs/libssl.so

cat << EOM > $BASE_DIR/ci/android.env
export QTDIR=$HOME/Qt/5.10.1/android_armv7
export PATH=$QTDIR/bin:$PWD/android-sdk-linux/tools:$PATH
export ANDROID_NDK_ROOT=$PWD/android-ndk-${NDK_VERSION}
export ANDROID_SDK_ROOT=$PWD/android-sdk-linux
EOM
11 changes: 11 additions & 0 deletions ci/prepare_linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
BASE_DIR=$PWD

$BASE_DIR/ci/build_mpv.sh

export QT_VERSION=5.10.1
export QT_CI_PACKAGES="qt.qt5.5101.gcc_64"
$BASE_DIR/ci/install_qt5.sh $QT_VERSION

cp $HOME/Qt/qt-$QT_VERSION.env $BASE_DIR/ci/linux.env
source $BASE_DIR/ci/linux.env
6 changes: 6 additions & 0 deletions ci/prepare_osx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

cat << EOM > ci/osx.env
export QTDIR=$(brew info --json=v1 qt | jq -r '.[0].bottle.stable.cellar + "/" + .[0].name + "/" + .[0].installed[0].version')
export PATH=$QTDIR/bin:$PATH
EOM
1 change: 0 additions & 1 deletion distfiles/Orion.desktop
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[Desktop Entry]
Version=1.1
Type=Application
Name=Orion
Icon=orion
Expand Down
6 changes: 3 additions & 3 deletions orion.pro
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ QT += gui qml network widgets quickcontrols2

QMAKE_CXXFLAGS += -Wall -O2

CONFIG += c++11
CONFIG += c++14
#CONFIG += console

TARGET = orion
Expand Down Expand Up @@ -86,8 +86,8 @@ android: {
android/src/com/orion/MainActivity.java

ANDROID_EXTRA_LIBS = \
$$PWD/../openssl-1.0.2l/libcrypto.so \
$$PWD/../openssl-1.0.2l/libssl.so
$$PWD/libs/libcrypto.so \
$$PWD/libs/libssl.so
}

#Backend for player, uses mpv as default
Expand Down
47 changes: 40 additions & 7 deletions src/player/mpvobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,25 @@ class MpvRenderer : public QQuickFramebufferObject::Renderer
MpvRenderer(MpvObject *new_obj)
: obj{new_obj}
{

#ifdef USE_OPENGL_CB
int r = mpv_opengl_cb_init_gl(obj->mpv_gl, nullptr, &get_proc_address_mpv, nullptr);
if (r < 0)
throw std::runtime_error("could not initialize OpenGL");
#endif
}

virtual ~MpvRenderer()
{}
{
#ifdef USE_OPENGL_CB
mpv_opengl_cb_uninit_gl(obj->mpv_gl);
#endif
}

// This function is called when a new FBO is needed.
// This happens on the initial frame.
QOpenGLFramebufferObject * createFramebufferObject(const QSize &size)
{
#ifndef USE_OPENGL_CB
// init mpv_gl:
if (!obj->mpv_gl)
{
Expand All @@ -72,15 +81,17 @@ class MpvRenderer : public QQuickFramebufferObject::Renderer
throw std::runtime_error("failed to initialize mpv GL context");
mpv_render_context_set_update_callback(obj->mpv_gl, on_mpv_redraw, obj);
}

#endif
return QQuickFramebufferObject::Renderer::createFramebufferObject(size);
}

void render()
{
obj->window()->resetOpenGLState();

QOpenGLFramebufferObject *fbo = framebufferObject();
#ifdef USE_OPENGL_CB
mpv_opengl_cb_draw(obj->mpv_gl, fbo->handle(), fbo->width(), fbo->height());
#else
mpv_opengl_fbo mpfbo{static_cast<int>(fbo->handle()), fbo->width(), fbo->height(), 0};
int flip_y{0};

Expand All @@ -97,14 +108,16 @@ class MpvRenderer : public QQuickFramebufferObject::Renderer
// See render_gl.h on what OpenGL environment mpv expects, and
// other API details.
mpv_render_context_render(obj->mpv_gl, params);

#endif
obj->window()->resetOpenGLState();
}
};

MpvObject::MpvObject(QQuickItem * parent)
: QQuickFramebufferObject(parent), mpv{mpv_create()}, mpv_gl(nullptr)
: QQuickFramebufferObject(parent), mpv_gl(nullptr)
{
std::setlocale(LC_NUMERIC, "C");
mpv = mpv_create();
if (!mpv)
throw std::runtime_error("could not create mpv context");

Expand All @@ -113,11 +126,27 @@ MpvObject::MpvObject(QQuickItem * parent)
mpv_set_option_string(mpv, "msg-level", "all=v");
#endif

#ifdef USE_OPENGL_CB
mpv_set_option_string(mpv, "vo", "opengl-cb");
#endif

if (mpv_initialize(mpv) < 0)
throw std::runtime_error("could not initialize mpv context");

// Request hw decoding, just for testing.
mpv::qt::set_option_variant(mpv, "hwdec", "auto");
mpv_set_option_string(mpv, "hwdec", "auto");

#ifdef USE_OPENGL_CB
// Setup the callback that will make QtQuick update and redraw if there
// is a new video frame. Use a queued connection: this makes sure the
// doUpdate() function is run on the GUI thread.
mpv_gl = (mpv_opengl_cb_context *)mpv_get_sub_api(mpv, MPV_SUB_API_OPENGL_CB);

if (!mpv_gl)
throw std::runtime_error("OpenGL not compiled in");

mpv_opengl_cb_set_update_callback(mpv_gl, MpvObject::on_update, (void *)this);
#endif

mpv_set_wakeup_callback(mpv, wakeup, this);

Expand All @@ -128,7 +157,11 @@ MpvObject::~MpvObject()
{
if (mpv_gl) // only initialized if something got drawn
{
#ifdef USE_OPENGL_CB
mpv_opengl_cb_set_update_callback(mpv_gl, nullptr, nullptr);
#else
mpv_render_context_free(mpv_gl);
#endif
}

mpv_terminate_destroy(mpv);
Expand Down
Loading