Commit 6b25d6fb authored by Kai Koehne's avatar Kai Koehne

DebuggingHelper: Always save output to 'General Messages' pane

Change-Id: I558c81f5a74d717dabb56d36fea3ed5f5b2acc18
parent 91259db4
......@@ -35,6 +35,8 @@
#include "qmlobservertool.h"
#include "qmldebugginglibrary.h"
#include <qt4projectmanager/baseqtversion.h>
#include <coreplugin/messagemanager.h>
#include <qt4projectmanager/qt4projectmanagerconstants.h>
#include <qt4projectmanager/qtversionmanager.h>
#include <qt4projectmanager/qt4projectmanagerconstants.h>
#include <projectexplorer/toolchainmanager.h>
......@@ -49,13 +51,21 @@ using namespace Qt4ProjectManager::Internal;
using ProjectExplorer::DebuggingHelperLibrary;
DebuggingHelperBuildTask::DebuggingHelperBuildTask(const BaseQtVersion *version, Tools tools) :
m_tools(tools & availableTools(version))
m_tools(tools & availableTools(version)),
m_invalidQt(false),
m_showErrors(true)
{
if (!version || !version->isValid())
return;
// allow type to be used in queued connections.
qRegisterMetaType<DebuggingHelperBuildTask::Tools>("DebuggingHelperBuildTask::Tools");
// Print result in application ouptut
Core::MessageManager *messageManager = Core::MessageManager::instance();
connect(this, SIGNAL(logOutput(QString,bool)),
messageManager, SLOT(printToOutputPane(QString,bool)),
Qt::QueuedConnection);
//
// Extract all information we need from version, such that we don't depend on the existence
// of the version pointer while compiling
......@@ -63,11 +73,13 @@ DebuggingHelperBuildTask::DebuggingHelperBuildTask(const BaseQtVersion *version,
m_qtId = version->uniqueId();
m_qtInstallData = version->versionInfo().value("QT_INSTALL_DATA");
if (m_qtInstallData.isEmpty()) {
m_errorMessage
const QString error
= QCoreApplication::translate(
"QtVersion",
"Cannot determine the installation path for Qt version '%1'."
).arg(version->displayName());
log(QString(), error);
m_invalidQt = true;
return;
}
......@@ -77,10 +89,12 @@ DebuggingHelperBuildTask::DebuggingHelperBuildTask(const BaseQtVersion *version,
// TODO: the debugging helper doesn't comply to actual tool chain yet
QList<ProjectExplorer::ToolChain *> tcList = ProjectExplorer::ToolChainManager::instance()->findToolChains(version->qtAbis().at(0));
if (tcList.isEmpty()) {
m_errorMessage =
QCoreApplication::translate(
const QString error
= QCoreApplication::translate(
"QtVersion",
"The Qt Version has no tool chain.");
log(QString(), error);
m_invalidQt = true;
return;
}
ProjectExplorer::ToolChain *tc = tcList.at(0);
......@@ -92,11 +106,6 @@ DebuggingHelperBuildTask::DebuggingHelperBuildTask(const BaseQtVersion *version,
m_qmakeCommand = version->qmakeCommand();
m_makeCommand = tc->makeCommand();
m_mkspec = version->mkspec();
// Make sure QtVersion cache is invalidated
connect(this, SIGNAL(finished(int,QString,DebuggingHelperBuildTask::Tools)),
QtVersionManager::instance(), SLOT(updateQtVersion(int)),
Qt::QueuedConnection);
}
DebuggingHelperBuildTask::~DebuggingHelperBuildTask()
......@@ -125,28 +134,39 @@ DebuggingHelperBuildTask::Tools DebuggingHelperBuildTask::availableTools(const B
return tools;
}
void DebuggingHelperBuildTask::showOutputOnError(bool show)
{
m_showErrors = show;
}
void DebuggingHelperBuildTask::run(QFutureInterface<void> &future)
{
future.setProgressRange(0, 5);
future.setProgressValue(1);
QString output;
bool success = false;
if (m_errorMessage.isEmpty()) // might be already set in constructor
success = buildDebuggingHelper(future, &output);
if (!m_invalidQt)
success = buildDebuggingHelper(future);
if (success) {
emit finished(m_qtId, output, m_tools);
if (!success) {
const QString error
= QCoreApplication::translate(
"QtVersion",
"Build failed!");
log(QString(), error);
} else {
qWarning("%s", qPrintable(m_errorMessage));
emit finished(m_qtId, m_errorMessage, m_tools);
const QString result
= QCoreApplication::translate(
"QtVersion",
"Build succeeded!");
log(result, QString());
}
emit finished(m_qtId, m_log, m_tools);
deleteLater();
}
bool DebuggingHelperBuildTask::buildDebuggingHelper(QFutureInterface<void> &future, QString *output)
bool DebuggingHelperBuildTask::buildDebuggingHelper(QFutureInterface<void> &future)
{
Utils::BuildableHelperLibrary::BuildHelperArguments arguments;
arguments.makeCommand = m_makeCommand;
......@@ -156,48 +176,87 @@ bool DebuggingHelperBuildTask::buildDebuggingHelper(QFutureInterface<void> &futu
arguments.environment = m_environment;
if (m_tools & GdbDebugging) {
arguments.directory = DebuggingHelperLibrary::copy(m_qtInstallData, &m_errorMessage);
if (arguments.directory.isEmpty())
return false;
QString output, error;
bool success = true;
if (!DebuggingHelperLibrary::build(arguments, output, &m_errorMessage))
arguments.directory = DebuggingHelperLibrary::copy(m_qtInstallData, &error);
if (arguments.directory.isEmpty()
|| !DebuggingHelperLibrary::build(arguments, &output, &error))
success = false;
log(output, error);
if (!success)
return false;
}
future.setProgressValue(2);
if (m_tools & QmlDump) {
arguments.directory = QmlDumpTool::copy(m_qtInstallData, &m_errorMessage);
if (arguments.directory.isEmpty())
return false;
if (!QmlDumpTool::build(arguments, output, &m_errorMessage))
QString output, error;
bool success = true;
arguments.directory = QmlDumpTool::copy(m_qtInstallData, &error);
if (arguments.directory.isEmpty()
|| !QmlDumpTool::build(arguments, &output, &error))
success = false;
log(output, error);
if (!success)
return false;
}
future.setProgressValue(3);
QString qmlDebuggingDirectory;
if (m_tools & QmlDebugging) {
qmlDebuggingDirectory = QmlDebuggingLibrary::copy(m_qtInstallData, &m_errorMessage);
if (qmlDebuggingDirectory.isEmpty())
return false;
QString output, error;
qmlDebuggingDirectory = QmlDebuggingLibrary::copy(m_qtInstallData, &error);
bool success = true;
arguments.directory = qmlDebuggingDirectory;
arguments.makeArguments += QLatin1String("all"); // build debug and release
if (!QmlDebuggingLibrary::build(arguments, output, &m_errorMessage))
if (arguments.directory.isEmpty()
|| !QmlDebuggingLibrary::build(arguments, &output, &error)) {
success = false;
}
log(output, error);
if (!success) {
return false;
}
arguments.makeArguments.clear();
}
future.setProgressValue(4);
if (m_tools & QmlObserver) {
arguments.directory = QmlObserverTool::copy(m_qtInstallData, &m_errorMessage);
if (arguments.directory.isEmpty())
return false;
QString output, error;
bool success = true;
arguments.directory = QmlObserverTool::copy(m_qtInstallData, &error);
arguments.qmakeArguments << QLatin1String("INCLUDEPATH+=\"\\\"") + qmlDebuggingDirectory + "include\\\"\"";
arguments.qmakeArguments << QLatin1String("LIBS+=-L\"\\\"") + qmlDebuggingDirectory + QLatin1String("\\\"\"");
if (!QmlObserverTool::build(arguments, output, &m_errorMessage))
if (arguments.directory.isEmpty()
|| !QmlObserverTool::build(arguments, &output, &error)) {
success = false;
}
log(output, error);
if (!success) {
return false;
}
}
future.setProgressValue(5);
return true;
}
void DebuggingHelperBuildTask::log(const QString &output, const QString &error)
{
if (output.isEmpty() && error.isEmpty())
return;
QString logEntry;
if (!output.isEmpty())
logEntry.append(output);
if (!error.isEmpty())
logEntry.append(error);
m_log.append(logEntry);
emit logOutput(logEntry, m_showErrors && !error.isEmpty());
}
......@@ -59,15 +59,19 @@ public:
explicit DebuggingHelperBuildTask(const BaseQtVersion *version, Tools tools = AllTools);
virtual ~DebuggingHelperBuildTask();
void showOutputOnError(bool show);
void run(QFutureInterface<void> &future);
static Tools availableTools(const BaseQtVersion *version);
signals:
// used internally
void logOutput(const QString &output, bool bringToForeground);
void finished(int qtVersionId, const QString &output, DebuggingHelperBuildTask::Tools tools);
private:
bool buildDebuggingHelper(QFutureInterface<void> &future, QString *output);
bool buildDebuggingHelper(QFutureInterface<void> &future);
void log(const QString &output, const QString &error);
const Tools m_tools;
......@@ -78,7 +82,9 @@ private:
QString m_makeCommand;
QString m_mkspec;
Utils::Environment m_environment;
QString m_errorMessage;
QString m_log;
bool m_invalidQt;
bool m_showErrors;
};
} //namespace Internal
......
......@@ -580,6 +580,9 @@ void QMakeStepConfigWidget::buildQmlDebuggingHelper()
this, SLOT(debuggingHelperBuildFinished(int,QString)),
Qt::QueuedConnection);
// pop up Application Output on error
buildTask->showOutputOnError(true);
QFuture<void> task = QtConcurrent::run(&DebuggingHelperBuildTask::run, buildTask);
const QString taskName = tr("Building helpers");
Core::ICore::instance()->progressManager()->addTask(task, taskName,
......@@ -598,12 +601,6 @@ void QMakeStepConfigWidget::debuggingHelperBuildFinished(int qtVersionId, const
updateEffectiveQMakeCall();
updateQmlDebuggingOption();
}
Core::MessageManager *messageManager = Core::ICore::instance()->messageManager();
messageManager->printToOutputPane(output);
if (!version->hasQmlDebuggingLibrary())
messageManager->showOutputPane();
}
void QMakeStepConfigWidget::updateSummaryLabel()
......
......@@ -72,7 +72,8 @@ public:
, m_failed(false)
{
qmlDumpBuilds()->insert(version->uniqueId(), this);
// Don't open General Messages pane with errors
m_buildTask->showOutputOnError(false);
connect(m_buildTask, SIGNAL(finished(int,QString,DebuggingHelperBuildTask::Tools)),
this, SLOT(finish(int,QString,DebuggingHelperBuildTask::Tools)),
Qt::QueuedConnection);
......
......@@ -326,6 +326,8 @@ void QtOptionsPageWidget::buildDebuggingHelper(DebuggingHelperBuildTask::Tools t
// Run a debugging helper build task in the background.
DebuggingHelperBuildTask *buildTask = new DebuggingHelperBuildTask(version, tools);
// Don't open General Messages pane with errors
buildTask->showOutputOnError(false);
connect(buildTask, SIGNAL(finished(int,QString,DebuggingHelperBuildTask::Tools)),
this, SLOT(debuggingHelperBuildFinished(int,QString,DebuggingHelperBuildTask::Tools)),
Qt::QueuedConnection);
......
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