From 18a3b64ab07ade6bfc9bb068956beed2032d9b58 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Mon, 22 Jul 2019 15:51:50 +0200 Subject: C++: Add support for clang on Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is about clang in "mingw mode", not clang-cl. When targeting Windows, clang is a lot like mingw, so factor out the common parts into a new base module. Testing uncovered a number of invalid assumptions in our autotests, which are also fixed in this patch. In addition, minor adjustments had to be made to the Qt.core module and to the qbscore lib. Change-Id: I73085dc62a65e2a9d0397cf234c8641989246f22 Reviewed-by: Ivan Komissarov Reviewed-by: Jörg Bornemann --- .../api/testdata/infinite-loop-process/infinite-loop.qbs | 9 +++++++++ .../link-staticlibs-dynamiclibs.qbs | 7 +++++++ tests/auto/api/testdata/timeout-process/timeout.qbs | 8 ++++++++ tests/auto/api/tst_api.cpp | 13 ++++++------- 4 files changed, 30 insertions(+), 7 deletions(-) (limited to 'tests/auto/api') diff --git a/tests/auto/api/testdata/infinite-loop-process/infinite-loop.qbs b/tests/auto/api/testdata/infinite-loop-process/infinite-loop.qbs index f0de12df1..f4ea8bf83 100644 --- a/tests/auto/api/testdata/infinite-loop-process/infinite-loop.qbs +++ b/tests/auto/api/testdata/infinite-loop-process/infinite-loop.qbs @@ -4,12 +4,21 @@ Project { consoleApplication: true // suppress bundle generation files: "main.cpp" name: "infinite-loop" + cpp.cxxLanguageVersion: "c++11" + Properties { + condition: qbs.toolchain.contains("gcc") + cpp.driverFlags: "-pthread" + } } Product { type: "mytype" name: "caller" Depends { name: "infinite-loop" } + Depends { + name: "cpp" // Make sure build environment is set up properly. + condition: qbs.hostOS.contains("windows") && qbs.toolchain.contains("gcc") + } Rule { inputsFromDependencies: "application" outputFileTags: "mytype" diff --git a/tests/auto/api/testdata/link-staticlibs-dynamiclibs/link-staticlibs-dynamiclibs.qbs b/tests/auto/api/testdata/link-staticlibs-dynamiclibs/link-staticlibs-dynamiclibs.qbs index eade97126..d7ed6c862 100644 --- a/tests/auto/api/testdata/link-staticlibs-dynamiclibs/link-staticlibs-dynamiclibs.qbs +++ b/tests/auto/api/testdata/link-staticlibs-dynamiclibs/link-staticlibs-dynamiclibs.qbs @@ -11,6 +11,13 @@ Project { files: [ "static1.cpp" ] Depends { name: "cpp" } Depends { name: "dynamic1" } + + Probe { + id: osCheck + property bool isNormalUnix: qbs.targetOS.contains("unix") + && !qbs.targetOS.contains("darwin") + configure: { console.info("is normal unix: " + (isNormalUnix ? "yes" : "no")); } + } } DynamicLibrary { diff --git a/tests/auto/api/testdata/timeout-process/timeout.qbs b/tests/auto/api/testdata/timeout-process/timeout.qbs index 3f79dce96..bdf6833fd 100644 --- a/tests/auto/api/testdata/timeout-process/timeout.qbs +++ b/tests/auto/api/testdata/timeout-process/timeout.qbs @@ -5,12 +5,20 @@ Project { files: "main.cpp" name: "infinite-loop" cpp.cxxLanguageVersion: "c++11" + Properties { + condition: qbs.toolchain.contains("gcc") + cpp.driverFlags: "-pthread" + } } Product { type: "product-under-test" name: "caller" Depends { name: "infinite-loop" } + Depends { + name: "cpp" // Make sure build environment is set up properly. + condition: qbs.hostOS.contains("windows") && qbs.toolchain.contains("gcc") + } Rule { inputsFromDependencies: "application" outputFileTags: "product-under-test" diff --git a/tests/auto/api/tst_api.cpp b/tests/auto/api/tst_api.cpp index 1a98f5f21..36a98fdaa 100644 --- a/tests/auto/api/tst_api.cpp +++ b/tests/auto/api/tst_api.cpp @@ -1556,9 +1556,13 @@ void TestApi::linkStaticAndDynamicLibs() BuildDescriptionReceiver bdr; qbs::BuildOptions options; options.setEchoMode(qbs::CommandEchoModeCommandLine); + m_logSink->output.clear(); const qbs::ErrorInfo errorInfo = doBuildProject("link-staticlibs-dynamiclibs", &bdr, nullptr, nullptr, options); VERIFY_NO_ERROR(errorInfo); + const bool isNormalUnix = m_logSink->output.contains("is normal unix: yes"); + const bool isNotNormalUnix = m_logSink->output.contains("is normal unix: no"); + QVERIFY2(isNormalUnix != isNotNormalUnix, qPrintable(m_logSink->output)); // The dependencies libdynamic1.so and libstatic2.a must not appear in the link command for the // executable. The -rpath-link line for libdynamic1.so must be there. @@ -1575,12 +1579,7 @@ void TestApi::linkStaticAndDynamicLibs() } } QVERIFY(!appLinkCmd.isEmpty()); - std::string targetPlatform = buildProfile.value("qbs.targetPlatform") - .toString().toStdString(); - std::vector targetOS = qbs::Internal::HostOsInfo::canonicalOSIdentifiers( - targetPlatform); - if (!qbs::Internal::contains(targetOS, "darwin") - && !qbs::Internal::contains(targetOS, "windows")) { + if (isNormalUnix) { const std::regex rpathLinkRex("-rpath-link=\\S*/" + relativeProductBuildDir("dynamic2").toStdString()); const auto ln = appLinkCmd.toStdString(); @@ -2861,7 +2860,7 @@ void TestApi::timeout() QVERIFY(waitForFinished(buildJob.get(), testTimeoutInMsecs())); QVERIFY(buildJob->error().hasError()); const auto errorString = buildJob->error().toString(); - QVERIFY(errorString.contains("cancel")); + QVERIFY2(errorString.contains("cancel"), qPrintable(errorString)); QVERIFY(errorString.contains("timeout")); } -- cgit v1.2.3