Skip to content

Commit

Permalink
Cleanup installation process
Browse files Browse the repository at this point in the history
- Do not use destinationDir any longer
- Let autotests find the executable automatically
  • Loading branch information
rweickelt committed May 20, 2019
1 parent 07829b8 commit 8c60ecb
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 21 deletions.
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
include:
# Qst application for Linux
- stage: build
name: Build Qst application (linux_amd64)
sudo: required
services:
- docker
Expand All @@ -35,7 +36,7 @@ jobs:
- TARGET=qst
- PLATFORM=linux-x86_64
- QBS_PROFILE=qt5
- QBS_OPTIONS="project.runAutotest:true project.version:$QST_VERSION"
- QBS_OPTIONS="modules.qstbuildconfig.runAutotest:true project.version:$QST_VERSION"
script:
- docker-compose run --rm linux qbs install
--install-root qst
Expand All @@ -46,6 +47,7 @@ jobs:
- find qst/
# Qst application for Windows
- stage: build
name: Build Qst application (mingw-w64)
sudo: required
services:
- docker
Expand All @@ -68,6 +70,7 @@ jobs:
- find qst/
# Launchpad probe for CC13x0
- stage: build
name: Build Launchpad probe
sudo: required
services:
- docker
Expand All @@ -91,6 +94,7 @@ jobs:
- find qst/
# Deploy linux bundle
- stage: bundle and deploy
name: Bundle and deploy for Linux
sudo: false
env:
- TARGET="linux-x86_64 bundle"
Expand All @@ -113,6 +117,7 @@ jobs:
all_branches: true
# Deploy windows bundle
- stage: bundle and deploy
name: Bundle and deploy for Windows
sudo: false
env:
- TARGET="windows-x86_64 bundle"
Expand Down
1 change: 1 addition & 0 deletions dist/distribute.qbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Product {
Depends { name: "cpp" }
Depends { name: "Qt.core" }
Depends { name: "Qt.qml" }
Depends { name: "qstbuildconfig" }

Group {
name: "Qt QML files"
Expand Down
10 changes: 5 additions & 5 deletions qbs/imports/QstAutoTest.qbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import qbs
QtApplication {
type: [ "application", "autotest" ]

condition : { return qbs.architecture.startsWith("x86") }
condition : qbs.architecture.startsWith("x86")

property string dataDirectory: sourceDirectory

destinationDirectory: "bin"

Depends { name : "Qt.testlib" }
Depends { name: "qsttestlib" }
Depends { name: "qstbuildconfig" }
Depends { name: "qst-application" }

cpp.defines: base.concat([
'SOURCE_DIR="' + dataDirectory + '"'
Expand All @@ -19,8 +19,8 @@ QtApplication {
consoleApplication: true

Group {
fileTagsFilter: product.type
qbs.install: project.installTests
fileTagsFilter: "application"
qbs.install: qstbuildconfig.installTests
qbs.installDir : "bin"
}
}
9 changes: 9 additions & 0 deletions qbs/modules/qstbuildconfig/common.qbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import qbs

Module {
name: "qbsbuildconfig"
property bool runAutotest: false
property bool installTests: false

qbs.installPrefix: ""
}
2 changes: 0 additions & 2 deletions qst-project.qbs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ Project {

minimumQbsVersion: "1.6"

property bool runAutotest: false
property bool installTests: false
property string commit: Environment.getEnv("QST_COMMIT") || "unspecified"
property string version: Environment.getEnv("QST_VERSION") || "local-build"
}
2 changes: 2 additions & 0 deletions share/share.qbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Product {
sourceDirectory + "/share/qst/imports",
]

Depends { name: "qstbuildconfig" }

Group {
name : "qst imports"
prefix : "qst/imports/qst/"
Expand Down
1 change: 1 addition & 0 deletions src/launchpad-probe/launchpad-probe.qbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Project {

Depends { name: "simplelink"; submodules: [ "core", "drivers", "tirtos", "board" ] }
Depends { name: "shared-types" }
Depends { name: "qstbuildconfig" }

simplelink.core.device: "cc1310f128"
simplelink.board.type: "CC1310_LAUNCHXL"
Expand Down
23 changes: 16 additions & 7 deletions src/qst/qst.qbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,23 @@ QtApplication {

condition : qbs.architecture.startsWith("x86")

Depends { name : "Qt.qml"; }
Depends { name : "Qt.serialport"; }
Depends {
name : "Qt";
submodules: [
"core",
"network",
"qml",
"qml-private",
"serialport"
]
}
Depends { name : "cpp" }
Depends { name : "Qt.qml-private"; }
Depends { name : "shared-types" }
Depends { name: "qstbuildconfig" }

cpp.cxxLanguageVersion : "c++14"
cpp.rpaths: [
"$ORIGIN/../lib/"
cpp.rpathOrigin + "/../lib/"
]
cpp.defines: [
"QST_COMMIT=" + project.commit,
Expand Down Expand Up @@ -112,16 +120,17 @@ QtApplication {
]

Group {
fileTagsFilter: product.type
fileTagsFilter: "application"
qbs.install: true
qbs.installDir : "bin"
}

destinationDirectory : "bin"

Export {
Depends { name: "cpp" }
cpp.includePaths: product.sourceDirectory
cpp.defines: [
'QST_APPLICATION_DIR="' + product.destinationDirectory + '"'
]
}
}

29 changes: 25 additions & 4 deletions tests/qsttest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>
#include <QtCore/QProcessEnvironment>
#include <QtCore/QSysInfo>
#include <QtTest/QTest>

#ifndef PROJECTPATH
Expand All @@ -42,6 +43,13 @@ const QString QstTest::m_defaultImportPath =
QDir(QProcessEnvironment::systemEnvironment().value(
"PROJECTPATH", PROJECTPATH) + "/share/qst/imports/").absolutePath();

namespace {
QVector<QDir> searchDirectories = {
QDir(QST_APPLICATION_DIR),
QDir(QCoreApplication::applicationDirPath())
};
}

QstTest::QstTest()
{
m_qstProcess.setWorkingDirectory(QDir::tempPath());
Expand All @@ -52,6 +60,20 @@ QString QstTest::dataPath(const QString& directory) const
return m_dataDirectory.absoluteFilePath(directory);
}

QString QstTest::qstFilepath() const
{
QString executableSuffix = QSysInfo::productType() == "windows" ? ".exe" : "";
for (const auto& dir: searchDirectories)
{
if (dir.exists("qst" + executableSuffix))
{
return dir.absoluteFilePath("qst" + executableSuffix);
}
}
Q_ASSERT(false);
return "";
}

void QstTest::setTimeoutMs(int milliseconds)
{
m_timeoutMs = milliseconds;
Expand All @@ -61,8 +83,8 @@ QstTestResults QstTest::execQstRun(const QStringList& arguments, int timeoutMs)
{
QStringList cmdLine = { "run", "--import", m_defaultImportPath };
cmdLine += arguments;
QDir qstDir(QCoreApplication::applicationDirPath());
m_qstProcess.start(qstDir.absoluteFilePath("qst"), cmdLine);

m_qstProcess.start(qstFilepath(), cmdLine);
if (!m_qstProcess.waitForFinished(timeoutMs))
{
m_qstProcess.kill();
Expand All @@ -76,8 +98,7 @@ bool QstTest::execQstRun(const QStringList& arguments, int expectedExitCode, con
{
QStringList cmdLine = { "run", "--import", m_defaultImportPath };
cmdLine += arguments;
QDir qstDir(QCoreApplication::applicationDirPath());
m_qstProcess.start(qstDir.absoluteFilePath("qst"), cmdLine);
m_qstProcess.start(qstFilepath(), cmdLine);
m_qstProcess.waitForFinished();

if (m_qstProcess.exitCode() == expectedExitCode)
Expand Down
1 change: 1 addition & 0 deletions tests/qsttest.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class QstTest : public QObject
QProcess& qstProcess();
const QstTestResults& results() const;
QString stdError() const;
QString qstFilepath() const;

private:
QProcess m_qstProcess;
Expand Down
5 changes: 3 additions & 2 deletions tests/tests.qbs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ Project {
}

AutotestRunner {
condition : { return qbs.architecture.startsWith("x86") }
condition : qbs.architecture.startsWith("x86")

builtByDefault: project.runAutotest
Depends { name: "qstbuildconfig" }
builtByDefault: qstbuildconfig.runAutotest
}

}

0 comments on commit 8c60ecb

Please sign in to comment.