Commit aafba07c authored by Volker Krause's avatar Volker Krause
Browse files

Add data source for the used compiler type and version

parent 2ce08ed0
......@@ -16,6 +16,7 @@
*/
#include <provider/core/applicationversionsource.h>
#include <provider/core/compilerinfosource.h>
#include <provider/core/cpuinfosource.h>
#include <provider/core/localeinfosource.h>
#include <provider/core/platforminfosource.h>
......@@ -260,6 +261,17 @@ private slots:
QVERIFY(!m.value(QLatin1String("glslVersion")).toString().isEmpty());
#endif
}
void testCompilerInfoSource()
{
CompilerInfoSource src;
const auto m = src.data().toMap();
qDebug() << m;
QVERIFY(m.contains(QLatin1String("type")));
QVERIFY(!m.value(QLatin1String("type")).toString().isEmpty());
QVERIFY(m.contains(QLatin1String("version")));
QVERIFY(!m.value(QLatin1String("version")).toString().isEmpty());
}
};
QTEST_MAIN(DataSourceTest)
......
......@@ -218,6 +218,17 @@
],
"name": "OpenGL Profile Distribution",
"type": "category"
},
{
"elements": [
{
"schemaEntry": "compiler",
"schemaEntryElement": "type",
"type": "value"
}
],
"name": "Compiler Distribution",
"type": "category"
}
],
"name": "org.kde.orwell",
......@@ -375,6 +386,20 @@
],
"name": "opengl",
"type": "scalar"
},
{
"elements": [
{
"name": "type",
"type": "string"
},
{
"name": "version",
"type": "string"
}
],
"name": "compiler",
"type": "scalar"
}
]
}
{
"name": "Compiler",
"schema": [
{
"name": "compiler",
"type": "scalar",
"elements": [
{
"name": "type",
"type": "string"
},
{
"name": "version",
"type": "string"
}
]
}
],
"aggregation": [ {
"type": "category",
"name": "Compiler Distribution",
"elements": [ { "type": "value", "schemaEntry": "compiler", "schemaEntryElement": "type" } ]
} ]
}
......@@ -2,6 +2,7 @@
<RCC version="1.0">
<qresource prefix="/org.kde.user-feedback/schematemplates">
<file>applicationVersion.schema</file>
<file>compiler.schema</file>
<file>cpu.schema</file>
<file>locale.schema</file>
<file>opengl.schema</file>
......
......@@ -3,6 +3,7 @@ ecm_create_qm_loader(userfeedback_core_QM_LOADER userfeedbackprovider5_qt)
set(userfeedback_core_srcs
abstractdatasource.cpp
applicationversionsource.cpp
compilerinfosource.cpp
cpuinfosource.cpp
localeinfosource.cpp
openglinfosource.cpp
......@@ -41,6 +42,7 @@ ecm_generate_headers(UserFeedbackCore_HEADERS
HEADER_NAMES
AbstractDataSource
ApplicationVersionSource
CompilerInfoSource
CpuInfoSource
LocaleInfoSource
OpenGLInfoSource
......
/*
Copyright (C) 2017 Volker Krause <vkrause@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "compilerinfosource.h"
#include <QVariant>
using namespace UserFeedback;
CompilerInfoSource::CompilerInfoSource()
: AbstractDataSource(QStringLiteral("compiler"))
{
}
QString CompilerInfoSource::description() const
{
return tr("The compiler used to build this application.");
}
#define STRINGIFY(x) #x
#define INT2STR(x) STRINGIFY(x)
QVariant CompilerInfoSource::data()
{
QVariantMap m;
#ifdef Q_CC_GNU
m.insert(QStringLiteral("type"), QStringLiteral("GCC"));
m.insert(QStringLiteral("version"), QString::fromLatin1( "" INT2STR(__GNUC__) "." INT2STR(__GNUC_MINOR__)));
#endif
#ifdef Q_CC_CLANG
m.insert(QStringLiteral("type"), QStringLiteral("Clang"));
m.insert(QStringLiteral("version"), QString::fromLatin1( "" INT2STR(__clang_major__) "." INT2STR(__clang_minor__)));
#endif
#ifdef Q_CC_MSVC
m.insert(QStringLiteral("type"), QStringLiteral("MSVC"));
m.insert(QStringLiteral("version"), QString::fromLatin1( "" INT2STR(_MSC_VER)));
#endif
if (m.isEmpty())
m.insert(QStringLiteral("type"), QStringLiteral("unknown"));
return m;
}
#undef STRINGIFY
#undef INT2STR
/*
Copyright (C) 2017 Volker Krause <vkrause@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef USERFEEDBACK_COMPILERINFOSOURCE_H
#define USERFEEDBACK_COMPILERINFOSOURCE_H
#include "abstractdatasource.h"
namespace UserFeedback {
/*! Data source reporting which compiler was used to build this code.
* @note This will report which compiler was used to build the feedback
* library, which technically does not need to be the same as used for
* the application code. This is particularly true for compilers that
* don't break ABI regularly (such as Clang and GCC), so this information
* is most reliable when this is not the case, e.g. with MSVC.
*/
class USERFEEDBACKCORE_EXPORT CompilerInfoSource : public AbstractDataSource
{
public:
Q_DECLARE_TR_FUNCTIONS(UserFeedback::CompilerInfoSource)
public:
CompilerInfoSource();
QString description() const override;
QVariant data() override;
};
}
#endif // USERFEEDBACK_COMPILERINFOSOURCE_H
......@@ -22,6 +22,7 @@
#include <NotificationPopup>
#include <StyleInfoSource>
#include <ApplicationVersionSource>
#include <CompilerInfoSource>
#include <CpuInfoSource>
#include <LocaleInfoSource>
#include <OpenGLInfoSource>
......@@ -115,6 +116,7 @@ int main(int argc, char** argv)
provider->setApplicationStartsUntilEncouragement(5);
provider->setEncouragementDelay(10);
provider->addDataSource(new UserFeedback::ApplicationVersionSource, UserFeedback::Provider::BasicSystemInformation);
provider->addDataSource(new UserFeedback::CompilerInfoSource, UserFeedback::Provider::BasicSystemInformation);
provider->addDataSource(new UserFeedback::CpuInfoSource, UserFeedback::Provider::DetailedSystemInformation);
provider->addDataSource(new UserFeedback::LocaleInfoSource, UserFeedback::Provider::DetailedSystemInformation);
provider->addDataSource(new UserFeedback::OpenGLInfoSource, UserFeedback::Provider::DetailedSystemInformation);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment