Clang: Fix release build

* The QtTest include is not available in release builds.
* Make the batch file mode only available in debug/test builds as that
  one uses test utilities that are only available in debug builds.

Change-Id: I441c51ec00b14b81a396ad0199882cf46fff10b0
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Nikolai Kosjar
2017-02-27 16:08:04 +01:00
parent 69ec8054a6
commit d1133916a9
4 changed files with 13 additions and 11 deletions

View File

@@ -54,7 +54,7 @@
#include <QLoggingCategory> #include <QLoggingCategory>
#include <QSharedPointer> #include <QSharedPointer>
#include <QString> #include <QString>
#include <QtTest> #include <QThread>
using namespace ClangBackEnd; using namespace ClangBackEnd;
using namespace ClangCodeModel; using namespace ClangCodeModel;

View File

@@ -9,9 +9,7 @@ SOURCES += \
clangassistproposal.cpp \ clangassistproposal.cpp \
clangassistproposalitem.cpp \ clangassistproposalitem.cpp \
clangassistproposalmodel.cpp \ clangassistproposalmodel.cpp \
clangautomationutils.cpp \
clangbackendipcintegration.cpp \ clangbackendipcintegration.cpp \
clangbatchfileprocessor.cpp \
clangcodemodelplugin.cpp \ clangcodemodelplugin.cpp \
clangcompletionassistinterface.cpp \ clangcompletionassistinterface.cpp \
clangcompletionassistprocessor.cpp \ clangcompletionassistprocessor.cpp \
@@ -41,9 +39,7 @@ HEADERS += \
clangassistproposal.h \ clangassistproposal.h \
clangassistproposalitem.h \ clangassistproposalitem.h \
clangassistproposalmodel.h \ clangassistproposalmodel.h \
clangautomationutils.h \
clangbackendipcintegration.h \ clangbackendipcintegration.h \
clangbatchfileprocessor.h \
clangcodemodelplugin.h \ clangcodemodelplugin.h \
clangcompletionassistinterface.h \ clangcompletionassistinterface.h \
clangcompletionassistprocessor.h \ clangcompletionassistprocessor.h \
@@ -80,10 +76,14 @@ DISTFILES += \
equals(TEST, 1) { equals(TEST, 1) {
HEADERS += \ HEADERS += \
test/clangcodecompletion_test.h test/clangautomationutils.h \
test/clangbatchfileprocessor.h \
test/clangcodecompletion_test.h \
SOURCES += \ SOURCES += \
test/clangcodecompletion_test.cpp test/clangautomationutils.cpp \
test/clangbatchfileprocessor.cpp \
test/clangcodecompletion_test.cpp \
RESOURCES += test/data/clangtestdata.qrc RESOURCES += test/data/clangtestdata.qrc
OTHER_FILES += $$files(test/data/*) OTHER_FILES += $$files(test/data/*)

View File

@@ -41,12 +41,8 @@ QtcPlugin {
"clangassistproposalitem.h", "clangassistproposalitem.h",
"clangassistproposalmodel.cpp", "clangassistproposalmodel.cpp",
"clangassistproposalmodel.h", "clangassistproposalmodel.h",
"clangautomationutils.cpp",
"clangautomationutils.h",
"clangbackendipcintegration.cpp", "clangbackendipcintegration.cpp",
"clangbackendipcintegration.h", "clangbackendipcintegration.h",
"clangbatchfileprocessor.cpp",
"clangbatchfileprocessor.h",
"clangcodemodel.qrc", "clangcodemodel.qrc",
"clangcodemodelplugin.cpp", "clangcodemodelplugin.cpp",
"clangcodemodelplugin.h", "clangcodemodelplugin.h",
@@ -102,6 +98,10 @@ QtcPlugin {
condition: qtc.testsEnabled condition: qtc.testsEnabled
prefix: "test/" prefix: "test/"
files: [ files: [
"clangautomationutils.cpp",
"clangautomationutils.h",
"clangbatchfileprocessor.cpp",
"clangbatchfileprocessor.h",
"clangcodecompletion_test.cpp", "clangcodecompletion_test.cpp",
"clangcodecompletion_test.h", "clangcodecompletion_test.h",
"data/clangtestdata.qrc", "data/clangtestdata.qrc",

View File

@@ -98,11 +98,13 @@ void ClangCodeModelPlugin::extensionsInitialized()
// For e.g. creation of profile-guided optimization builds. // For e.g. creation of profile-guided optimization builds.
void ClangCodeModelPlugin::maybeHandleBatchFileAndExit() const void ClangCodeModelPlugin::maybeHandleBatchFileAndExit() const
{ {
#ifdef WITH_TESTS
const QString batchFilePath = QString::fromLocal8Bit(qgetenv("QTC_CLANG_BATCH")); const QString batchFilePath = QString::fromLocal8Bit(qgetenv("QTC_CLANG_BATCH"));
if (!batchFilePath.isEmpty() && QTC_GUARD(QFileInfo::exists(batchFilePath))) { if (!batchFilePath.isEmpty() && QTC_GUARD(QFileInfo::exists(batchFilePath))) {
const bool runSucceeded = runClangBatchFile(batchFilePath); const bool runSucceeded = runClangBatchFile(batchFilePath);
QCoreApplication::exit(!runSucceeded); QCoreApplication::exit(!runSucceeded);
} }
#endif
} }
#ifdef WITH_TESTS #ifdef WITH_TESTS