aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/corelib/buildgraph
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@theqtcompany.com>2014-11-05 16:50:37 +0100
committerJoerg Bornemann <joerg.bornemann@theqtcompany.com>2014-11-07 11:28:35 +0100
commitbd3764d42ed06769ce854f974c6e448ea3263e87 (patch)
treeee0dda2d66a33f58ca912ef7c89922c444622500 /src/lib/corelib/buildgraph
parent842ae64080f33366715c390a5f3b338ea8dd5ff2 (diff)
add option to show command lines in build output
With "qbs build --show-command-lines" one can suppress command descriptions and show actual command lines instead. Change-Id: I98328254bad7fb85036abb0525c5ad7e734110c7 Task-number: QBS-615 Reviewed-by: Christian Kandeler <christian.kandeler@digia.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Diffstat (limited to 'src/lib/corelib/buildgraph')
-rw-r--r--src/lib/corelib/buildgraph/abstractcommandexecutor.cpp23
-rw-r--r--src/lib/corelib/buildgraph/abstractcommandexecutor.h1
-rw-r--r--src/lib/corelib/buildgraph/executor.cpp1
-rw-r--r--src/lib/corelib/buildgraph/executorjob.cpp5
-rw-r--r--src/lib/corelib/buildgraph/executorjob.h1
-rw-r--r--src/lib/corelib/buildgraph/processcommandexecutor.cpp14
-rw-r--r--src/lib/corelib/buildgraph/processcommandexecutor.h3
7 files changed, 40 insertions, 8 deletions
diff --git a/src/lib/corelib/buildgraph/abstractcommandexecutor.cpp b/src/lib/corelib/buildgraph/abstractcommandexecutor.cpp
index 3549d09c4..3560d20f0 100644
--- a/src/lib/corelib/buildgraph/abstractcommandexecutor.cpp
+++ b/src/lib/corelib/buildgraph/abstractcommandexecutor.cpp
@@ -52,16 +52,23 @@ void AbstractCommandExecutor::start(Transformer *transformer, const AbstractComm
{
m_transformer = transformer;
m_command = cmd;
- if (!m_command->isSilent()) {
- if (m_command->description().isEmpty()) {
- m_logger.printWarning(ErrorInfo(Tr::tr("Command is not marked silent, but has no "
- "description."), m_command->codeLocation()));
- } else {
- emit reportCommandDescription(m_command->highlight(), m_command->description());
- }
- }
+ doReportCommandDescription();
doStart();
}
+void AbstractCommandExecutor::doReportCommandDescription()
+{
+ if (m_command->isSilent())
+ return;
+
+ if (m_command->description().isEmpty()) {
+ m_logger.printWarning(
+ ErrorInfo(Tr::tr("Command is not marked silent, but has no description."),
+ m_command->codeLocation()));
+ } else {
+ emit reportCommandDescription(m_command->highlight(), m_command->description());
+ }
+}
+
} // namespace Internal
} // namespace qbs
diff --git a/src/lib/corelib/buildgraph/abstractcommandexecutor.h b/src/lib/corelib/buildgraph/abstractcommandexecutor.h
index 7423fcedd..ba8a952e5 100644
--- a/src/lib/corelib/buildgraph/abstractcommandexecutor.h
+++ b/src/lib/corelib/buildgraph/abstractcommandexecutor.h
@@ -63,6 +63,7 @@ signals:
void finished(const qbs::ErrorInfo &err = ErrorInfo()); // !hasError() <=> command successful
protected:
+ virtual void doReportCommandDescription();
const AbstractCommand *command() const { return m_command; }
Transformer *transformer() const { return m_transformer; }
ScriptEngine *scriptEngine() const { return m_mainThreadScriptEngine; }
diff --git a/src/lib/corelib/buildgraph/executor.cpp b/src/lib/corelib/buildgraph/executor.cpp
index 556c60ce5..aa3f47a04 100644
--- a/src/lib/corelib/buildgraph/executor.cpp
+++ b/src/lib/corelib/buildgraph/executor.cpp
@@ -655,6 +655,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());
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 abd2102c2..15a549332 100644
--- a/src/lib/corelib/buildgraph/executorjob.cpp
+++ b/src/lib/corelib/buildgraph/executorjob.cpp
@@ -78,6 +78,11 @@ void ExecutorJob::setDryRun(bool enabled)
m_jsCommandExecutor->setDryRunEnabled(enabled);
}
+void ExecutorJob::setShowCommandLines(bool enabled)
+{
+ m_processCommandExecutor->setShowCommandLines(enabled);
+}
+
void ExecutorJob::run(Transformer *t)
{
QBS_ASSERT(m_currentCommandIdx == -1, return);
diff --git a/src/lib/corelib/buildgraph/executorjob.h b/src/lib/corelib/buildgraph/executorjob.h
index cf914d5d9..d22b47bb5 100644
--- a/src/lib/corelib/buildgraph/executorjob.h
+++ b/src/lib/corelib/buildgraph/executorjob.h
@@ -58,6 +58,7 @@ public:
void setMainThreadScriptEngine(ScriptEngine *engine);
void setDryRun(bool enabled);
+ void setShowCommandLines(bool enabled);
void run(Transformer *t);
void cancel();
diff --git a/src/lib/corelib/buildgraph/processcommandexecutor.cpp b/src/lib/corelib/buildgraph/processcommandexecutor.cpp
index 5eb034af5..e23f588f7 100644
--- a/src/lib/corelib/buildgraph/processcommandexecutor.cpp
+++ b/src/lib/corelib/buildgraph/processcommandexecutor.cpp
@@ -58,6 +58,7 @@ 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)));
@@ -269,6 +270,19 @@ void ProcessCommandExecutor::onProcessFinished(int exitCode)
emit finished();
}
+void ProcessCommandExecutor::doReportCommandDescription()
+{
+ if (m_showCommandLines) {
+ const ProcessCommand * const cmd = processCommand();
+ emit reportCommandDescription(QString(),
+ cmd->program() + QLatin1Char(' ')
+ + cmd->arguments().join(QLatin1Char(' ')));
+ return;
+ }
+
+ AbstractCommandExecutor::doReportCommandDescription();
+}
+
void ProcessCommandExecutor::removeResponseFile()
{
if (m_responseFileName.isEmpty())
diff --git a/src/lib/corelib/buildgraph/processcommandexecutor.h b/src/lib/corelib/buildgraph/processcommandexecutor.h
index fc9be61e0..173115cbb 100644
--- a/src/lib/corelib/buildgraph/processcommandexecutor.h
+++ b/src/lib/corelib/buildgraph/processcommandexecutor.h
@@ -49,6 +49,7 @@ 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;
}
@@ -61,6 +62,7 @@ private slots:
void onProcessFinished(int exitCode);
private:
+ void doReportCommandDescription();
void doStart();
void cancel();
@@ -75,6 +77,7 @@ private:
QStringList m_arguments;
QProcess m_process;
+ bool m_showCommandLines;
QProcessEnvironment m_buildEnvironment;
QString m_responseFileName;
};