aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--src/app/qbs/commandlinefrontend.cpp21
-rw-r--r--src/app/qbs/parser/command.cpp4
-rw-r--r--src/app/qbs/parser/commandlineoption.cpp52
-rw-r--r--src/app/qbs/parser/commandlineoption.h17
-rw-r--r--src/app/qbs/parser/commandlineoptionpool.cpp10
-rw-r--r--src/app/qbs/parser/commandlineoptionpool.h2
-rw-r--r--src/app/qbs/parser/commandlineparser.cpp40
-rw-r--r--src/app/qbs/parser/commandlineparser.h6
-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
-rw-r--r--tests/auto/cmdlineparser/tst_cmdlineparser.cpp4
24 files changed, 299 insertions, 58 deletions
diff --git a/src/app/qbs/commandlinefrontend.cpp b/src/app/qbs/commandlinefrontend.cpp
index 105aae990..e5c38bb4f 100644
--- a/src/app/qbs/commandlinefrontend.cpp
+++ b/src/app/qbs/commandlinefrontend.cpp
@@ -389,12 +389,14 @@ void CommandLineFrontend::makeClean()
{
if (m_parser.products().isEmpty()) {
foreach (const Project &project, m_projects) {
- m_buildJobs << project.cleanAllProducts(m_parser.cleanOptions(), this);
+ m_buildJobs << project.cleanAllProducts(m_parser.cleanOptions(project.profile()), this);
}
} else {
const ProductMap &products = productsToUse();
for (ProductMap::ConstIterator it = products.begin(); it != products.end(); ++it) {
- m_buildJobs << it.key().cleanSomeProducts(it.value(), m_parser.cleanOptions(), this);
+ m_buildJobs << it.key().cleanSomeProducts(it.value(),
+ m_parser.cleanOptions(it.key().profile()),
+ this);
}
}
connectBuildJobs();
@@ -404,14 +406,14 @@ int CommandLineFrontend::runShell()
{
const ProductData productToRun = getTheOneRunnableProduct();
RunEnvironment runEnvironment = m_projects.first().getRunEnvironment(productToRun,
- m_parser.installOptions(),
+ m_parser.installOptions(m_projects.first().profile()),
QProcessEnvironment::systemEnvironment(), m_settings);
return runEnvironment.runShell();
}
BuildOptions CommandLineFrontend::buildOptions(const Project &project) const
{
- BuildOptions options = m_parser.buildOptions();
+ BuildOptions options = m_parser.buildOptions(m_projects.first().profile());
if (options.maxJobCount() <= 0) {
const QString profileName = project.profile();
QBS_CHECK(!profileName.isEmpty());
@@ -488,20 +490,20 @@ void CommandLineFrontend::generate()
generator->clearProjects();
generator->addProjects(m_projects);
- generator->generate(m_parser.installOptions());
+ generator->generate(m_parser.installOptions(m_projects.first().profile()));
}
int CommandLineFrontend::runTarget()
{
const ProductData productToRun = getTheOneRunnableProduct();
const QString executableFilePath = m_projects.first().targetExecutable(productToRun,
- m_parser.installOptions());
+ m_parser.installOptions(m_projects.first().profile()));
if (executableFilePath.isEmpty()) {
throw ErrorInfo(Tr::tr("Cannot run: Product '%1' is not an application.")
.arg(productToRun.name()));
}
RunEnvironment runEnvironment = m_projects.first().getRunEnvironment(productToRun,
- m_parser.installOptions(),
+ m_parser.installOptions(m_projects.first().profile()),
QProcessEnvironment::systemEnvironment(), m_settings);
return runEnvironment.runTarget(executableFilePath, m_parser.runArgs());
}
@@ -608,12 +610,13 @@ void CommandLineFrontend::install()
if (m_parser.products().isEmpty()) {
const Project::ProductSelection productSelection = m_parser.withNonDefaultProducts()
? Project::ProductSelectionWithNonDefault : Project::ProductSelectionDefaultOnly;
- installJob = project.installAllProducts(m_parser.installOptions(), productSelection);
+ installJob = project.installAllProducts(m_parser.installOptions(project.profile()),
+ productSelection);
} else {
const Project project = m_projects.first();
const ProductMap products = productsToUse();
installJob = project.installSomeProducts(products.value(project),
- m_parser.installOptions());
+ m_parser.installOptions(project.profile()));
}
connectJob(installJob);
}
diff --git a/src/app/qbs/parser/command.cpp b/src/app/qbs/parser/command.cpp
index 9e197e944..f39300846 100644
--- a/src/app/qbs/parser/command.cpp
+++ b/src/app/qbs/parser/command.cpp
@@ -247,7 +247,7 @@ static QList<CommandLineOption::Type> buildOptions()
<< CommandLineOption::ChangedFilesOptionType
<< CommandLineOption::ForceTimestampCheckOptionType
<< CommandLineOption::BuildNonDefaultOptionType
- << CommandLineOption::ShowCommandLinesOptionType
+ << CommandLineOption::CommandEchoModeOptionType
<< CommandLineOption::NoInstallOptionType
<< CommandLineOption::RemoveFirstOptionType;
}
@@ -281,7 +281,7 @@ QList<CommandLineOption::Type> CleanCommand::supportedOptions() const
options.removeOne(CommandLineOption::ChangedFilesOptionType);
options.removeOne(CommandLineOption::JobsOptionType);
options.removeOne(CommandLineOption::BuildNonDefaultOptionType);
- options.removeOne(CommandLineOption::ShowCommandLinesOptionType);
+ options.removeOne(CommandLineOption::CommandEchoModeOptionType);
return options << CommandLineOption::AllArtifactsOptionType;
}
diff --git a/src/app/qbs/parser/commandlineoption.cpp b/src/app/qbs/parser/commandlineoption.cpp
index 000cce5dc..e0c6dd0b8 100644
--- a/src/app/qbs/parser/commandlineoption.cpp
+++ b/src/app/qbs/parser/commandlineoption.cpp
@@ -41,12 +41,23 @@ CommandLineOption::~CommandLineOption()
{
}
+bool CommandLineOption::wasSet() const
+{
+ return m_wasSet;
+}
+
void CommandLineOption::parse(CommandType command, const QString &representation, QStringList &input)
{
m_command = command;
+ m_wasSet = true;
doParse(representation, input);
}
+CommandLineOption::CommandLineOption()
+ : m_command(static_cast<CommandType>(-1)), m_wasSet(false)
+{
+}
+
QString CommandLineOption::getArgument(const QString &representation, QStringList &input)
{
if (input.isEmpty()) {
@@ -563,16 +574,47 @@ void SettingsDirOption::doParse(const QString &representation, QStringList &inpu
m_settingsDir = input.takeFirst();
}
-QString ShowCommandLinesOption::description(CommandType command) const
+CommandEchoModeOption::CommandEchoModeOption()
+ : m_echoMode(defaultCommandEchoMode())
+{
+}
+
+QString CommandEchoModeOption::description(CommandType command) const
{
Q_UNUSED(command);
- return Tr::tr("%1\n\tShow command lines instead of command descriptions.\n")
- .arg(longRepresentation());
+ return Tr::tr("%1 <mode>\n"
+ "\tKind of output to show when executing commands.\n"
+ "\tPossible values are '%2'.\n"
+ "\tThe default is '%3'.\n")
+ .arg(longRepresentation(), allCommandEchoModeStrings().join(QLatin1String("', '")),
+ commandEchoModeName(defaultCommandEchoMode()));
}
-QString ShowCommandLinesOption::longRepresentation() const
+QString CommandEchoModeOption::longRepresentation() const
{
- return QLatin1String("--show-command-lines");
+ return QLatin1String("--command-echo-mode");
+}
+
+CommandEchoMode CommandEchoModeOption::commandEchoMode() const
+{
+ return m_echoMode;
+}
+
+void CommandEchoModeOption::doParse(const QString &representation, QStringList &input)
+{
+ const QString mode = getArgument(representation, input);
+ if (mode.isEmpty()) {
+ throw ErrorInfo(Tr::tr("Invalid use of option '%1': No command echo mode given.\nUsage: %2")
+ .arg(representation, description(command())));
+ }
+
+ if (!allCommandEchoModeStrings().contains(mode)) {
+ throw ErrorInfo(Tr::tr("Invalid use of option '%1': "
+ "Invalid command echo mode '%2' given.\nUsage: %3")
+ .arg(representation, mode, description(command())));
+ }
+
+ m_echoMode = commandEchoModeFromName(mode);
}
} // namespace qbs
diff --git a/src/app/qbs/parser/commandlineoption.h b/src/app/qbs/parser/commandlineoption.h
index eb3234c0f..0f3119275 100644
--- a/src/app/qbs/parser/commandlineoption.h
+++ b/src/app/qbs/parser/commandlineoption.h
@@ -32,6 +32,8 @@
#include "commandtype.h"
+#include <tools/commandechomode.h>
+
#include <QStringList>
namespace qbs {
@@ -56,7 +58,7 @@ public:
ForceTimestampCheckOptionType,
BuildNonDefaultOptionType,
LogTimeOptionType,
- ShowCommandLinesOptionType,
+ CommandEchoModeOptionType,
SettingsDirOptionType,
GeneratorOptionType
};
@@ -67,9 +69,11 @@ public:
virtual QString longRepresentation() const = 0;
virtual bool canAppearMoreThanOnce() const { return false; }
+ bool wasSet() const;
void parse(CommandType command, const QString &representation, QStringList &input);
protected:
+ CommandLineOption();
QString getArgument(const QString &representation, QStringList &input);
CommandType command() const { return m_command; }
@@ -77,6 +81,7 @@ private:
virtual void doParse(const QString &representation, QStringList &input) = 0;
CommandType m_command;
+ bool m_wasSet;
};
class FileOption : public CommandLineOption
@@ -326,12 +331,20 @@ public:
QString longRepresentation() const;
};
-class ShowCommandLinesOption : public OnOffOption
+class CommandEchoModeOption : public CommandLineOption
{
public:
+ CommandEchoModeOption();
+
QString description(CommandType command) const;
QString shortRepresentation() const { return QString(); }
QString longRepresentation() const;
+ CommandEchoMode commandEchoMode() const;
+
+private:
+ void doParse(const QString &representation, QStringList &input);
+
+ CommandEchoMode m_echoMode;
};
class SettingsDirOption : public CommandLineOption
diff --git a/src/app/qbs/parser/commandlineoptionpool.cpp b/src/app/qbs/parser/commandlineoptionpool.cpp
index dcd734002..6427f260d 100644
--- a/src/app/qbs/parser/commandlineoptionpool.cpp
+++ b/src/app/qbs/parser/commandlineoptionpool.cpp
@@ -101,8 +101,8 @@ CommandLineOption *CommandLineOptionPool::getOption(CommandLineOption::Type type
case CommandLineOption::LogTimeOptionType:
option = new LogTimeOption;
break;
- case CommandLineOption::ShowCommandLinesOptionType:
- option = new ShowCommandLinesOption;
+ case CommandLineOption::CommandEchoModeOptionType:
+ option = new CommandEchoModeOption;
break;
case CommandLineOption::SettingsDirOptionType:
option = new SettingsDirOption;
@@ -219,10 +219,10 @@ LogTimeOption *CommandLineOptionPool::logTimeOption() const
return static_cast<LogTimeOption *>(getOption(CommandLineOption::LogTimeOptionType));
}
-ShowCommandLinesOption *CommandLineOptionPool::showCommandLinesOption() const
+CommandEchoModeOption *CommandLineOptionPool::commandEchoModeOption() const
{
- return static_cast<ShowCommandLinesOption *>(
- getOption(CommandLineOption::ShowCommandLinesOptionType));
+ return static_cast<CommandEchoModeOption *>(
+ getOption(CommandLineOption::CommandEchoModeOptionType));
}
SettingsDirOption *CommandLineOptionPool::settingsDirOption() const
diff --git a/src/app/qbs/parser/commandlineoptionpool.h b/src/app/qbs/parser/commandlineoptionpool.h
index 76c89bb38..6930c19e9 100644
--- a/src/app/qbs/parser/commandlineoptionpool.h
+++ b/src/app/qbs/parser/commandlineoptionpool.h
@@ -62,7 +62,7 @@ public:
ForceTimeStampCheckOption *forceTimestampCheckOption() const;
BuildNonDefaultOption *buildNonDefaultOption() const;
LogTimeOption *logTimeOption() const;
- ShowCommandLinesOption *showCommandLinesOption() const;
+ CommandEchoModeOption *commandEchoModeOption() const;
SettingsDirOption *settingsDirOption() const;
GeneratorOption *generatorOption() const;
diff --git a/src/app/qbs/parser/commandlineparser.cpp b/src/app/qbs/parser/commandlineparser.cpp
index 19864631e..1b89b2474 100644
--- a/src/app/qbs/parser/commandlineparser.cpp
+++ b/src/app/qbs/parser/commandlineparser.cpp
@@ -82,6 +82,8 @@ public:
bool dryRun() const;
QString settingsDir() const { return optionPool.settingsDirOption()->settingsDir(); }
+ CommandEchoMode echoMode() const;
+
QString propertyName(const QString &aCommandLineName) const;
QStringList commandLine;
@@ -141,19 +143,30 @@ QString CommandLineParser::projectBuildDirectory() const
return d->projectBuildDirectory;
}
-BuildOptions CommandLineParser::buildOptions() const
+BuildOptions CommandLineParser::buildOptions(const QString &profile) const
{
+ Settings settings(settingsDir());
+ Preferences preferences(&settings, profile);
+
+ if (d->buildOptions.maxJobCount() <= 0) {
+ d->buildOptions.setMaxJobCount(preferences.jobs());
+ }
+
+ if (!d->optionPool.commandEchoModeOption()->wasSet()) {
+ d->buildOptions.setEchoMode(preferences.defaultEchoMode());
+ }
+
return d->buildOptions;
}
-CleanOptions CommandLineParser::cleanOptions() const
+CleanOptions CommandLineParser::cleanOptions(const QString &profile) const
{
Q_ASSERT(command() == CleanCommandType);
CleanOptions options;
options.setCleanType(d->optionPool.allArtifactsOption()->enabled()
? CleanOptions::CleanupAll : CleanOptions::CleanupTemporaries);
- options.setDryRun(buildOptions().dryRun());
- options.setKeepGoing(buildOptions().keepGoing());
+ options.setDryRun(buildOptions(profile).dryRun());
+ options.setKeepGoing(buildOptions(profile).keepGoing());
options.setLogElapsedTime(logTime());
return options;
}
@@ -166,7 +179,7 @@ GenerateOptions CommandLineParser::generateOptions() const
return options;
}
-InstallOptions CommandLineParser::installOptions() const
+InstallOptions CommandLineParser::installOptions(const QString &profile) const
{
Q_ASSERT(command() == InstallCommandType || command() == RunCommandType
|| command() == GenerateCommandType);
@@ -179,8 +192,8 @@ InstallOptions CommandLineParser::installOptions() const
if (!fi.isAbsolute())
options.setInstallRoot(fi.absoluteFilePath());
}
- options.setDryRun(buildOptions().dryRun());
- options.setKeepGoing(buildOptions().keepGoing());
+ options.setDryRun(buildOptions(profile).dryRun());
+ options.setKeepGoing(buildOptions(profile).keepGoing());
options.setLogElapsedTime(logTime());
return options;
}
@@ -490,7 +503,7 @@ void CommandLineParser::CommandLineParserPrivate::setupBuildOptions()
const JobsOption * jobsOption = optionPool.jobsOption();
buildOptions.setMaxJobCount(jobsOption->jobCount());
buildOptions.setLogElapsedTime(logTime);
- buildOptions.setShowCommandLines(optionPool.showCommandLinesOption()->enabled());
+ buildOptions.setEchoMode(echoMode());
buildOptions.setInstall(!optionPool.noInstallOption()->enabled());
buildOptions.setRemoveExistingInstallation(optionPool.removeFirstoption()->enabled());
}
@@ -597,4 +610,15 @@ bool CommandLineParser::CommandLineParserPrivate::dryRun() const
return optionPool.dryRunOption()->enabled();
}
+CommandEchoMode CommandLineParser::CommandLineParserPrivate::echoMode() const
+{
+ if (command->type() == GenerateCommandType)
+ return CommandEchoModeSilent;
+
+ if (optionPool.commandEchoModeOption()->wasSet())
+ return optionPool.commandEchoModeOption()->commandEchoMode();
+
+ return defaultCommandEchoMode();
+}
+
} // namespace qbs
diff --git a/src/app/qbs/parser/commandlineparser.h b/src/app/qbs/parser/commandlineparser.h
index d6880be05..2d7bd4f7d 100644
--- a/src/app/qbs/parser/commandlineparser.h
+++ b/src/app/qbs/parser/commandlineparser.h
@@ -57,10 +57,10 @@ public:
QString commandDescription() const;
QString projectFilePath() const;
QString projectBuildDirectory() const;
- BuildOptions buildOptions() const;
- CleanOptions cleanOptions() const;
+ BuildOptions buildOptions(const QString &profile) const;
+ CleanOptions cleanOptions(const QString &profile) const;
GenerateOptions generateOptions() const;
- InstallOptions installOptions() const;
+ InstallOptions installOptions(const QString &profile) const;
bool force() const;
bool forceTimestampCheck() const;
bool dryRun() const;
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 \
diff --git a/tests/auto/cmdlineparser/tst_cmdlineparser.cpp b/tests/auto/cmdlineparser/tst_cmdlineparser.cpp
index e1dbd1ddb..60b7bfd73 100644
--- a/tests/auto/cmdlineparser/tst_cmdlineparser.cpp
+++ b/tests/auto/cmdlineparser/tst_cmdlineparser.cpp
@@ -69,8 +69,8 @@ private slots:
QCOMPARE(ConsoleLogger::instance().logSink()->logLevel(), LoggerTrace);
QCOMPARE(parser.command(), BuildCommandType);
QCOMPARE(parser.products(), QStringList() << "blubb");
- QCOMPARE(parser.buildOptions().changedFiles().count(), 2);
- QVERIFY(parser.buildOptions().keepGoing());
+ QCOMPARE(parser.buildOptions(QString()).changedFiles().count(), 2);
+ QVERIFY(parser.buildOptions(QString()).keepGoing());
QVERIFY(parser.force());
QVERIFY(parser.forceTimestampCheck());
QVERIFY(!parser.logTime());