Skip to content

Commit

Permalink
Modify ci to support cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
KangLin committed Jul 24, 2020
1 parent f647f1a commit 84e9a17
Show file tree
Hide file tree
Showing 6 changed files with 256 additions and 87 deletions.
31 changes: 18 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#Author: KangLin(kl222@126.com)

#sudo: required
dist: xenial
dist: bionic

services:
- xvfb

language: cpp

cache:
- apt: true
- apt
- directories:
- Tools
- Package

compiler:
- g++
Expand All @@ -24,12 +24,9 @@ addons:

env:
jobs:
- BUILD_TARGERT="linux" QT_VERSION_DIR=5.13 QT_VERSION=5.13.0
# - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.13 QT_VERSION=5.13.0
- BUILD_TARGERT="linux" QT_VERSION_DIR=5.12 QT_VERSION=5.12.4
# - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.12 QT_VERSION=5.12.4
- BUILD_TARGERT="linux" QT_VERSION_DIR=5.9 QT_VERSION=5.9.8
# - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.9 QT_VERSION=5.9.8
- BUILD_TARGERT="unix" DOWNLOAD_QT=APT
- BUILD_TARGERT="unix" QT_VERSION_DIR=512 QT_VERSION=5.12.6 DOWNLOAD_QT=FALSE
- BUILD_TARGERT="unix" QT_VERSION_DIR=511 QT_VERSION=5.11.3 DOWNLOAD_QT=FALSE

before_install:
- echo "TRAVIS_OS_NAME=${TRAVIS_OS_NAME}"
Expand All @@ -43,7 +40,15 @@ 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
# Test qmake
- mkdir ${TRAVIS_BUILD_DIR}/build_qamke
- cd ${TRAVIS_BUILD_DIR}/build_qamke
- ${QT_ROOT}/bin/qmake CONFIG+=Release PRFIEX=`pwd`/install ${TRAVIS_BUILD_DIR}/src
- make install

# Test cmake
- mkdir ${TRAVIS_BUILD_DIR}/build_camke
- cd ${TRAVIS_BUILD_DIR}/build_camke
- cmake -DQt5_DIR=${QT_ROOT}/lib/cmake/Qt5 -DCMAKE_INSTALL_PREFIX=`pwd`/install ${TRAVIS_BUILD_DIR}/src
- cmake --build . --config Release
- cmake --build . --config Release --target install
50 changes: 26 additions & 24 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
#original author: KangLin(kl222@126.com)
#original author: Kang Lin(kl222@126.com)

version: '3.0.a.5.{build}'

configuration:
- release
- debug
- Release
- Debug

environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
GENERATORS: "Visual Studio 14 2015"
QT_ROOT: C:/Qt/5.6/msvc2015

- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
GENERATORS: "Visual Studio 14 2015 Win64"
QT_ROOT: C:/Qt/5.9/msvc2015_64

- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
GENERATORS: "Visual Studio 15 2017 Win64"
QT_ROOT: C:/Qt/5.12/msvc2017_64
# - QT_ROOT: C:/Qt/5.12/msvc2015
# - QT_ROOT: C:/Qt/5.12/mingw53_32

- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
QT_ROOT: C:/Qt/5.9/msvc2017_64
# - QT_ROOT: C:/Qt/5.9/msvc2015_64
# - QT_ROOT: C:/Qt/5.9/msvc2015
# - QT_ROOT: C:/Qt/5.9/msvc2013_64
# - QT_ROOT: C:/Qt/5.9/mingw53_32

- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
QT_ROOT: C:/Qt/5.6/msvc2015_64
# - QT_ROOT: C:/Qt/5.6/msvc2015
# - QT_ROOT: C:/Qt/5.6/msvc2013_64
# - QT_ROOT: C:/Qt/5.6/msvc2013

init:

Expand Down Expand Up @@ -75,17 +69,25 @@ install:
- cl

build_script:
- mkdir "%APPVEYOR_BUILD_FOLDER%/build"
- cd "%APPVEYOR_BUILD_FOLDER%/build"
- call "%QT_ROOT%/bin/qmake.exe" CONFIG+=%Configuration% PREFIX="%APPVEYOR_BUILD_FOLDER%/install" "%APPVEYOR_BUILD_FOLDER%/src/QZXing.pro"
# Test qmake
- mkdir "%APPVEYOR_BUILD_FOLDER%/build_qmake"
- cd "%APPVEYOR_BUILD_FOLDER%/build_qmake"
- call "%QT_ROOT%/bin/qmake.exe" CONFIG+=%Configuration% PREFIX="%APPVEYOR_BUILD_FOLDER%/install_qmake" "%APPVEYOR_BUILD_FOLDER%/src"
- call %MAKE%
- call %MAKE% install
- call %MAKE% install

# Test cmake
- mkdir "%APPVEYOR_BUILD_FOLDER%/build_cmake"
- cd "%APPVEYOR_BUILD_FOLDER%/build_cmake"
- cmake.exe -G"%GENERATORS%" -DCMAKE_INSTALL_PREFIX="%APPVEYOR_BUILD_FOLDER%/install_cmake" -DQt5_DIR="%QT_ROOT%/lib/cmake/Qt5" "%APPVEYOR_BUILD_FOLDER%/src"
- cmake --build . --config %Configuration%
- cmake --build . --config %Configuration% --target install

test_script:

artifacts:
- path: install
name: QZXing_$(QMAKE_XSPEC)$(TOOLCHAIN_VERSION)_$(CONFIGURATION)_$(BUILD_VERSION)
- path: install_qmake
name: QZXing_$(QMAKE_XSPEC)$(TOOLCHAIN_VERSION)_$(CONFIGURATION)_Qt$(QT_VERSION)_$(BUILD_VERSION)
type: zip

# whitelist branches to avoid testing feature branches twice (as branch and as pull request)
Expand Down
180 changes: 148 additions & 32 deletions ci/build-install-tools.sh
Original file line number Diff line number Diff line change
@@ -1,74 +1,190 @@
#!/bin/bash
#Author: KangLin(kl222@126.com)
#Author: Kang Lin(kl222@126.com)

set -e

SOURCE_DIR="`pwd`"
echo $SOURCE_DIR
TOOLS_DIR=${SOURCE_DIR}/Tools
echo ${TOOLS_DIR}
PACKAGE_DIR=${SOURCE_DIR}/Package
ThirdLibs_DIR=${TOOLS_DIR}/ThirdLibs

if [ ! -f "${TOOLS_DIR}" ]; then
mkdir -p ${TOOLS_DIR}
if [ ! -d "${TOOLS_DIR}" ]; then
mkdir ${TOOLS_DIR}
fi
if [ ! -d "$PACKAGE_DIR" ]; then
mkdir -p $PACKAGE_DIR
fi

function function_common()
{
cd ${TOOLS_DIR}

# Qt download and install:https://github.com/benlau/qtci
if [ -n "${QT_VERSION}" ]; then

# See: https://github.com/benlau/qtci
cd ${TOOLS_DIR}
if [ "$DOWNLOAD_QT" = "TRUE" ]; then
QT_DIR=`pwd`/Qt/${QT_VERSION}
cd ${PACKAGE_DIR}
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
if [ "${QT_VERSION}" = "5.6.3" ]; then
if [ ! -f qt-opensource-linux-x64-android-${QT_VERSION}.run ]; then
wget -c --no-check-certificate -nv http://download.qt.io/official_releases/qt/${QT_VERSION_DIR}/${QT_VERSION}/qt-opensource-linux-x64-android-${QT_VERSION}.run
fi
bash ${SOURCE_DIR}/ci/qt-installer.sh qt-opensource-linux-x64-android-${QT_VERSION}.run ${QT_DIR}
#rm qt-opensource-linux-x64-android-${QT_VERSION}.run
else
if [ ! -f qt-opensource-linux-x64-${QT_VERSION}.run ]; 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
fi
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
fi

cd ${SOURCE_DIR}
}

function function_android()
function install_android()
{
if [ -n "$1" ]; then
NDK="ndk-bundle"
fi
cd ${TOOLS_DIR}
if [ ! -d "`pwd`/android-sdk" ]; then
cd ${PACKAGE_DIR}
ANDROID_STUDIO_VERSION=191.5900203
if [ ! -f android-studio-ide-${ANDROID_STUDIO_VERSION}-linux.tar.gz ]; then
wget -c -nv https://dl.google.com/dl/android/studio/ide-zips/3.5.1.0/android-studio-ide-${ANDROID_STUDIO_VERSION}-linux.tar.gz
fi
tar xzf android-studio-ide-${ANDROID_STUDIO_VERSION}-linux.tar.gz -C ${TOOLS_DIR}
cd ${TOOLS_DIR}
export JAVA_HOME=`pwd`/android-studio/jre
export PATH=${JAVA_HOME}/bin:$PATH
cd ${PACKAGE_DIR}
SDK_PACKAGE=sdk-tools-linux-4333796.zip
if [ ! -f ${SDK_PACKAGE} ]; then
wget -c -nv https://dl.google.com/android/repository/${SDK_PACKAGE}
fi
cd ${TOOLS_DIR}
mkdir android-sdk
cd android-sdk
unzip -q ${PACKAGE_DIR}/${SDK_PACKAGE} -d `pwd`

echo "Install sdk and ndk ......"
if [ -n "${ANDROID_API}" ]; then
PLATFORMS="platforms;${ANDROID_API}"
else
PLATFORMS="platforms"
fi
if [ -z "${BUILD_TOOS_VERSION}" ]; then
BUILD_TOOS_VERSION="28.0.3"
fi
(sleep 5 ; num=0 ; while [ $num -le 5 ] ; do sleep 1 ; num=$(($num+1)) ; printf 'y\r\n' ; done ) \
| ./tools/bin/sdkmanager "platform-tools" "build-tools;${BUILD_TOOS_VERSION}" "${PLATFORMS}" ${NDK}
if [ -n "${NDK}" ]; then
if [ ! -d ${TOOLS_DIR}/android-ndk ]; then
ln -s ${TOOLS_DIR}/android-sdk/ndk-bundle ${TOOLS_DIR}/android-ndk
fi
fi
fi
}

#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
function install_android_sdk_and_ndk()
{
install_android
NDK_PACKAGE=android-ndk-r21-linux-x86_64.zip
cd ${PACKAGE_DIR}
if [ ! -f ${NDK_PACKAGE} ]; then
wget -c -nv https://dl.google.com/android/repository/${NDK_PACKAGE}
fi
unzip -q ${NDK_PACKAGE} -d ${TOOLS_DIR}
cd ${TOOLS_DIR}
mv android-ndk-r21 android-ndk
}

function function_android()
{
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
sudo apt-get update -y -qq
#sudo apt-get install -qq -y openjdk-11-jdk
# install oracle jdk
#sudo add-apt-repository ppa:linuxuprising/java -y
#sudo apt update
#(sleep 5 ; while true ; do sleep 1 ; printf '\r\n' ; done ) | sudo apt install oracle-java11-installer -qq -y

#sudo apt install oracle-java11-set-default -qq -y
#sudo apt-get install ant -qq -y
sudo apt-get install libicu-dev -qq -y
sudo apt-get install -qq -y libxkbcommon-x11-dev libglu1-mesa-dev

install_android_sdk_and_ndk
function_common

cd ${SOURCE_DIR}
}

function function_linux()
function function_unix()
{
if [ "$DOWNLOAD_QT" != "TRUE" -a "$DOWNLOAD_QT" != "APT" ]; then
#See: https://launchpad.net/~beineri
sudo add-apt-repository ppa:beineri/opt-qt-${QT_VERSION}-`lsb_release -c|awk '{print $2}'` -y
fi

sudo apt-get update -y -qq
sudo apt-get install debhelper fakeroot -y -qq
sudo apt-get install -y -qq libglu1-mesa-dev \
libxkbcommon-x11-dev \
libpulse-mainloop-glib0 \
libgstreamer1.0-dev \
libgstreamer-plugins-base1.0-dev \
gstreamer1.0-pulseaudio \
libmysql-cil-dev libmysql-cil-dev libmysql-ocaml-dev \
libmysql++-dev libmysqld-dev libmysqlcppconn-dev \
libmysqlclient-dev \
libodbc1

if [ "$DOWNLOAD_QT" = "APT" ]; then
sudo apt-get install -y -qq qttools5-dev qttools5-dev-tools \
qtbase5-dev qtbase5-dev-tools \
qtmultimedia5-dev \
qtquickcontrols2-5-dev \
qtdeclarative5-dev \
libqt5svg5-dev
sudo ln -s /usr/lib/`uname -m`-linux-gnu/cmake /usr/lib/`uname -m`-linux-gnu/qt5/cmake
elif [ "$DOWNLOAD_QT" != "TRUE" ]; then
sudo apt-get install -y -qq qt${QT_VERSION_DIR}base \
qt${QT_VERSION_DIR}tools \
qt${QT_VERSION_DIR}multimedia \
qt${QT_VERSION_DIR}svg \
qt${QT_VERSION_DIR}quickcontrols2 \
qt${QT_VERSION_DIR}declarative
fi
function_common

cd ${SOURCE_DIR}
}

function function_mingw()
{
cd ${SOURCE_DIR}
if [ "true" == "$RABBITIM_BUILD_THIRDLIBRARY" ]; then
export RABBITIM_BUILD_CROSS_HOST=i686-w64-mingw32 #i586-mingw32msvc
fi

function_common
cd ${SOURCE_DIR}
}

case ${BUILD_TARGERT} in
android*)
android)
function_android
;;
linux)
function_linux
unix)
function_unix
;;
windows_mingw)
function_mingw
;;
*)
echo "There aren't ${BUILD_TARGERT}"
Expand Down
19 changes: 14 additions & 5 deletions ci/build_env.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Author: KangLin(kl222@126.com)
#Author: Kang Lin(kl222@126.com)

SOURCE_DIR="`pwd`"
echo $SOURCE_DIR
Expand All @@ -7,11 +7,20 @@ 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
unix)
if [ "$DOWNLOAD_QT" = "APT" ]; then
export QT_ROOT=/usr/lib/`uname -m`-linux-gnu/qt5
elif [ "$DOWNLOAD_QT" = "TRUE" ]; then
QT_DIR=${TOOLS_DIR}/Qt/${QT_VERSION}
export QT_ROOT=${QT_DIR}/${QT_VERSION}/gcc_64
else
#source /opt/qt${QT_VERSION_DIR}/bin/qt${QT_VERSION_DIR}-env.sh
export QT_ROOT=/opt/qt${QT_VERSION_DIR}
fi
export PATH=$QT_ROOT/bin:$PATH
export LD_LIBRARY_PATH=$QT_ROOT/lib/i386-linux-gnu:$QT_ROOT/lib:$LD_LIBRARY_PATH
;;
android*)
android)
export ANDROID_NDK_ROOT=`pwd`/android-ndk
export ANDROID_NDK=$ANDROID_NDK_ROOT

Expand Down
Loading

0 comments on commit 84e9a17

Please sign in to comment.