CI为Qt应用程序:构建与不同的Qt版本 [英] CI for Qt app: build with different Qt versions

查看:377
本文介绍了CI为Qt应用程序:构建与不同的Qt版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Travis-CI为我的简单Qt应用程序的持续集成。我的.travis.yml文件如下所示(基于此要点):

I use Travis-CI for continuous integration for my simple Qt app. My .travis.yml file looks like this (based on this gist):

language: cpp

before_install:
  - sudo add-apt-repository --yes ppa:ubuntu-sdk-team/ppa
  - sudo apt-get update -qq
  - sudo apt-get install -qq g++ qt4-qmake libqt4-dev qt5-qmake qtbase5-dev

script: 
  - qmake -qt=qt4 -v
  - qmake -qt=qt4
  - make
  - make -k check
  - make clean
  - qmake -qt=qt5 -v
  - qmake -qt=qt5
  - make
  - make -k check

这个配置允许我使用默认的Qt库在Ubuntu(Qt 4.8.1和Qt 5.0.2)中构建我的应用程序(运行测试)。

This configuration allows me to build my app (and run tests) with default Qt libraries in Ubuntu (Qt 4.8.1 and Qt 5.0.2).

有任何方法来与其他Qt版本(4.7.x,4.8.x,5.1.x等)构建应用程序吗?

Is there any way to build app with other Qt versions (4.7.x, 4.8.x, 5.1.x and so on)?

推荐答案

受到 AlexandreP 答案和。doublefold-Qt项目的travis.yml文件与许多感谢 Stephan Binner

Inspired by AlexandreP answer and .travis.yml file of Twofold-Qt project with many thanks to Stephan Binner.

language: cpp

compiler:
  - gcc

sudo: required
dist: trusty

env:
  - QT_BASE=48
  - QT_BASE=51
  - QT_BASE=52
  - QT_BASE=53
  - QT_BASE=54
  - QT_BASE=55
  - QT_BASE=56
  - QT_BASE=57

before_install:
  - if [ "$QT_BASE" = "48" ]; then sudo add-apt-repository ppa:beineri/opt-qt487-trusty -y; fi
  - if [ "$QT_BASE" = "51" ]; then sudo add-apt-repository ppa:beineri/opt-qt511-trusty -y; fi
  - if [ "$QT_BASE" = "52" ]; then sudo add-apt-repository ppa:beineri/opt-qt521-trusty -y; fi
  - if [ "$QT_BASE" = "53" ]; then sudo add-apt-repository ppa:beineri/opt-qt532-trusty -y; fi
  - if [ "$QT_BASE" = "54" ]; then sudo add-apt-repository ppa:beineri/opt-qt542-trusty -y; fi
  - if [ "$QT_BASE" = "55" ]; then sudo add-apt-repository ppa:beineri/opt-qt551-trusty -y; fi
  - if [ "$QT_BASE" = "56" ]; then sudo add-apt-repository ppa:beineri/opt-qt562-trusty -y; fi
  - if [ "$QT_BASE" = "57" ]; then sudo add-apt-repository ppa:beineri/opt-qt571-trusty -y; fi
  - sudo apt-get update -qq

install:
  - if [ "$QT_BASE" = "48" ]; then sudo apt-get install -qq opt-qt4-qmake opt-qt4-dev-tools; source /opt/qt-4.8/bin/qt-4.8-env.sh; fi
  - if [ "$QT_BASE" = "51" ]; then sudo apt-get install -qq qt51base; source /opt/qt51/bin/qt51-env.sh; fi
  - if [ "$QT_BASE" = "52" ]; then sudo apt-get install -qq qt52base; source /opt/qt52/bin/qt52-env.sh; fi
  - if [ "$QT_BASE" = "53" ]; then sudo apt-get install -qq qt53base; source /opt/qt53/bin/qt53-env.sh; fi
  - if [ "$QT_BASE" = "54" ]; then sudo apt-get install -qq qt54base; source /opt/qt54/bin/qt54-env.sh; fi
  - if [ "$QT_BASE" = "55" ]; then sudo apt-get install -qq qt55base; source /opt/qt55/bin/qt55-env.sh; fi
  - if [ "$QT_BASE" = "56" ]; then sudo apt-get install -qq qt56base; source /opt/qt56/bin/qt56-env.sh; fi
  - if [ "$QT_BASE" = "57" ]; then sudo apt-get install -qq qt57base; source /opt/qt57/bin/qt57-env.sh; fi

script:
  - qmake -r
  - make
  - make check

notifications:
  email: false

使用此设置Travis-CI将启动7个单独的构建作业(参见环境变量) - 定义的QT_BASE变量的数量。

With this er... settings Travis-CI will start 7 separate build jobs (see Environment Variables) - number of defined QT_BASE variables. Each build job will install specified Qt version and use it for app building.

如果您想构建适用于Windows的应用程序,可以尝试 AppVeyor CI服务。我使用这个配置(Qt 5.3 - 5.7):

If you want to build your app for Windows, you can try AppVeyor CI service. I use this config (Qt 5.3 - 5.7):

version: '{build}'

init:
- git config --global core.autocrlf input

environment:
  matrix:
  - QT5: C:\Qt\5.3\mingw482_32
    MINGW: C:\Qt\Tools\mingw482_32
  - QT5: C:\Qt\5.4\mingw491_32
    MINGW: C:\Qt\Tools\mingw491_32
  - QT5: C:\Qt\5.5\mingw492_32
    MINGW: C:\Qt\Tools\mingw492_32
  - QT5: C:\Qt\5.6\mingw49_32
    MINGW: C:\Qt\Tools\mingw492_32
  - QT5: C:\Qt\5.7\mingw53_32
    MINGW: C:\Qt\Tools\mingw530_32

matrix:
  fast_finish: true

before_build:
- set PATH=%MINGW%\bin;%QT5%\bin;%PATH%

build_script:
- qmake -v
- qmake -r
- mingw32-make

这篇关于CI为Qt应用程序:构建与不同的Qt版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆