summaryrefslogtreecommitdiff
path: root/src/plugins/incredibuild/commandbuilder.cpp
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2020-08-06 18:11:52 +0200
committerhjk <hjk@qt.io>2020-08-07 13:02:51 +0000
commite04b9a5348ccfed2cd1279aedb373f5499fe00dc (patch)
tree46553d0ffc05220dfcd6e519759cc71ecfc79bd2 /src/plugins/incredibuild/commandbuilder.cpp
parentf00b088a1ddce99b76aac9670edb8d6405d2e455 (diff)
downloadqt-creator-e04b9a5348ccfed2cd1279aedb373f5499fe00dc.tar.gz
IncrediBuild: Rework CommandBuilder
Simplify interfaces. Also persist all command line settings, make overriding default arguments explicit. Change-Id: Ifb7e791dfc07ae9a88cfd769b9d21c5ee242e31d Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/incredibuild/commandbuilder.cpp')
-rw-r--r--src/plugins/incredibuild/commandbuilder.cpp115
1 files changed, 19 insertions, 96 deletions
diff --git a/src/plugins/incredibuild/commandbuilder.cpp b/src/plugins/incredibuild/commandbuilder.cpp
index 605d345a0e..b290afdea7 100644
--- a/src/plugins/incredibuild/commandbuilder.cpp
+++ b/src/plugins/incredibuild/commandbuilder.cpp
@@ -29,114 +29,37 @@ namespace IncrediBuild {
namespace Internal {
namespace Constants {
-const QLatin1String CUSTOMCOMMANDBUILDER_COMMAND("IncrediBuild.BuildConsole.CustomCommandBuilder.Command");
-const QLatin1String CUSTOMCOMMANDBUILDER_ARGS("IncrediBuild.BuildConsole.CustomCommandBuilder.Arguments");
-const QLatin1String CUSTOMCOMMANDBUILDER_ARGSSET("IncrediBuild.BuildConsole.CustomCommandBuilder.ArgumentsSet");
+const QLatin1String CUSTOMCOMMANDBUILDER_COMMAND("IncrediBuild.BuildConsole.%1.Command");
+const QLatin1String CUSTOMCOMMANDBUILDER_ARGS("IncrediBuild.BuildConsole.%1.Arguments");
+const QLatin1String CUSTOMCOMMANDBUILDER_ARGSSET("IncrediBuild.BuildConsole.%1.ArgumentsSet");
} // namespace Constants
-QString CommandBuilder::fullCommandFlag()
+void CommandBuilder::fromMap(const QVariantMap &map)
{
- QString argsLine;
- for (const QString &a : arguments())
- argsLine += "\"" + a + "\" ";
-
- if (!keepJobNum())
- argsLine = setMultiProcessArg(argsLine);
-
- QString fullCommand("\"%0\" %1");
- fullCommand = fullCommand.arg(command(), argsLine);
-
- return fullCommand;
+ m_command = map.value(QString(Constants::CUSTOMCOMMANDBUILDER_COMMAND).arg(id())).toString();
+ m_args = map.value(QString(Constants::CUSTOMCOMMANDBUILDER_ARGS).arg(id())).toString();
}
-void CommandBuilder::reset()
+void CommandBuilder::toMap(QVariantMap *map) const
{
- m_command.clear();
- m_args.clear();
- m_argsSet = false;
+ (*map)[QString(Constants::CUSTOMCOMMANDBUILDER_COMMAND).arg(id())] = QVariant(m_command);
+ (*map)[QString(Constants::CUSTOMCOMMANDBUILDER_ARGS).arg(id())] = QVariant(m_args);
}
-bool CommandBuilder::fromMap(const QVariantMap &map)
+void CommandBuilder::setCommand(const QString &command)
{
- m_command = map.value(Constants::CUSTOMCOMMANDBUILDER_COMMAND, QVariant(QString())).toString();
- m_argsSet = map.value(Constants::CUSTOMCOMMANDBUILDER_ARGSSET, QVariant(false)).toBool();
- if (m_argsSet)
- arguments(map.value(Constants::CUSTOMCOMMANDBUILDER_ARGS, QVariant(QString())).toString());
-
- // Not loading m_keepJobNum as it is managed by the build step.
- return true;
+ if (command == defaultCommand())
+ m_command.clear();
+ else
+ m_command = command;
}
-void CommandBuilder::toMap(QVariantMap *map) const
+void CommandBuilder::setArguments(const QString &arguments)
{
- (*map)[Constants::CUSTOMCOMMANDBUILDER_COMMAND] = QVariant(m_command);
- (*map)[Constants::CUSTOMCOMMANDBUILDER_ARGSSET] = QVariant(m_argsSet);
- if (m_argsSet)
- (*map)[Constants::CUSTOMCOMMANDBUILDER_ARGS] = QVariant(m_args);
-
- // Not saving m_keepJobNum as it is managed by the build step.
-}
-
-// Split args to quoted or spaced parts
-void CommandBuilder::arguments(const QString &argsLine)
-{
- QStringList args;
- QString currArg;
- bool inQuote = false;
- bool inArg = false;
- for (int i = 0; i < argsLine.length(); ++i) {
- QChar c = argsLine[i];
- if (c.isSpace()) {
- if (!inArg) // Spaces between arguments
- continue;
-
- if (!inQuote) { // Arg termination
- if (currArg.length() > 0) {
- args.append(currArg);
- currArg.clear();
- }
- inArg = false;
- continue;
- } else { // Space within argument
- currArg += c;
- continue;
- }
- }
-
- inArg = true;
- if (c == '"') {
- if ((i < (argsLine.length() - 1))
- && (argsLine[i + 1] == '"')) { // Convert '""' to double-quote within arg
- currArg += '"';
- ++i;
- continue;
- }
-
- if (inQuote) { // Arg termination
- if (currArg.length() > 0) {
- args.append(currArg);
- currArg.clear();
- }
- inArg = false;
- inQuote = false;
- continue;
- }
-
- // Arg start
- inArg = true;
- inQuote = true;
- continue;
- }
-
- // Simple character
- inArg = true;
- currArg += c;
- }
-
- if (currArg.length() > 0)
- args.append(currArg);
-
- arguments(args);
+ if (arguments == defaultArguments())
+ m_args.clear();
+ else
+ m_args = arguments;
}
} // namespace Internal