From da15d888d4cfc020f9a05031b3bf9700c258a034 Mon Sep 17 00:00:00 2001 From: KangLin Date: Wed, 14 Nov 2018 16:55:44 +0800 Subject: [PATCH 1/2] Appveyor: Add ci for windows use msvc and mingw --- appveyor.yml | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..bb5aec8 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,113 @@ +#Author: KangLin(kl222@126.com) + +version: '0.1.1.{build}' + +image: Visual Studio 2015 + +configuration: + - release + - debug + +environment: + matrix: + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + QT_ROOT: C:/Qt/5.11/msvc2017_64 + - QT_ROOT: C:/Qt/5.11/msvc2015 + - QT_ROOT: C:/Qt/5.11/mingw53_32 + + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + QT_ROOT: C:/Qt/5.10/msvc2017_64 + - QT_ROOT: C:/Qt/5.10/msvc2015_64 + - QT_ROOT: C:/Qt/5.10/msvc2015 + - QT_ROOT: C:/Qt/5.10/msvc2013_64 + - QT_ROOT: C:/Qt/5.10/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 + + - QT_ROOT: C:/Qt/5.7.0/msvc2015 + - QT_ROOT: C:/Qt/5.7.0/mingw53_32 + + - 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: + +install: + - for /f "delims=" %%i in ('git describe --tags') do (set BUILD_VERSION=%%i) + - if "%BUILD_VERSION%" == "" for /f "delims=" %%i in ('git rev-parse HEAD') do (set BUILD_VERSION=%%i) + - echo BUILD_VERSION=%BUILD_VERSION% + - if NOT "%QT_ROOT%" == "NO" for /f "delims=" %%i in ('%QT_ROOT%/bin/qmake -query QT_VERSION') do (set QT_VERSION=%%i) + - echo "QT_VERSION:%QT_VERSION" + - if NOT "%QT_ROOT%" == "NO" for /f "delims=" %%i in ('%QT_ROOT%/bin/qmake -query QMAKE_XSPEC') do (set QMAKE_XSPEC=%%i) + - echo "QMAKE_XSPEC=%QMAKE_XSPEC%" + - set TOOLCHAIN_VERSION="" + - ps: >- + if (($env:QMAKE_XSPEC).Contains("msvc")) + { + $env:MAKE="nmake" + if (($env:QT_ROOT).Contains("_64")) + { + $env:varch="amd64" + } + else + { + $env:varch="x86" + } + if (($env:QT_ROOT).Contains("2017")) + { + $env:TOOLCHAIN_VERSION="15" + } + else + { + if (($env:QT_ROOT).Contains("2015")) + { + $env:TOOLCHAIN_VERSION="14" + }elseif (($env:QT_ROOT).Contains("2013")) + { + $env:TOOLCHAIN_VERSION="12" + } + } + } + else + { + $env:MAKE="mingw32-make" + $env:PATH="C:\Qt\Tools\mingw530_32;$env:PATH" + } + + - if NOT "%TOOLCHAIN_VERSION%"=="" if %TOOLCHAIN_VERSION% LSS 15 (call "C:/Program Files (x86)/Microsoft Visual Studio %TOOLCHAIN_VERSION%.0/VC/vcvarsall.bat" %varch%) else (call "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build/vcvarsall.bat" %varch%) + - echo "cl " + - 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" + - call %MAKE% + - call %MAKE% install + +test_script: + +artifacts: + - path: install + name: QZXing_$(QMAKE_XSPEC)$(TOOLCHAIN_VERSION)_$(CONFIGURATION)_$(BUILD_VERSION) + type: zip + +# whitelist branches to avoid testing feature branches twice (as branch and as pull request) +branches: + only: + - master + +deploy: + provider: GitHub + #token: https://github.com/settings/tokens encode token: https://ci.appveyor.com/tools/encrypt + auth_token: + secure: #TODO: set your token + on: + appveyor_repo_tag: true # deploy on tag push only From 6e5d4087321d6464eea78484a8f88c1c09a74df8 Mon Sep 17 00:00:00 2001 From: KangLin Date: Wed, 14 Nov 2018 16:56:14 +0800 Subject: [PATCH 2/2] Travis: add ci for linux and android --- .travis.yml | 49 ++++++++++++++ ci/build-install-tools.sh | 78 ++++++++++++++++++++++ ci/build_env.sh | 24 +++++++ ci/qt-installer.sh | 133 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 284 insertions(+) create mode 100644 .travis.yml create mode 100644 ci/build-install-tools.sh create mode 100644 ci/build_env.sh create mode 100644 ci/qt-installer.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..f86b3d8 --- /dev/null +++ b/.travis.yml @@ -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 diff --git a/ci/build-install-tools.sh b/ci/build-install-tools.sh new file mode 100644 index 0000000..4f5f792 --- /dev/null +++ b/ci/build-install-tools.sh @@ -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 install:https://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} diff --git a/ci/build_env.sh b/ci/build_env.sh new file mode 100644 index 0000000..8434b38 --- /dev/null +++ b/ci/build_env.sh @@ -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 diff --git a/ci/qt-installer.sh b/ci/qt-installer.sh new file mode 100644 index 0000000..6eb39ca --- /dev/null +++ b/ci/qt-installer.sh @@ -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 < $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 +