Travis: add ci for linux and android

This commit is contained in:
KangLin 2018-11-14 16:56:14 +08:00
parent da15d888d4
commit 6e5d408732
4 changed files with 284 additions and 0 deletions

49
.travis.yml Normal file
View File

@ -0,0 +1,49 @@
#Author: KangLin(kl222@126.com)
sudo: required
dist: trusty
language: cpp
cache:
- apt: true
- directories:
- Tools
compiler:
- g++
jdk: oraclejdk7
os:
- unix
addons:
ssh_known_hosts:
- github.com
env:
matrix:
- BUILD_TARGERT="linux" QT_VERSION_DIR=5.11 QT_VERSION=5.11.2
- BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.11 QT_VERSION=5.11.2
- BUILD_TARGERT="linux" QT_VERSION_DIR=5.10 QT_VERSION=5.10.1
- BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.10 QT_VERSION=5.10.1
- BUILD_TARGERT="linux" QT_VERSION_DIR=5.9 QT_VERSION=5.9.7
- BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.9 QT_VERSION=5.9.7
before_install:
- echo "TRAVIS_OS_NAME=${TRAVIS_OS_NAME}"
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
install:
- bash ${TRAVIS_BUILD_DIR}/ci/build-install-tools.sh #> /dev/null
before_script:
- source ${TRAVIS_BUILD_DIR}/ci/build_env.sh
script:
- mkdir ${TRAVIS_BUILD_DIR}/build
- cd ${TRAVIS_BUILD_DIR}/build
- ${QT_ROOT}/bin/qmake -o Makefile CONFIG+=Release ${TRAVIS_BUILD_DIR}/src/QZXing.pro
- make -f Makefile

78
ci/build-install-tools.sh Normal file
View File

@ -0,0 +1,78 @@
#!/bin/bash
#Author: KangLin(kl222@126.com)
set -e
SOURCE_DIR="`pwd`"
echo $SOURCE_DIR
TOOLS_DIR=${SOURCE_DIR}/Tools
echo ${TOOLS_DIR}
if [ ! -f "${TOOLS_DIR}" ]; then
mkdir -p ${TOOLS_DIR}
fi
function function_common()
{
cd ${TOOLS_DIR}
# Qt download and installhttps://github.com/benlau/qtci
if [ -n "${QT_VERSION}" ]; then
QT_DIR=`pwd`/Qt/${QT_VERSION}
if [ ! -d "${QT_DIR}" ]; then
wget -c --no-check-certificate -nv http://download.qt.io/official_releases/qt/${QT_VERSION_DIR}/${QT_VERSION}/qt-opensource-linux-x64-${QT_VERSION}.run
bash ${SOURCE_DIR}/ci/qt-installer.sh qt-opensource-linux-x64-${QT_VERSION}.run ${QT_DIR}
rm qt-opensource-linux-x64-${QT_VERSION}.run
fi
fi
}
function function_android()
{
cd ${TOOLS_DIR}
#Download android ndk
if [ ! -d "`pwd`/android-ndk" ]; then
wget -c -nv http://dl.google.com/android/ndk/android-ndk-r10e-linux-x86_64.bin
chmod u+x android-ndk-r10e-linux-x86_64.bin
./android-ndk-r10e-linux-x86_64.bin > /dev/null
mv android-ndk-r10e android-ndk
rm android-ndk-r10e-linux-x86_64.bin
fi
cd ${TOOLS_DIR}
#Download android sdk
if [ ! -d "`pwd`/android-sdk" ]; then
wget -c -nv https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz
tar xf android-sdk_r24.4.1-linux.tgz
mv android-sdk-linux android-sdk
rm android-sdk_r24.4.1-linux.tgz
(sleep 5 ; while true ; do sleep 1 ; printf 'y\r\n' ; done ) \
| android-sdk/tools/android update sdk -u -t tool,android-18,android-24,extra,platform,platform-tools,build-tools-25
fi
function_common
cd ${SOURCE_DIR}
}
function function_linux()
{
function_common
cd ${SOURCE_DIR}
}
case ${BUILD_TARGERT} in
android*)
function_android
;;
linux)
function_linux
;;
*)
echo "There aren't ${BUILD_TARGERT}"
;;
esac
cd ${SOURCE_DIR}

24
ci/build_env.sh Normal file
View File

@ -0,0 +1,24 @@
#Author: KangLin(kl222@126.com)
SOURCE_DIR="`pwd`"
echo $SOURCE_DIR
TOOLS_DIR=${SOURCE_DIR}/Tools
cd ${TOOLS_DIR}
case "${BUILD_TARGERT}" in
linux)
QT_DIR=`pwd`/Qt/${QT_VERSION}
export QT_ROOT=${QT_DIR}/${QT_VERSION}/gcc_64
;;
android*)
export ANDROID_NDK_ROOT=`pwd`/android-ndk
export ANDROID_NDK=$ANDROID_NDK_ROOT
export ANDROID_SDK_ROOT=`pwd`/android-sdk
export ANDROID_SDK=$ANDROID_SDK_ROOT
QT_DIR=`pwd`/Qt/${QT_VERSION}
export QT_ROOT=${QT_DIR}/${QT_VERSION}/android_armv7
;;
esac

133
ci/qt-installer.sh Normal file
View File

@ -0,0 +1,133 @@
#!/bin/bash
#http://stackoverflow.com/questions/25105269/silent-install-qt-run-installer-on-ubuntu-server
#http://doc.qt.io/qtinstallerframework/noninteractive.html
#参考https://github.com/benlau/qtci
# https://github.com/mjscosta/qt-silent-installer
set -e #quit on error
if [ $# -lt 2 ];
then
echo qt-installer.sh qt-installer-file output_path
exit -1
fi
export PATH=$PATH:$PWD
export WORKDIR=$PWD
INSTALLER=$1
OUTPUT=$2
SCRIPT="$(mktemp /tmp/tmp.XXXXXXXXX)"
case $BUILD_TARGERT in
android_arm*)
SELECTEDPACKAGES=android_armv7
;;
android_x86)
SELECTEDPACKAGES=android_x86
;;
linux)
SELECTEDPACKAGES=gcc_64
;;
*)
echo "Aach[$RABBIT_ARCH] don't suppoert"
esac
cat <<EOF > $SCRIPT
function Controller() {
installer.autoRejectMessageBoxes();
installer.installationFinished.connect(function() {
gui.clickButton(buttons.NextButton);
});
}
function log() {
var msg = ["QTCI: "].concat([].slice.call(arguments));
console.log(msg.join(" "));
}
Controller.prototype.WelcomePageCallback = function() {
gui.clickButton(buttons.NextButton, 5000);
}
Controller.prototype.CredentialsPageCallback = function() {
gui.clickButton(buttons.CommitButton);
}
Controller.prototype.ComponentSelectionPageCallback = function() {
var components = installer.components();
log("Available components: " + components.length);
for (var i = 0 ; i < components.length ;i++) {
log(components[i].name);
}
log("Select components");
function trim(str) {
return str.replace(/^ +/,"").replace(/ *$/,"");
}
var widget = gui.currentPageWidget();
widget.deselectAll();
var packages = trim("$SELECTEDPACKAGES").split(",");
if (packages.length > 0 && packages[0] !== "") {
for (var i in packages) {
var pkg = trim(packages[i]);
for (var i = 0 ; i < components.length ;i++) {
if(components[i].name.indexOf(pkg) != -1)
{
log("Select " + components[i].name);
widget.selectComponent(trim(components[i].name));
}
}
}
} else {
log("Use default component list");
}
gui.clickButton(buttons.NextButton);
}
Controller.prototype.IntroductionPageCallback = function() {
gui.clickButton(buttons.NextButton);
}
Controller.prototype.TargetDirectoryPageCallback = function() {
var widget = gui.currentPageWidget();
if (widget != null) {
widget.TargetDirectoryLineEdit.setText("$OUTPUT");
}
gui.clickButton(buttons.NextButton);
}
Controller.prototype.LicenseAgreementPageCallback = function() {
var widget = gui.currentPageWidget();
if (widget != null) {
widget.AcceptLicenseRadioButton.setChecked(true);
}
gui.clickButton(buttons.NextButton);
}
Controller.prototype.StartMenuDirectoryPageCallback = function() {
gui.clickButton(buttons.CommitButton);
}
Controller.prototype.ReadyForInstallationPageCallback = function() {
gui.clickButton(buttons.CommitButton);
}
Controller.prototype.FinishedPageCallback = function() {
var widget = gui.currentPageWidget();
widget.LaunchQtCreatorCheckBoxForm.launchQtCreatorCheckBox.setChecked(false);
gui.clickButton(buttons.FinishButton);
}
EOF
chmod u+x $1
$1 -v --script $SCRIPT