aboutsummaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/app/qbs/parser/command.cpp3
-rw-r--r--src/app/qbs/parser/commandlineoption.cpp12
-rw-r--r--src/app/qbs/parser/commandlineoption.h9
-rw-r--r--src/app/qbs/parser/commandlineoptionpool.cpp9
-rw-r--r--src/app/qbs/parser/commandlineoptionpool.h1
-rw-r--r--src/app/qbs/parser/commandlineparser.cpp1
-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
-rw-r--r--src/lib/corelib/tools/buildoptions.cpp21
-rw-r--r--src/lib/corelib/tools/buildoptions.h3
15 files changed, 97 insertions, 10 deletions
diff --git a/src/app/qbs/parser/command.cpp b/src/app/qbs/parser/command.cpp
index 62320958a..4f8830e2e 100644
--- a/src/app/qbs/parser/command.cpp
+++ b/src/app/qbs/parser/command.cpp
@@ -215,7 +215,8 @@ static QList<CommandLineOption::Type> buildOptions()
<< CommandLineOption::ProductsOptionType
<< CommandLineOption::ChangedFilesOptionType
<< CommandLineOption::ForceTimestampCheckOptionType
- << CommandLineOption::BuildNonDefaultOptionType;
+ << CommandLineOption::BuildNonDefaultOptionType
+ << CommandLineOption::ShowCommandLinesOptionType;
}
QList<CommandLineOption::Type> BuildCommand::supportedOptions() const
diff --git a/src/app/qbs/parser/commandlineoption.cpp b/src/app/qbs/parser/commandlineoption.cpp
index 92a737584..f3b57865f 100644
--- a/src/app/qbs/parser/commandlineoption.cpp
+++ b/src/app/qbs/parser/commandlineoption.cpp
@@ -515,4 +515,16 @@ void SettingsDirOption::doParse(const QString &representation, QStringList &inpu
m_settingsDir = input.takeFirst();
}
+QString ShowCommandLinesOption::description(CommandType command) const
+{
+ Q_UNUSED(command);
+ return Tr::tr("%1\n\tShow command lines instead of command descriptions.\n")
+ .arg(longRepresentation());
+}
+
+QString ShowCommandLinesOption::longRepresentation() const
+{
+ return QLatin1String("--show-command-lines");
+}
+
} // namespace qbs
diff --git a/src/app/qbs/parser/commandlineoption.h b/src/app/qbs/parser/commandlineoption.h
index 39ed8df02..a070cc561 100644
--- a/src/app/qbs/parser/commandlineoption.h
+++ b/src/app/qbs/parser/commandlineoption.h
@@ -55,6 +55,7 @@ public:
ForceTimestampCheckOptionType,
BuildNonDefaultOptionType,
LogTimeOptionType,
+ ShowCommandLinesOptionType,
SettingsDirOptionType
};
@@ -300,6 +301,14 @@ public:
QString longRepresentation() const;
};
+class ShowCommandLinesOption : public OnOffOption
+{
+public:
+ QString description(CommandType command) const;
+ QString shortRepresentation() const { return QString(); }
+ QString longRepresentation() const;
+};
+
class SettingsDirOption : public CommandLineOption
{
public:
diff --git a/src/app/qbs/parser/commandlineoptionpool.cpp b/src/app/qbs/parser/commandlineoptionpool.cpp
index f772c3ebb..c80529d7a 100644
--- a/src/app/qbs/parser/commandlineoptionpool.cpp
+++ b/src/app/qbs/parser/commandlineoptionpool.cpp
@@ -98,6 +98,9 @@ CommandLineOption *CommandLineOptionPool::getOption(CommandLineOption::Type type
case CommandLineOption::LogTimeOptionType:
option = new LogTimeOption;
break;
+ case CommandLineOption::ShowCommandLinesOptionType:
+ option = new ShowCommandLinesOption;
+ break;
case CommandLineOption::SettingsDirOptionType:
option = new SettingsDirOption;
break;
@@ -205,6 +208,12 @@ LogTimeOption *CommandLineOptionPool::logTimeOption() const
return static_cast<LogTimeOption *>(getOption(CommandLineOption::LogTimeOptionType));
}
+ShowCommandLinesOption *CommandLineOptionPool::showCommandLinesOption() const
+{
+ return static_cast<ShowCommandLinesOption *>(
+ getOption(CommandLineOption::ShowCommandLinesOptionType));
+}
+
SettingsDirOption *CommandLineOptionPool::settingsDirOption() const
{
return static_cast<SettingsDirOption *>(getOption(CommandLineOption::SettingsDirOptionType));
diff --git a/src/app/qbs/parser/commandlineoptionpool.h b/src/app/qbs/parser/commandlineoptionpool.h
index 3aeeec2a1..f14c36165 100644
--- a/src/app/qbs/parser/commandlineoptionpool.h
+++ b/src/app/qbs/parser/commandlineoptionpool.h
@@ -61,6 +61,7 @@ public:
ForceTimeStampCheckOption *forceTimestampCheckOption() const;
BuildNonDefaultOption *buildNonDefaultOption() const;
LogTimeOption *logTimeOption() const;
+ ShowCommandLinesOption *showCommandLinesOption() const;
SettingsDirOption *settingsDirOption() const;
private:
diff --git a/src/app/qbs/parser/commandlineparser.cpp b/src/app/qbs/parser/commandlineparser.cpp
index eb8781e66..852f8aad4 100644
--- a/src/app/qbs/parser/commandlineparser.cpp
+++ b/src/app/qbs/parser/commandlineparser.cpp
@@ -478,6 +478,7 @@ void CommandLineParser::CommandLineParserPrivate::setupBuildOptions()
const JobsOption * jobsOption = optionPool.jobsOption();
buildOptions.setMaxJobCount(jobsOption->jobCount());
buildOptions.setLogElapsedTime(logTime);
+ buildOptions.setShowCommandLines(optionPool.showCommandLinesOption()->enabled());
}
void CommandLineParser::CommandLineParserPrivate::setupProgress()
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;
};
diff --git a/src/lib/corelib/tools/buildoptions.cpp b/src/lib/corelib/tools/buildoptions.cpp
index dc23359b4..6c5f6f7ca 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)
+ logElapsedTime(false), showCommandLines(false)
{
}
@@ -52,6 +52,7 @@ public:
bool keepGoing;
bool forceTimestampCheck;
bool logElapsedTime;
+ bool showCommandLines;
};
} // namespace Internal
@@ -251,6 +252,23 @@ void BuildOptions::setLogElapsedTime(bool log)
d->logElapsedTime = log;
}
+/*!
+ * \brief Returns true iff command lines should be shown during the build.
+ * The default is \c false.
+ */
+bool BuildOptions::showCommandLines() const
+{
+ return d->showCommandLines;
+}
+
+/*!
+ * \brief Controls whether to show command lines during the build.
+ */
+void BuildOptions::setShowCommandLines(bool b)
+{
+ d->showCommandLines = b;
+}
+
bool operator==(const BuildOptions &bo1, const BuildOptions &bo2)
{
@@ -258,6 +276,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.maxJobCount() == bo2.maxJobCount();
}
diff --git a/src/lib/corelib/tools/buildoptions.h b/src/lib/corelib/tools/buildoptions.h
index e943815f1..49aa7f5fe 100644
--- a/src/lib/corelib/tools/buildoptions.h
+++ b/src/lib/corelib/tools/buildoptions.h
@@ -71,6 +71,9 @@ public:
bool logElapsedTime() const;
void setLogElapsedTime(bool log);
+ bool showCommandLines() const;
+ void setShowCommandLines(bool b);
+
private:
QSharedDataPointer<Internal::BuildOptionsPrivate> d;
};