Commit 001793fe authored by Kai Koehne's avatar Kai Koehne
Browse files

DebuggingHelpers: Put long argument list into one struct

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