diff --git a/.travis.yml b/.travis.yml index cb80aac..0a0f543 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,7 @@ jobs: include: # Qst application for Linux - stage: build + name: Build Qst application (linux_amd64) sudo: required services: - docker @@ -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 @@ -46,6 +47,7 @@ jobs: - find qst/ # Qst application for Windows - stage: build + name: Build Qst application (mingw-w64) sudo: required services: - docker @@ -68,6 +70,7 @@ jobs: - find qst/ # Launchpad probe for CC13x0 - stage: build + name: Build Launchpad probe sudo: required services: - docker @@ -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" @@ -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" diff --git a/dist/distribute.qbs b/dist/distribute.qbs index 65727d8..f527e2b 100644 --- a/dist/distribute.qbs +++ b/dist/distribute.qbs @@ -11,6 +11,7 @@ Product { Depends { name: "cpp" } Depends { name: "Qt.core" } Depends { name: "Qt.qml" } + Depends { name: "qstbuildconfig" } Group { name: "Qt QML files" diff --git a/qbs/imports/QstAutoTest.qbs b/qbs/imports/QstAutoTest.qbs index 189b66d..99891a3 100644 --- a/qbs/imports/QstAutoTest.qbs +++ b/qbs/imports/QstAutoTest.qbs @@ -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 + '"' @@ -19,8 +19,8 @@ QtApplication { consoleApplication: true Group { - fileTagsFilter: product.type - qbs.install: project.installTests + fileTagsFilter: "application" + qbs.install: qstbuildconfig.installTests qbs.installDir : "bin" } } diff --git a/qbs/modules/qstbuildconfig/common.qbs b/qbs/modules/qstbuildconfig/common.qbs new file mode 100644 index 0000000..1258fb6 --- /dev/null +++ b/qbs/modules/qstbuildconfig/common.qbs @@ -0,0 +1,9 @@ +import qbs + +Module { + name: "qbsbuildconfig" + property bool runAutotest: false + property bool installTests: false + + qbs.installPrefix: "" +} diff --git a/qst-project.qbs b/qst-project.qbs index 789a7c0..89e911f 100644 --- a/qst-project.qbs +++ b/qst-project.qbs @@ -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" } diff --git a/share/share.qbs b/share/share.qbs index 888c361..a886be9 100644 --- a/share/share.qbs +++ b/share/share.qbs @@ -10,6 +10,8 @@ Product { sourceDirectory + "/share/qst/imports", ] + Depends { name: "qstbuildconfig" } + Group { name : "qst imports" prefix : "qst/imports/qst/" diff --git a/src/launchpad-probe/launchpad-probe.qbs b/src/launchpad-probe/launchpad-probe.qbs index 058d995..ede9a12 100644 --- a/src/launchpad-probe/launchpad-probe.qbs +++ b/src/launchpad-probe/launchpad-probe.qbs @@ -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" diff --git a/src/qst/qst.qbs b/src/qst/qst.qbs index 50dba14..a613493 100644 --- a/src/qst/qst.qbs +++ b/src/qst/qst.qbs @@ -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, @@ -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 + '"' + ] } } diff --git a/tests/qsttest.cpp b/tests/qsttest.cpp index cb93229..69e7b12 100644 --- a/tests/qsttest.cpp +++ b/tests/qsttest.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #ifndef PROJECTPATH @@ -42,6 +43,13 @@ const QString QstTest::m_defaultImportPath = QDir(QProcessEnvironment::systemEnvironment().value( "PROJECTPATH", PROJECTPATH) + "/share/qst/imports/").absolutePath(); +namespace { + QVector searchDirectories = { + QDir(QST_APPLICATION_DIR), + QDir(QCoreApplication::applicationDirPath()) + }; +} + QstTest::QstTest() { m_qstProcess.setWorkingDirectory(QDir::tempPath()); @@ -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; @@ -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(); @@ -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) diff --git a/tests/qsttest.h b/tests/qsttest.h index 4f34005..94966de 100644 --- a/tests/qsttest.h +++ b/tests/qsttest.h @@ -52,6 +52,7 @@ class QstTest : public QObject QProcess& qstProcess(); const QstTestResults& results() const; QString stdError() const; + QString qstFilepath() const; private: QProcess m_qstProcess; diff --git a/tests/tests.qbs b/tests/tests.qbs index 68554f1..c36c60a 100644 --- a/tests/tests.qbs +++ b/tests/tests.qbs @@ -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 } }