forked from qt-creator/qt-creator
QmlPuppet: Fix the debug messages
Change-Id: I2b1d969a665863232a8d60a943fce87b6bb4dd3c Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -38,39 +38,20 @@ add_qtc_executable(qml2puppet
|
||||
DEPENDS
|
||||
Qt::CorePrivate Qt::Widgets Qt::QmlPrivate
|
||||
Qt::QuickPrivate Qt::Network Qt::GuiPrivate
|
||||
app_version
|
||||
QmlPuppetCommunication
|
||||
INCLUDES
|
||||
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
SOURCES
|
||||
qml2puppet/qml2puppetmain.cpp
|
||||
qml2puppet/qmlbase.h
|
||||
qml2puppet/appmetadata.cpp qml2puppet/appmetadata.h
|
||||
qml2puppet/qmlpuppet.h qml2puppet/qmlpuppet.cpp qml2puppet/configcrashpad.h
|
||||
qml2puppet/qmlpuppet.h qml2puppet/qmlpuppet.cpp
|
||||
qml2puppet/configcrashpad.h
|
||||
qmlpuppet.qrc
|
||||
PROPERTIES
|
||||
OUTPUT_NAME qml2puppet-${IDE_VERSION}
|
||||
)
|
||||
|
||||
if (TARGET qml2puppet)
|
||||
execute_process(
|
||||
COMMAND git describe --tags --always --dirty=+
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
RESULT_VARIABLE GIT_SHA_RESULT
|
||||
OUTPUT_VARIABLE GIT_SHA
|
||||
ERROR_VARIABLE GIT_SHA_ERROR
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
#if we are not a git repository use the .tag file
|
||||
if(NOT GIT_SHA)
|
||||
file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/../../../.tag GIT_SHA LIMIT_COUNT 1)
|
||||
endif()
|
||||
|
||||
set(IDE_REVISION_STR ${GIT_SHA})
|
||||
|
||||
configure_file(../../app/app_version.h.cmakein app/app_version.h ESCAPE_QUOTES)
|
||||
endif()
|
||||
|
||||
extend_qtc_executable(qml2puppet
|
||||
CONDITION Qt6_VERSION
|
||||
SOURCES
|
||||
|
@@ -1,51 +0,0 @@
|
||||
// Copyright (C) 2022 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "appmetadata.h"
|
||||
|
||||
#include <app/app_version.h>
|
||||
|
||||
namespace QDSMeta::AppInfo {
|
||||
|
||||
void printAppInfo()
|
||||
{
|
||||
qInfo() << Qt::endl
|
||||
<< "<< QDS Meta Info >>" << Qt::endl
|
||||
<< "App Info" << Qt::endl
|
||||
<< " - Name :" << Core::Constants::IDE_ID << Qt::endl
|
||||
<< " - Version :" << Core::Constants::IDE_VERSION_DISPLAY << Qt::endl
|
||||
<< " - Author :" << Core::Constants::IDE_AUTHOR << Qt::endl
|
||||
<< " - Year :" << Core::Constants::IDE_YEAR << Qt::endl
|
||||
<< " - App :" << QCoreApplication::applicationName() << Qt::endl
|
||||
<< "Build Info " << Qt::endl
|
||||
<< " - Date :" << __DATE__ << Qt::endl
|
||||
<< " - Commit :" << QStringLiteral(QDS_STRINGIFY(IDE_REVISION_STR)) << Qt::endl
|
||||
<< " - Qt Version :" << QT_VERSION_STR << Qt::endl
|
||||
<< "Compiler Info " << Qt::endl
|
||||
#if defined(__GNUC__)
|
||||
<< " - GCC :" << __GNUC__ << Qt::endl
|
||||
<< " - GCC Minor :" << __GNUC_MINOR__ << Qt::endl
|
||||
<< " - GCC Patch :" << __GNUC_PATCHLEVEL__ << Qt::endl
|
||||
#endif
|
||||
#if defined(_MSC_VER)
|
||||
<< " - MSC Short :" << _MSC_VER << Qt::endl
|
||||
<< " - MSC Full :" << _MSC_FULL_VER << Qt::endl
|
||||
#endif
|
||||
#if defined(__clang__)
|
||||
<< " - clang maj :" << __clang_major__ << Qt::endl
|
||||
<< " - clang min :" << __clang_minor__ << Qt::endl
|
||||
<< " - clang patch :" << __clang_patchlevel__ << Qt::endl
|
||||
#endif
|
||||
<< "<< End Of QDS Meta Info >>" << Qt::endl;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void registerAppInfo(const QString &appName)
|
||||
{
|
||||
QCoreApplication::setOrganizationName(Core::Constants::IDE_AUTHOR);
|
||||
QCoreApplication::setOrganizationDomain("qt-project.org");
|
||||
QCoreApplication::setApplicationName(appName);
|
||||
QCoreApplication::setApplicationVersion(Core::Constants::IDE_VERSION_LONG);
|
||||
}
|
||||
|
||||
} // namespace QDSMeta::AppInfo
|
@@ -1,55 +0,0 @@
|
||||
// Copyright (C) 2022 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
#pragma once
|
||||
|
||||
#include <QCommandLineParser>
|
||||
#include <QLoggingCategory>
|
||||
|
||||
// Common functions can be used in all QDS apps
|
||||
namespace QDSMeta {
|
||||
|
||||
namespace Logging {
|
||||
inline Q_LOGGING_CATEGORY(deprecated, "qt.tools.qds.deprecated");
|
||||
inline Q_LOGGING_CATEGORY(verbose1, "qt.tools.qds.verbose1");
|
||||
inline Q_LOGGING_CATEGORY(verbose2, "qt.tools.qds.verbose2");
|
||||
|
||||
inline void registerMessageHandler()
|
||||
{
|
||||
qInstallMessageHandler(
|
||||
[](QtMsgType type, const QMessageLogContext &context, const QString &msg) {
|
||||
auto tPrinter = [&](const QString &msgPrefix) {
|
||||
fprintf(stderr,
|
||||
"%s: %s (%s:%u, %s)\n",
|
||||
msgPrefix.toLocal8Bit().constData(),
|
||||
msg.toLocal8Bit().constData(),
|
||||
context.file,
|
||||
context.line,
|
||||
context.function);
|
||||
};
|
||||
|
||||
if (type == QtDebugMsg)
|
||||
tPrinter("Debug");
|
||||
else if (type == QtInfoMsg)
|
||||
tPrinter("Info");
|
||||
else if (type == QtWarningMsg)
|
||||
tPrinter("Warning");
|
||||
else if (type == QtCriticalMsg)
|
||||
tPrinter("Critical");
|
||||
else if (type == QtFatalMsg) {
|
||||
tPrinter("Fatal");
|
||||
abort();
|
||||
}
|
||||
});
|
||||
}
|
||||
} // namespace Logging
|
||||
|
||||
namespace AppInfo {
|
||||
|
||||
#define STRINGIFY_INTERNAL(x) #x
|
||||
#define QDS_STRINGIFY(x) STRINGIFY_INTERNAL(x)
|
||||
|
||||
void printAppInfo();
|
||||
void registerAppInfo(const QString &appName);
|
||||
|
||||
} // namespace AppInfo
|
||||
} // namespace QDSMeta
|
@@ -7,6 +7,34 @@
|
||||
#include "runner/qmlruntime.h"
|
||||
#endif
|
||||
|
||||
#include <QLoggingCategory>
|
||||
|
||||
inline Q_LOGGING_CATEGORY(deprecated, "qt.tools.qds.deprecated");
|
||||
inline Q_LOGGING_CATEGORY(verbose1, "qt.tools.qds.verbose1");
|
||||
inline Q_LOGGING_CATEGORY(verbose2, "qt.tools.qds.verbose2");
|
||||
|
||||
void registerMessageHandler(
|
||||
QtMsgType type, [[maybe_unused]] const QMessageLogContext &context, const QString &msg)
|
||||
{
|
||||
auto tPrinter = [&](const QString &msgPrefix) {
|
||||
fprintf(
|
||||
stderr, "%s: %s\n", msgPrefix.toLocal8Bit().constData(), msg.toLocal8Bit().constData());
|
||||
};
|
||||
|
||||
if (type == QtDebugMsg)
|
||||
tPrinter("Debug");
|
||||
else if (type == QtInfoMsg)
|
||||
tPrinter("Info");
|
||||
else if (type == QtWarningMsg)
|
||||
tPrinter("Warning");
|
||||
else if (type == QtCriticalMsg)
|
||||
tPrinter("Critical");
|
||||
else if (type == QtFatalMsg) {
|
||||
tPrinter("Fatal");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
auto getQmlRunner(int &argc, char **argv)
|
||||
{
|
||||
#ifdef ENABLE_INTERNAL_QML_RUNTIME
|
||||
@@ -24,7 +52,6 @@ auto getQmlRunner(int &argc, char **argv)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QDSMeta::Logging::registerMessageHandler();
|
||||
QDSMeta::AppInfo::registerAppInfo("Qml2Puppet");
|
||||
qInstallMessageHandler(registerMessageHandler);
|
||||
return getQmlRunner(argc, argv)->run();
|
||||
}
|
||||
|
@@ -3,27 +3,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDir>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QQmlComponent>
|
||||
#include <QQmlContext>
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QFileOpenEvent>
|
||||
#include <QLibraryInfo>
|
||||
#include <QSurfaceFormat>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QCommandLineParser>
|
||||
#include <QQmlApplicationEngine>
|
||||
|
||||
#include <QStandardPaths>
|
||||
#include <QTranslator>
|
||||
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include "appmetadata.h"
|
||||
#include <iostream>
|
||||
|
||||
#include <QApplication>
|
||||
class QmlBase : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -44,7 +29,6 @@ public:
|
||||
#ifdef ENABLE_INTERNAL_QML_RUNTIME
|
||||
m_argParser.addOption({"qml-runtime", "Run QML Runtime"});
|
||||
#endif
|
||||
m_argParser.addOption({"appinfo", "Print build information"});
|
||||
m_argParser.addOption({"test", "Run test mode"});
|
||||
}
|
||||
|
||||
@@ -92,7 +76,6 @@ private:
|
||||
void initParser()
|
||||
{
|
||||
QCommandLineOption optHelp = m_argParser.addHelpOption();
|
||||
QCommandLineOption optVers = m_argParser.addVersionOption();
|
||||
|
||||
if (!m_argParser.parse(m_coreApp->arguments())) {
|
||||
std::cout << "Error: " << m_argParser.errorText().toStdString() << std::endl;
|
||||
@@ -103,12 +86,8 @@ private:
|
||||
std::cout << std::endl;
|
||||
|
||||
m_argParser.showHelp(1);
|
||||
} else if (m_argParser.isSet(optVers)) {
|
||||
m_argParser.showVersion();
|
||||
} else if (m_argParser.isSet(optHelp)) {
|
||||
m_argParser.showHelp(0);
|
||||
} else if (m_argParser.isSet("appinfo")) {
|
||||
QDSMeta::AppInfo::printAppInfo();
|
||||
} else if (m_argParser.isSet("test")) {
|
||||
exit(startTestMode());
|
||||
}
|
||||
|
@@ -10,7 +10,6 @@
|
||||
|
||||
#include <app/app_version.h>
|
||||
#include <qml2puppet/import3d/import3d.h>
|
||||
|
||||
#include <qt5nodeinstanceclientproxy.h>
|
||||
|
||||
#include <QFileInfo>
|
||||
|
@@ -13,6 +13,10 @@
|
||||
#include <QDirIterator>
|
||||
#include <QFontDatabase>
|
||||
#include <QIcon>
|
||||
#include <QLibraryInfo>
|
||||
#include <QStandardPaths>
|
||||
#include <QSurfaceFormat>
|
||||
#include <QTranslator>
|
||||
|
||||
#define FILE_OPEN_EVENT_WAIT_TIME 3000 // ms
|
||||
#define QSL QStringLiteral
|
||||
@@ -242,12 +246,12 @@ void QmlRuntime::initQmlRunner()
|
||||
if (translator.load(translationFile)) {
|
||||
m_coreApp->installTranslator(&translator);
|
||||
if (m_verboseMode)
|
||||
qInfo() << "qml: Loaded translation file %s\n",
|
||||
qPrintable(QDir::toNativeSeparators(translationFile));
|
||||
qInfo() << "qml: Loaded translation file "
|
||||
<< qPrintable(QDir::toNativeSeparators(translationFile));
|
||||
} else {
|
||||
if (!m_quietMode)
|
||||
qInfo() << "qml: Could not load the translation file %s\n",
|
||||
qPrintable(QDir::toNativeSeparators(translationFile));
|
||||
qInfo() << "qml: Could not load the translation file "
|
||||
<< qPrintable(QDir::toNativeSeparators(translationFile));
|
||||
}
|
||||
}
|
||||
#else
|
||||
@@ -278,7 +282,7 @@ void QmlRuntime::initQmlRunner()
|
||||
for (const QString &path : std::as_const(files)) {
|
||||
QUrl url = QUrl::fromUserInput(path, QDir::currentPath(), QUrl::AssumeLocalFile);
|
||||
if (m_verboseMode)
|
||||
qInfo() << "qml: loading %s\n", qPrintable(url.toString());
|
||||
qInfo() << "qml: loading " << qPrintable(url.toString());
|
||||
m_qmlEngine->load(url);
|
||||
}
|
||||
|
||||
@@ -318,8 +322,8 @@ void QmlRuntime::loadConf(const QString &override, bool quiet) // Terminates app
|
||||
else
|
||||
fi.setFile(override);
|
||||
if (!fi.exists()) {
|
||||
qCritical() << "qml: Couldn't find required configuration file: %s\n",
|
||||
qPrintable(QDir::toNativeSeparators(fi.absoluteFilePath()));
|
||||
qCritical() << "qml: Couldn't find required configuration file:"
|
||||
<< qPrintable(QDir::toNativeSeparators(fi.absoluteFilePath()));
|
||||
exit(1);
|
||||
}
|
||||
settingsUrl = QQmlImports::urlFromLocalFileOrQrcOrUrl(fi.absoluteFilePath());
|
||||
@@ -327,13 +331,14 @@ void QmlRuntime::loadConf(const QString &override, bool quiet) // Terminates app
|
||||
}
|
||||
|
||||
if (!quiet) {
|
||||
qInfo() << "qml: %s\n", QLibraryInfo::build();
|
||||
qInfo() << "qml:" << QLibraryInfo::build();
|
||||
if (builtIn) {
|
||||
qInfo() << "qml: Using built-in configuration: %s\n",
|
||||
qPrintable(override.isEmpty() ? defaultFileName : override);
|
||||
qInfo() << "qml: Using built-in configuration:"
|
||||
<< qPrintable(override.isEmpty() ? defaultFileName : override);
|
||||
} else {
|
||||
qInfo() << "qml: Using configuration: %s\n",
|
||||
qPrintable(settingsUrl.isLocalFile()
|
||||
qInfo() << "qml: Using configuration:"
|
||||
<< qPrintable(
|
||||
settingsUrl.isLocalFile()
|
||||
? QDir::toNativeSeparators(settingsUrl.toLocalFile())
|
||||
: settingsUrl.toString());
|
||||
}
|
||||
@@ -345,18 +350,19 @@ void QmlRuntime::loadConf(const QString &override, bool quiet) // Terminates app
|
||||
m_conf.reset(qobject_cast<Config *>(c2.create()));
|
||||
|
||||
if (!m_conf) {
|
||||
qCritical() << "qml: Error loading configuration file: %s\n", qPrintable(c2.errorString());
|
||||
qCritical() << "qml: Error loading configuration file:" << qPrintable(c2.errorString());
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void QmlRuntime::listConfFiles()
|
||||
{
|
||||
qDebug() << "qml: Built-in configurations:";
|
||||
const QDir confResourceDir(m_confResourcePath);
|
||||
qInfo() << "%s\n", qPrintable(QCoreApplication::translate("main", "Built-in configurations:"));
|
||||
qInfo() << qPrintable(QCoreApplication::translate("main", "Built-in configurations:"));
|
||||
for (const QFileInfo &fi : confResourceDir.entryInfoList(QDir::Files))
|
||||
qInfo() << " %s\n", qPrintable(fi.baseName());
|
||||
qInfo() << "%s\n", qPrintable(QCoreApplication::translate("main", "Other configurations:"));
|
||||
qInfo() << qPrintable(fi.baseName());
|
||||
qInfo() << qPrintable(QCoreApplication::translate("main", "Other configurations:"));
|
||||
bool foundOther = false;
|
||||
const QStringList otherLocations = QStandardPaths::standardLocations(
|
||||
QStandardPaths::AppConfigLocation);
|
||||
@@ -365,16 +371,16 @@ void QmlRuntime::listConfFiles()
|
||||
for (const QFileInfo &fi : confDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) {
|
||||
foundOther = true;
|
||||
if (m_verboseMode)
|
||||
qInfo() << " %s\n", qPrintable(fi.absoluteFilePath());
|
||||
qInfo() << qPrintable(fi.absoluteFilePath());
|
||||
else
|
||||
qInfo() << " %s\n", qPrintable(fi.baseName());
|
||||
qInfo() << qPrintable(fi.baseName());
|
||||
}
|
||||
}
|
||||
if (!foundOther)
|
||||
qInfo() << " %s\n", qPrintable(QCoreApplication::translate("main", "none"));
|
||||
qInfo() << qPrintable(QCoreApplication::translate("main", "none"));
|
||||
if (m_verboseMode) {
|
||||
qInfo() << "%s\n", qPrintable(QCoreApplication::translate("main", "Checked in:"));
|
||||
qInfo() << qPrintable(QCoreApplication::translate("main", "Checked in:"));
|
||||
for (const auto &confDirPath : otherLocations)
|
||||
qInfo() << " %s\n", qPrintable(confDirPath);
|
||||
qInfo() << qPrintable(confDirPath);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user