forked from qt-creator/qt-creator
DebuggingHelpers: Put long argument list into one struct
This commit is contained in:
@@ -223,58 +223,58 @@ static bool runBuildProcess(QProcess &proc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool BuildableHelperLibrary::buildHelper(const QString &helperName, const QString &proFilename,
|
bool BuildableHelperLibrary::buildHelper(const BuildHelperArguments &arguments,
|
||||||
const QString &directory, const QString &makeCommand,
|
QString *log, QString *errorMessage)
|
||||||
const QString &qmakeCommand, const QString &mkspec,
|
|
||||||
const Utils::Environment &env, const QString &targetMode,
|
|
||||||
const QStringList &qmakeArguments, QString *output,
|
|
||||||
QString *errorMessage)
|
|
||||||
{
|
{
|
||||||
const QChar newline = QLatin1Char('\n');
|
const QChar newline = QLatin1Char('\n');
|
||||||
// Setup process
|
// Setup process
|
||||||
QProcess proc;
|
QProcess proc;
|
||||||
proc.setEnvironment(env.toStringList());
|
proc.setEnvironment(arguments.environment.toStringList());
|
||||||
proc.setWorkingDirectory(directory);
|
proc.setWorkingDirectory(arguments.directory);
|
||||||
proc.setProcessChannelMode(QProcess::MergedChannels);
|
proc.setProcessChannelMode(QProcess::MergedChannels);
|
||||||
|
|
||||||
output->append(QCoreApplication::translate("ProjectExplorer::BuildableHelperLibrary",
|
log->append(QCoreApplication::translate("ProjectExplorer::BuildableHelperLibrary",
|
||||||
"Building helper '%1' in %2\n").arg(helperName, directory));
|
"Building helper '%1' in %2\n").arg(arguments.helperName,
|
||||||
output->append(newline);
|
arguments.directory));
|
||||||
|
log->append(newline);
|
||||||
|
|
||||||
const QString makeFullPath = env.searchInPath(makeCommand);
|
const QString makeFullPath = arguments.environment.searchInPath(arguments.makeCommand);
|
||||||
if (QFileInfo(directory + QLatin1String("/Makefile")).exists()) {
|
if (QFileInfo(arguments.directory + QLatin1String("/Makefile")).exists()) {
|
||||||
if (makeFullPath.isEmpty()) {
|
if (makeFullPath.isEmpty()) {
|
||||||
*errorMessage = QCoreApplication::translate("ProjectExplorer::DebuggingHelperLibrary",
|
*errorMessage = QCoreApplication::translate("ProjectExplorer::DebuggingHelperLibrary",
|
||||||
"%1 not found in PATH\n").arg(makeCommand);
|
"%1 not found in PATH\n").arg(arguments.makeCommand);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const QString cleanTarget = QLatin1String("distclean");
|
const QString cleanTarget = QLatin1String("distclean");
|
||||||
output->append(QCoreApplication::translate("ProjectExplorer::BuildableHelperLibrary",
|
log->append(QCoreApplication::translate("ProjectExplorer::BuildableHelperLibrary",
|
||||||
"Running %1 %2...\n").arg(makeFullPath, cleanTarget));
|
"Running %1 %2...\n").arg(makeFullPath, cleanTarget));
|
||||||
if (!runBuildProcess(proc, makeFullPath, QStringList(cleanTarget), 30000, true, output, errorMessage))
|
if (!runBuildProcess(proc, makeFullPath, QStringList(cleanTarget), 30000, true, log, errorMessage))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
QStringList qmakeArgs;
|
QStringList qmakeArgs;
|
||||||
if (!targetMode.isEmpty())
|
if (!arguments.targetMode.isEmpty())
|
||||||
qmakeArgs << targetMode;
|
qmakeArgs << arguments.targetMode;
|
||||||
if (!mkspec.isEmpty())
|
if (!arguments.mkspec.isEmpty())
|
||||||
qmakeArgs << QLatin1String("-spec") << mkspec;
|
qmakeArgs << QLatin1String("-spec") << arguments.mkspec;
|
||||||
qmakeArgs << proFilename;
|
qmakeArgs << arguments.proFilename;
|
||||||
qmakeArgs << qmakeArguments;
|
qmakeArgs << arguments.qmakeArguments;
|
||||||
|
|
||||||
output->append(newline);
|
log->append(newline);
|
||||||
output->append(QCoreApplication::translate("ProjectExplorer::BuildableHelperLibrary", "Running %1 %2 ...\n").arg(qmakeCommand,
|
log->append(QCoreApplication::translate("ProjectExplorer::BuildableHelperLibrary",
|
||||||
qmakeArgs.join(" ")));
|
"Running %1 %2 ...\n").arg(arguments.qmakeCommand,
|
||||||
|
arguments.qmakeArguments.join(" ")));
|
||||||
|
|
||||||
if (!runBuildProcess(proc, qmakeCommand, qmakeArgs, 30000, false, output, errorMessage))
|
if (!runBuildProcess(proc, arguments.qmakeCommand, arguments.qmakeArguments, 30000, false, log, errorMessage))
|
||||||
return false;
|
return false;
|
||||||
output->append(newline);
|
log->append(newline);
|
||||||
if (makeFullPath.isEmpty()) {
|
if (makeFullPath.isEmpty()) {
|
||||||
*errorMessage = QCoreApplication::translate("ProjectExplorer::BuildableHelperLibrary", "%1 not found in PATH\n").arg(makeCommand);
|
*errorMessage = QCoreApplication::translate("ProjectExplorer::BuildableHelperLibrary",
|
||||||
|
"%1 not found in PATH\n").arg(arguments.makeCommand);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
output->append(QCoreApplication::translate("ProjectExplorer::BuildableHelperLibrary", "Running %1 ...\n").arg(makeFullPath));
|
log->append(QCoreApplication::translate("ProjectExplorer::BuildableHelperLibrary",
|
||||||
if (!runBuildProcess(proc, makeFullPath, QStringList(), 120000, false, output, errorMessage))
|
"Running %1 ...\n").arg(makeFullPath));
|
||||||
|
if (!runBuildProcess(proc, makeFullPath, QStringList(), 120000, false, log, errorMessage))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
#define BUILDABLEHELPERLIBRARY_H
|
#define BUILDABLEHELPERLIBRARY_H
|
||||||
|
|
||||||
#include "utils_global.h"
|
#include "utils_global.h"
|
||||||
|
#include <utils/environment.h>
|
||||||
|
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
|
|
||||||
@@ -67,12 +68,22 @@ public:
|
|||||||
static bool copyFiles(const QString &sourcePath, const QStringList &files,
|
static bool copyFiles(const QString &sourcePath, const QStringList &files,
|
||||||
const QString &targetDirectory, QString *errorMessage);
|
const QString &targetDirectory, QString *errorMessage);
|
||||||
|
|
||||||
static bool buildHelper(const QString &helperName, const QString &proFilename,
|
struct BuildHelperArguments {
|
||||||
const QString &directory, const QString &makeCommand,
|
QString helperName;
|
||||||
const QString &qmakeCommand, const QString &mkspec,
|
QString directory;
|
||||||
const Utils::Environment &env, const QString &targetMode,
|
Utils::Environment environment;
|
||||||
const QStringList &qmakeArguments, QString *output,
|
|
||||||
QString *errorMessage);
|
QString qmakeCommand;
|
||||||
|
QString targetMode;
|
||||||
|
QString mkspec;
|
||||||
|
QString proFilename;
|
||||||
|
QStringList qmakeArguments;
|
||||||
|
|
||||||
|
QString makeCommand;
|
||||||
|
};
|
||||||
|
|
||||||
|
static bool buildHelper(const BuildHelperArguments &arguments,
|
||||||
|
QString *log, QString *errorMessage);
|
||||||
|
|
||||||
static bool getHelperFileInfoFor(const QStringList &validBinaryFilenames,
|
static bool getHelperFileInfoFor(const QStringList &validBinaryFilenames,
|
||||||
const QString &directory, QFileInfo* info);
|
const QString &directory, QFileInfo* info);
|
||||||
|
|||||||
@@ -125,13 +125,10 @@ QString DebuggingHelperLibrary::copy(const QString &qtInstallData,
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DebuggingHelperLibrary::build(const QString &directory, const QString &makeCommand,
|
bool DebuggingHelperLibrary::build(BuildHelperArguments arguments, QString *log, QString *errorMessage)
|
||||||
const QString &qmakeCommand, const QString &mkspec,
|
|
||||||
const Utils::Environment &env, const QString &targetMode,
|
|
||||||
const QStringList &qmakeArguments, QString *output,
|
|
||||||
QString *errorMessage)
|
|
||||||
{
|
{
|
||||||
return buildHelper(QCoreApplication::translate("ProjectExplorer::DebuggingHelperLibrary",
|
arguments.proFilename = QLatin1String("gdbmacros.pro");
|
||||||
"GDB helper"), QLatin1String("gdbmacros.pro"), directory,
|
arguments.helperName = QCoreApplication::translate("ProjectExplorer::DebuggingHelperLibrary",
|
||||||
makeCommand, qmakeCommand, mkspec, env, targetMode, qmakeArguments, output, errorMessage);
|
"GDB helper");
|
||||||
|
return buildHelper(arguments, log, errorMessage);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,10 +50,7 @@ public:
|
|||||||
static QStringList locationsByInstallData(const QString &qtInstallData);
|
static QStringList locationsByInstallData(const QString &qtInstallData);
|
||||||
|
|
||||||
// Build the helpers and return the output log/errormessage.
|
// Build the helpers and return the output log/errormessage.
|
||||||
static bool build(const QString &directory, const QString &makeCommand,
|
static bool build(BuildHelperArguments arguments, QString *log, QString *errorMessage);
|
||||||
const QString &qmakeCommand, const QString &mkspec,
|
|
||||||
const Utils::Environment &env, const QString &targetMode,
|
|
||||||
const QStringList &qmakeArguments, QString *output, QString *errorMessage);
|
|
||||||
|
|
||||||
// Copy the source files to a target location and return the chosen target location.
|
// Copy the source files to a target location and return the chosen target location.
|
||||||
static QString copy(const QString &qtInstallData, QString *errorMessage);
|
static QString copy(const QString &qtInstallData, QString *errorMessage);
|
||||||
|
|||||||
@@ -143,24 +143,28 @@ void DebuggingHelperBuildTask::run(QFutureInterface<void> &future)
|
|||||||
|
|
||||||
bool DebuggingHelperBuildTask::buildDebuggingHelper(QFutureInterface<void> &future, QString *output)
|
bool DebuggingHelperBuildTask::buildDebuggingHelper(QFutureInterface<void> &future, QString *output)
|
||||||
{
|
{
|
||||||
|
Utils::BuildableHelperLibrary::BuildHelperArguments arguments;
|
||||||
|
arguments.makeCommand = m_makeCommand;
|
||||||
|
arguments.qmakeCommand = m_qmakeCommand;
|
||||||
|
arguments.targetMode = m_target;
|
||||||
|
arguments.mkspec = m_mkspec;
|
||||||
|
arguments.environment = m_environment;
|
||||||
|
|
||||||
if (m_tools & GdbDebugging) {
|
if (m_tools & GdbDebugging) {
|
||||||
const QString gdbHelperDirectory = DebuggingHelperLibrary::copy(m_qtInstallData,
|
arguments.directory = DebuggingHelperLibrary::copy(m_qtInstallData, &m_errorMessage);
|
||||||
&m_errorMessage);
|
if (arguments.directory.isEmpty())
|
||||||
if (gdbHelperDirectory.isEmpty())
|
|
||||||
return false;
|
return false;
|
||||||
if (!DebuggingHelperLibrary::build(gdbHelperDirectory, m_makeCommand,
|
|
||||||
m_qmakeCommand, m_mkspec, m_environment,
|
if (!DebuggingHelperLibrary::build(arguments, output, &m_errorMessage))
|
||||||
m_target, QStringList(), output, &m_errorMessage))
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
future.setProgressValue(2);
|
future.setProgressValue(2);
|
||||||
|
|
||||||
if (m_tools & QmlDump) {
|
if (m_tools & QmlDump) {
|
||||||
const QString qmlDumpToolDirectory = QmlDumpTool::copy(m_qtInstallData, &m_errorMessage);
|
arguments.directory = QmlDumpTool::copy(m_qtInstallData, &m_errorMessage);
|
||||||
if (qmlDumpToolDirectory.isEmpty())
|
if (arguments.directory.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
if (!QmlDumpTool::build(qmlDumpToolDirectory, m_makeCommand, m_qmakeCommand, m_mkspec,
|
if (!QmlDumpTool::build(arguments, output, &m_errorMessage))
|
||||||
m_environment, m_target, QStringList(), output, &m_errorMessage))
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
future.setProgressValue(3);
|
future.setProgressValue(3);
|
||||||
@@ -170,25 +174,21 @@ bool DebuggingHelperBuildTask::buildDebuggingHelper(QFutureInterface<void> &futu
|
|||||||
qmlDebuggingDirectory = QmlDebuggingLibrary::copy(m_qtInstallData, &m_errorMessage);
|
qmlDebuggingDirectory = QmlDebuggingLibrary::copy(m_qtInstallData, &m_errorMessage);
|
||||||
if (qmlDebuggingDirectory.isEmpty())
|
if (qmlDebuggingDirectory.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
if (!QmlDebuggingLibrary::build(qmlDebuggingDirectory, m_makeCommand,
|
arguments.directory = qmlDebuggingDirectory;
|
||||||
m_qmakeCommand, m_mkspec, m_environment,
|
if (!QmlDebuggingLibrary::build(arguments, output, &m_errorMessage))
|
||||||
m_target, QStringList(), output, &m_errorMessage))
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
future.setProgressValue(4);
|
future.setProgressValue(4);
|
||||||
|
|
||||||
if (m_tools & QmlObserver) {
|
if (m_tools & QmlObserver) {
|
||||||
const QString qmlObserverDirectory = QmlObserverTool::copy(m_qtInstallData,
|
arguments.directory = QmlObserverTool::copy(m_qtInstallData, &m_errorMessage);
|
||||||
&m_errorMessage);
|
if (arguments.directory.isEmpty())
|
||||||
if (qmlObserverDirectory.isEmpty())
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QStringList qmakeArgs;
|
arguments.qmakeArguments << QLatin1String("INCLUDEPATH+=\"\\\"") + qmlDebuggingDirectory + "include\\\"\"";
|
||||||
qmakeArgs << QLatin1String("INCLUDEPATH+=\"\\\"") + qmlDebuggingDirectory + "include\\\"\"";
|
arguments.qmakeArguments << QLatin1String("LIBS+=-L\"\\\"") + qmlDebuggingDirectory + QLatin1String("\\\"\"");
|
||||||
qmakeArgs << QLatin1String("LIBS+=-L\"\\\"") + qmlDebuggingDirectory + QLatin1String("\\\"\"");
|
|
||||||
|
|
||||||
if (!QmlObserverTool::build(qmlObserverDirectory, m_makeCommand, m_qmakeCommand, m_mkspec,
|
if (!QmlObserverTool::build(arguments, output, &m_errorMessage))
|
||||||
m_environment, m_target, qmakeArgs, output, &m_errorMessage))
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
future.setProgressValue(5);
|
future.setProgressValue(5);
|
||||||
|
|||||||
@@ -70,15 +70,11 @@ bool QmlDebuggingLibrary::canBuild(const QtVersion *qtVersion)
|
|||||||
return qtVersion->qtVersion() >= QtVersionNumber(4, 7, 1);
|
return qtVersion->qtVersion() >= QtVersionNumber(4, 7, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlDebuggingLibrary::build(const QString &directory, const QString &makeCommand,
|
bool QmlDebuggingLibrary::build(BuildHelperArguments arguments, QString *log, QString *errorMessage)
|
||||||
const QString &qmakeCommand, const QString &mkspec,
|
|
||||||
const Utils::Environment &env, const QString &targetMode,
|
|
||||||
const QStringList &qmakeArguments, QString *output, QString *errorMessage)
|
|
||||||
{
|
{
|
||||||
return buildHelper(QCoreApplication::translate("Qt4ProjectManager::QmlDebuggingLibrary", "QML Debugging"),
|
arguments.helperName = QCoreApplication::translate("Qt4ProjectManager::QmlDebuggingLibrary", "QML Debugging");
|
||||||
QLatin1String("qmljsdebugger.pro"),
|
arguments.proFilename = QLatin1String("qmljsdebugger.pro");
|
||||||
directory, makeCommand, qmakeCommand, mkspec, env, targetMode,
|
return buildHelper(arguments, log, errorMessage);
|
||||||
qmakeArguments, output, errorMessage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool mkpath(const QString &targetDirectory, QString *errorMessage)
|
static inline bool mkpath(const QString &targetDirectory, QString *errorMessage)
|
||||||
|
|||||||
@@ -56,10 +56,7 @@ public:
|
|||||||
static QString libraryByInstallData(const QString &qtInstallData, bool debugBuild);
|
static QString libraryByInstallData(const QString &qtInstallData, bool debugBuild);
|
||||||
|
|
||||||
static bool canBuild(const QtVersion *qtVersion);
|
static bool canBuild(const QtVersion *qtVersion);
|
||||||
static bool build(const QString &directory, const QString &makeCommand,
|
static bool build(BuildHelperArguments arguments, QString *log, QString *errorMessage);
|
||||||
const QString &qmakeCommand, const QString &mkspec,
|
|
||||||
const Utils::Environment &env, const QString &targetMode,
|
|
||||||
const QStringList &qmakeArguments, QString *output, QString *errorMessage);
|
|
||||||
static QString copy(const QString &qtInstallData, QString *errorMessage);
|
static QString copy(const QString &qtInstallData, QString *errorMessage);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -290,14 +290,11 @@ QStringList QmlDumpTool::locationsByInstallData(const QString &qtInstallData, bo
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlDumpTool::build(const QString &directory, const QString &makeCommand,
|
bool QmlDumpTool::build(BuildHelperArguments arguments, QString *log, QString *errorMessage)
|
||||||
const QString &qmakeCommand, const QString &mkspec,
|
|
||||||
const Utils::Environment &env, const QString &targetMode,
|
|
||||||
const QStringList &qmakeArguments, QString *output, QString *errorMessage)
|
|
||||||
{
|
{
|
||||||
return buildHelper(QCoreApplication::translate("Qt4ProjectManager::QmlDumpTool", "qmldump"), QLatin1String("qmldump.pro"),
|
arguments.helperName = QCoreApplication::translate("Qt4ProjectManager::QmlDumpTool", "qmldump");
|
||||||
directory, makeCommand, qmakeCommand, mkspec, env, targetMode,
|
arguments.proFilename = QLatin1String("qmldump.pro");
|
||||||
qmakeArguments, output, errorMessage);
|
return buildHelper(arguments, log, errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QmlDumpTool::copy(const QString &qtInstallData, QString *errorMessage)
|
QString QmlDumpTool::copy(const QString &qtInstallData, QString *errorMessage)
|
||||||
|
|||||||
@@ -58,10 +58,7 @@ public:
|
|||||||
static QStringList locationsByInstallData(const QString &qtInstallData, bool debugDump);
|
static QStringList locationsByInstallData(const QString &qtInstallData, bool debugDump);
|
||||||
|
|
||||||
// Build the helpers and return the output log/errormessage.
|
// Build the helpers and return the output log/errormessage.
|
||||||
static bool build(const QString &directory, const QString &makeCommand,
|
static bool build(BuildHelperArguments arguments, QString *log, QString *errorMessage);
|
||||||
const QString &qmakeCommand, const QString &mkspec,
|
|
||||||
const Utils::Environment &env, const QString &targetMode,
|
|
||||||
const QStringList &qmakeArguments, QString *output, QString *errorMessage);
|
|
||||||
|
|
||||||
// Copy the source files to a target location and return the chosen target location.
|
// Copy the source files to a target location and return the chosen target location.
|
||||||
static QString copy(const QString &qtInstallData, QString *errorMessage);
|
static QString copy(const QString &qtInstallData, QString *errorMessage);
|
||||||
|
|||||||
@@ -101,16 +101,12 @@ QStringList QmlObserverTool::locationsByInstallData(const QString &qtInstallData
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlObserverTool::build(const QString &directory, const QString &makeCommand,
|
bool QmlObserverTool::build(BuildHelperArguments arguments, QString *log, QString *errorMessage)
|
||||||
const QString &qmakeCommand, const QString &mkspec,
|
|
||||||
const Utils::Environment &env, const QString &targetMode,
|
|
||||||
const QStringList &qmakeArguments, QString *output,
|
|
||||||
QString *errorMessage)
|
|
||||||
{
|
{
|
||||||
return buildHelper(QCoreApplication::translate("Qt4ProjectManager::QmlObserverTool", "QMLObserver"),
|
arguments.helperName = QCoreApplication::translate("Qt4ProjectManager::QmlObserverTool", "QMLObserver");
|
||||||
QLatin1String("qmlobserver.pro"),
|
arguments.proFilename = QLatin1String("qmlobserver.pro");
|
||||||
directory, makeCommand, qmakeCommand, mkspec, env, targetMode,
|
|
||||||
qmakeArguments, output, errorMessage);
|
return buildHelper(arguments, log, errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool mkpath(const QString &targetDirectory, QString *errorMessage)
|
static inline bool mkpath(const QString &targetDirectory, QString *errorMessage)
|
||||||
|
|||||||
@@ -59,10 +59,7 @@ public:
|
|||||||
static QStringList locationsByInstallData(const QString &qtInstallData);
|
static QStringList locationsByInstallData(const QString &qtInstallData);
|
||||||
|
|
||||||
// Build the helpers and return the output log/errormessage.
|
// Build the helpers and return the output log/errormessage.
|
||||||
static bool build(const QString &directory, const QString &makeCommand,
|
static bool build(BuildHelperArguments arguments, QString *out, QString *err);
|
||||||
const QString &qmakeCommand, const QString &mkspec,
|
|
||||||
const Utils::Environment &env, const QString &targetMode,
|
|
||||||
const QStringList &qmakeArguments, QString *output, QString *errorMessage);
|
|
||||||
|
|
||||||
// Copy the source files to a target location and return the chosen target location.
|
// Copy the source files to a target location and return the chosen target location.
|
||||||
static QString copy(const QString &qtInstallData, QString *errorMessage);
|
static QString copy(const QString &qtInstallData, QString *errorMessage);
|
||||||
|
|||||||
Reference in New Issue
Block a user