aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/corelib
diff options
context:
space:
mode:
authorJake Petroules <jake.petroules@petroules.com>2015-02-19 20:51:15 -0800
committerJake Petroules <jake.petroules@petroules.com>2015-02-25 15:40:32 +0000
commit64cbb7c8cd0c5b4dacad94a88464f8c3b2e59fc1 (patch)
tree905c7d40d52d80424b9bf32332241d41f04f492e /src/lib/corelib
parent6c9de0488a8fcee5e88c00d1df07f9c11e8bacfc (diff)
Replace --show-command-lines with --command-echo-mode.
This allows users to hide command output entirely without changing the logging level. It is also used by the generator command to hide the dry run command "executions" it performs when creating the build graph for project generation. Change-Id: I27a64c8138521001f5b62473b4a3b4ff46d8ba25 Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
Diffstat (limited to 'src/lib/corelib')
-rw-r--r--src/lib/corelib/buildgraph/abstractcommandexecutor.cpp3
-rw-r--r--src/lib/corelib/buildgraph/abstractcommandexecutor.h3
-rw-r--r--src/lib/corelib/buildgraph/executor.cpp2
-rw-r--r--src/lib/corelib/buildgraph/executorjob.cpp5
-rw-r--r--src/lib/corelib/buildgraph/executorjob.h3
-rw-r--r--src/lib/corelib/buildgraph/processcommandexecutor.cpp4
-rw-r--r--src/lib/corelib/buildgraph/processcommandexecutor.h2
-rw-r--r--src/lib/corelib/corelib.qbs2
-rw-r--r--src/lib/corelib/tools/buildoptions.cpp19
-rw-r--r--src/lib/corelib/tools/buildoptions.h6
-rw-r--r--src/lib/corelib/tools/commandechomode.cpp84
-rw-r--r--src/lib/corelib/tools/commandechomode.h55
-rw-r--r--src/lib/corelib/tools/preferences.cpp8
-rw-r--r--src/lib/corelib/tools/preferences.h3
-rw-r--r--src/lib/corelib/tools/tools.pri2
15 files changed, 180 insertions, 21 deletions
diff --git a/src/lib/corelib/buildgraph/abstractcommandexecutor.cpp b/src/lib/corelib/buildgraph/abstractcommandexecutor.cpp
index 2f38b6c38..b9215a996 100644
--- a/src/lib/corelib/buildgraph/abstractcommandexecutor.cpp
+++ b/src/lib/corelib/buildgraph/abstractcommandexecutor.cpp
@@ -40,6 +40,7 @@ namespace Internal {
AbstractCommandExecutor::AbstractCommandExecutor(const Logger &logger, QObject *parent)
: QObject(parent)
+ , m_echoMode(defaultCommandEchoMode())
, m_command(0)
, m_transformer(0)
, m_mainThreadScriptEngine(0)
@@ -58,7 +59,7 @@ void AbstractCommandExecutor::start(Transformer *transformer, const AbstractComm
void AbstractCommandExecutor::doReportCommandDescription()
{
- if (m_command->isSilent())
+ if (m_command->isSilent() || m_echoMode == CommandEchoModeSilent)
return;
if (m_command->description().isEmpty()) {
diff --git a/src/lib/corelib/buildgraph/abstractcommandexecutor.h b/src/lib/corelib/buildgraph/abstractcommandexecutor.h
index 1e50761a7..b57cc9885 100644
--- a/src/lib/corelib/buildgraph/abstractcommandexecutor.h
+++ b/src/lib/corelib/buildgraph/abstractcommandexecutor.h
@@ -32,6 +32,7 @@
#define QBS_ABSTRACTCOMMANDEXECUTOR_H
#include <logging/logger.h>
+#include <tools/commandechomode.h>
#include <tools/error.h>
#include <QObject>
@@ -52,6 +53,7 @@ public:
void setMainThreadScriptEngine(ScriptEngine *engine) { m_mainThreadScriptEngine = engine; }
void setDryRunEnabled(bool enabled) { m_dryRun = enabled; }
+ void setEchoMode(CommandEchoMode echoMode) { m_echoMode = echoMode; }
virtual void cancel() = 0;
@@ -69,6 +71,7 @@ protected:
ScriptEngine *scriptEngine() const { return m_mainThreadScriptEngine; }
bool dryRun() const { return m_dryRun; }
Internal::Logger logger() const { return m_logger; }
+ CommandEchoMode m_echoMode;
private:
virtual void doStart() = 0;
diff --git a/src/lib/corelib/buildgraph/executor.cpp b/src/lib/corelib/buildgraph/executor.cpp
index a7603481f..6bade604a 100644
--- a/src/lib/corelib/buildgraph/executor.cpp
+++ b/src/lib/corelib/buildgraph/executor.cpp
@@ -670,7 +670,7 @@ void Executor::addExecutorJobs()
job->setMainThreadScriptEngine(m_evalContext->engine());
job->setObjectName(QString::fromLatin1("J%1").arg(i));
job->setDryRun(m_buildOptions.dryRun());
- job->setShowCommandLines(m_buildOptions.showCommandLines());
+ job->setEchoMode(m_buildOptions.echoMode());
m_availableJobs.append(job);
connect(job, SIGNAL(reportCommandDescription(QString,QString)),
this, SIGNAL(reportCommandDescription(QString,QString)), Qt::QueuedConnection);
diff --git a/src/lib/corelib/buildgraph/executorjob.cpp b/src/lib/corelib/buildgraph/executorjob.cpp
index 65d1d81f0..3add5d29f 100644
--- a/src/lib/corelib/buildgraph/executorjob.cpp
+++ b/src/lib/corelib/buildgraph/executorjob.cpp
@@ -78,9 +78,10 @@ void ExecutorJob::setDryRun(bool enabled)
m_jsCommandExecutor->setDryRunEnabled(enabled);
}
-void ExecutorJob::setShowCommandLines(bool enabled)
+void ExecutorJob::setEchoMode(CommandEchoMode echoMode)
{
- m_processCommandExecutor->setShowCommandLines(enabled);
+ m_processCommandExecutor->setEchoMode(echoMode);
+ m_jsCommandExecutor->setEchoMode(echoMode);
}
void ExecutorJob::run(Transformer *t)
diff --git a/src/lib/corelib/buildgraph/executorjob.h b/src/lib/corelib/buildgraph/executorjob.h
index 570579451..c33ebb455 100644
--- a/src/lib/corelib/buildgraph/executorjob.h
+++ b/src/lib/corelib/buildgraph/executorjob.h
@@ -32,6 +32,7 @@
#define QBS_EXECUTORJOB_H
#include <language/forward_decls.h>
+#include <tools/commandechomode.h>
#include <tools/error.h>
#include <QObject>
@@ -58,7 +59,7 @@ public:
void setMainThreadScriptEngine(ScriptEngine *engine);
void setDryRun(bool enabled);
- void setShowCommandLines(bool enabled);
+ void setEchoMode(CommandEchoMode echoMode);
void run(Transformer *t);
void cancel();
diff --git a/src/lib/corelib/buildgraph/processcommandexecutor.cpp b/src/lib/corelib/buildgraph/processcommandexecutor.cpp
index 6a295329f..e336da519 100644
--- a/src/lib/corelib/buildgraph/processcommandexecutor.cpp
+++ b/src/lib/corelib/buildgraph/processcommandexecutor.cpp
@@ -38,6 +38,7 @@
#include <language/scriptengine.h>
#include <logging/logger.h>
#include <logging/translator.h>
+#include <tools/commandechomode.h>
#include <tools/error.h>
#include <tools/executablefinder.h>
#include <tools/fileinfo.h>
@@ -58,7 +59,6 @@ namespace Internal {
ProcessCommandExecutor::ProcessCommandExecutor(const Logger &logger, QObject *parent)
: AbstractCommandExecutor(logger, parent)
- , m_showCommandLines(false)
{
connect(&m_process, SIGNAL(error(QProcess::ProcessError)), SLOT(onProcessError()));
connect(&m_process, SIGNAL(finished(int)), SLOT(onProcessFinished(int)));
@@ -272,7 +272,7 @@ void ProcessCommandExecutor::onProcessFinished(int exitCode)
void ProcessCommandExecutor::doReportCommandDescription()
{
- if (m_showCommandLines) {
+ if (m_echoMode == CommandEchoModeCommandLine) {
const ProcessCommand * const cmd = processCommand();
emit reportCommandDescription(QString(),
cmd->program() + QLatin1Char(' ')
diff --git a/src/lib/corelib/buildgraph/processcommandexecutor.h b/src/lib/corelib/buildgraph/processcommandexecutor.h
index fa6d34963..d93d585b3 100644
--- a/src/lib/corelib/buildgraph/processcommandexecutor.h
+++ b/src/lib/corelib/buildgraph/processcommandexecutor.h
@@ -49,7 +49,6 @@ class ProcessCommandExecutor : public AbstractCommandExecutor
public:
explicit ProcessCommandExecutor(const Internal::Logger &logger, QObject *parent = 0);
- void setShowCommandLines(bool enabled) { m_showCommandLines = enabled;}
void setProcessEnvironment(const QProcessEnvironment &processEnvironment) {
m_buildEnvironment = processEnvironment;
}
@@ -77,7 +76,6 @@ private:
QStringList m_arguments;
QProcess m_process;
- bool m_showCommandLines;
QProcessEnvironment m_buildEnvironment;
QString m_responseFileName;
};
diff --git a/src/lib/corelib/corelib.qbs b/src/lib/corelib/corelib.qbs
index d30f59887..a5c1ab652 100644
--- a/src/lib/corelib/corelib.qbs
+++ b/src/lib/corelib/corelib.qbs
@@ -301,6 +301,8 @@ QbsLibrary {
"buildoptions.cpp",
"cleanoptions.cpp",
"codelocation.cpp",
+ "commandechomode.cpp",
+ "commandechomode.h",
"error.cpp",
"executablefinder.cpp",
"executablefinder.h",
diff --git a/src/lib/corelib/tools/buildoptions.cpp b/src/lib/corelib/tools/buildoptions.cpp
index 3b428f9d6..5ac21b97c 100644
--- a/src/lib/corelib/tools/buildoptions.cpp
+++ b/src/lib/corelib/tools/buildoptions.cpp
@@ -40,7 +40,7 @@ class BuildOptionsPrivate : public QSharedData
public:
BuildOptionsPrivate()
: maxJobCount(0), dryRun(false), keepGoing(false), forceTimestampCheck(false),
- logElapsedTime(false), showCommandLines(false), install(true),
+ logElapsedTime(false), echoMode(defaultCommandEchoMode()), install(true),
removeExistingInstallation(false)
{
}
@@ -53,7 +53,7 @@ public:
bool keepGoing;
bool forceTimestampCheck;
bool logElapsedTime;
- bool showCommandLines;
+ CommandEchoMode echoMode;
bool install;
bool removeExistingInstallation;
};
@@ -256,20 +256,19 @@ void BuildOptions::setLogElapsedTime(bool log)
}
/*!
- * \brief Returns true iff command lines should be shown during the build.
- * The default is \c false.
+ * \brief The kind of output that is displayed when executing commands.
*/
-bool BuildOptions::showCommandLines() const
+CommandEchoMode BuildOptions::echoMode() const
{
- return d->showCommandLines;
+ return d->echoMode;
}
/*!
- * \brief Controls whether to show command lines during the build.
+ * \brief Controls the kind of output that is displayed when executing commands.
*/
-void BuildOptions::setShowCommandLines(bool b)
+void BuildOptions::setEchoMode(CommandEchoMode echoMode)
{
- d->showCommandLines = b;
+ d->echoMode = echoMode;
}
/*!
@@ -316,7 +315,7 @@ bool operator==(const BuildOptions &bo1, const BuildOptions &bo2)
&& bo1.dryRun() == bo2.dryRun()
&& bo1.keepGoing() == bo2.keepGoing()
&& bo1.logElapsedTime() == bo2.logElapsedTime()
- && bo1.showCommandLines() == bo2.showCommandLines()
+ && bo1.echoMode() == bo2.echoMode()
&& bo1.maxJobCount() == bo2.maxJobCount()
&& bo1.install() == bo2.install()
&& bo1.removeExistingInstallation() == bo2.removeExistingInstallation();
diff --git a/src/lib/corelib/tools/buildoptions.h b/src/lib/corelib/tools/buildoptions.h
index a777c6765..b1639d682 100644
--- a/src/lib/corelib/tools/buildoptions.h
+++ b/src/lib/corelib/tools/buildoptions.h
@@ -32,6 +32,8 @@
#include "qbs_export.h"
+#include "commandechomode.h"
+
#include <QSharedDataPointer>
#include <QStringList>
@@ -71,8 +73,8 @@ public:
bool logElapsedTime() const;
void setLogElapsedTime(bool log);
- bool showCommandLines() const;
- void setShowCommandLines(bool b);
+ CommandEchoMode echoMode() const;
+ void setEchoMode(CommandEchoMode echoMode);
bool install() const;
void setInstall(bool install);
diff --git a/src/lib/corelib/tools/commandechomode.cpp b/src/lib/corelib/tools/commandechomode.cpp
new file mode 100644
index 000000000..a43fbf821
--- /dev/null
+++ b/src/lib/corelib/tools/commandechomode.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Jake Petroules.
+** Contact: http://www.qt.io/licensing
+**
+** This file is part of the Qt Build Suite.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms and
+** conditions see http://www.qt.io/terms-conditions. For further information
+** use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "commandechomode.h"
+
+/*!
+ * \enum CommandEchoMode
+ * This enum type specifies the kind of output to display when executing commands.
+ * \value CommandEchoModeSilent Indicates that no output will be printed.
+ * \value CommandEchoModeSummary Indicates that descriptions will be printed.
+ * \value CommandEchoModeCommandLine Indidcates that full command line invocations will be printed.
+ */
+
+namespace qbs {
+
+CommandEchoMode defaultCommandEchoMode()
+{
+ return CommandEchoModeSummary;
+}
+
+QString commandEchoModeName(CommandEchoMode mode)
+{
+ switch (mode) {
+ case CommandEchoModeSilent:
+ return QLatin1String("silent");
+ case CommandEchoModeSummary:
+ return QLatin1String("summary");
+ case CommandEchoModeCommandLine:
+ return QLatin1String("command-line");
+ default:
+ break;
+ }
+ return QString();
+}
+
+CommandEchoMode commandEchoModeFromName(const QString &name)
+{
+ CommandEchoMode mode = defaultCommandEchoMode();
+ for (int i = 0; i <= static_cast<int>(CommandEchoModeLast); ++i) {
+ if (commandEchoModeName(static_cast<CommandEchoMode>(i)) == name) {
+ mode = static_cast<CommandEchoMode>(i);
+ break;
+ }
+ }
+
+ return mode;
+}
+
+QStringList allCommandEchoModeStrings()
+{
+ QStringList result;
+ for (int i = 0; i <= static_cast<int>(CommandEchoModeLast); ++i)
+ result << commandEchoModeName(static_cast<CommandEchoMode>(i));
+ return result;
+}
+
+} // namespace qbs
diff --git a/src/lib/corelib/tools/commandechomode.h b/src/lib/corelib/tools/commandechomode.h
new file mode 100644
index 000000000..43421248e
--- /dev/null
+++ b/src/lib/corelib/tools/commandechomode.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Jake Petroules.
+** Contact: http://www.qt.io/licensing
+**
+** This file is part of the Qt Build Suite.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms and
+** conditions see http://www.qt.io/terms-conditions. For further information
+** use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef QBS_COMMANDECHOMODE_H
+#define QBS_COMMANDECHOMODE_H
+
+#include "qbs_export.h"
+#include <QString>
+#include <QStringList>
+
+namespace qbs {
+
+enum CommandEchoMode {
+ CommandEchoModeSilent,
+ CommandEchoModeSummary,
+ CommandEchoModeCommandLine,
+ CommandEchoModeLast = CommandEchoModeCommandLine
+};
+
+QBS_EXPORT CommandEchoMode defaultCommandEchoMode();
+QBS_EXPORT QString commandEchoModeName(CommandEchoMode mode);
+QBS_EXPORT CommandEchoMode commandEchoModeFromName(const QString &name);
+QBS_EXPORT QStringList allCommandEchoModeStrings();
+
+} // namespace qbs
+
+#endif // QBS_COMMANDECHOMODE_H
+
diff --git a/src/lib/corelib/tools/preferences.cpp b/src/lib/corelib/tools/preferences.cpp
index 2f7378978..c0f7cf52b 100644
--- a/src/lib/corelib/tools/preferences.cpp
+++ b/src/lib/corelib/tools/preferences.cpp
@@ -84,6 +84,14 @@ QString Preferences::defaultBuildDirectory() const
}
/*!
+ * \brief Returns the default echo mode used by Qbs if none is specified.
+ */
+CommandEchoMode Preferences::defaultEchoMode() const
+{
+ return commandEchoModeFromName(getPreference(QLatin1String("defaultEchoMode")).toString());
+}
+
+/*!
* \brief Returns the list of paths where qbs looks for modules and imports.
* In addition to user-supplied locations, they will also be looked up at \c{baseDir}/share/qbs.
*/
diff --git a/src/lib/corelib/tools/preferences.h b/src/lib/corelib/tools/preferences.h
index f4f89c7d3..19a2a3010 100644
--- a/src/lib/corelib/tools/preferences.h
+++ b/src/lib/corelib/tools/preferences.h
@@ -32,6 +32,8 @@
#include "qbs_export.h"
+#include "commandechomode.h"
+
#include <QStringList>
#include <QVariant>
@@ -47,6 +49,7 @@ public:
int jobs() const;
QString shell() const;
QString defaultBuildDirectory() const;
+ CommandEchoMode defaultEchoMode() const;
QStringList searchPaths(const QString &baseDir = QString()) const;
QStringList pluginPaths(const QString &baseDir = QString()) const;
diff --git a/src/lib/corelib/tools/tools.pri b/src/lib/corelib/tools/tools.pri
index c6e508aa3..35bc9c8bb 100644
--- a/src/lib/corelib/tools/tools.pri
+++ b/src/lib/corelib/tools/tools.pri
@@ -4,6 +4,7 @@ HEADERS += \
$$PWD/architectures.h \
$$PWD/buildgraphlocker.h \
$$PWD/codelocation.h \
+ $$PWD/commandechomode.h \
$$PWD/error.h \
$$PWD/executablefinder.h \
$$PWD/fileinfo.h \
@@ -39,6 +40,7 @@ SOURCES += \
$$PWD/architectures.cpp \
$$PWD/buildgraphlocker.cpp \
$$PWD/codelocation.cpp \
+ $$PWD/commandechomode.cpp \
$$PWD/error.cpp \
$$PWD/executablefinder.cpp \
$$PWD/fileinfo.cpp \