aboutsummaryrefslogtreecommitdiffstats
path: root/src/app/qbs
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@digia.com>2013-03-25 17:15:03 +0100
committerChristian Kandeler <christian.kandeler@digia.com>2013-03-26 11:51:43 +0100
commit83a24ab31851e939a3837e77e967fc55c2c5297a (patch)
tree66148794539dac58f44c4618880a6529d44afe45 /src/app/qbs
parentf8b8aa5c5fdab5da3d43b693b974fa46b6b4bd6e (diff)
Add new command "resolve".
This resolves the project and applies the rules, but does not build it. Saving the build graph can be switched off using the "--dry-run" option. Change-Id: Ib917937a9aac1f3405d95adfd8a2fd5666a84af2 Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'src/app/qbs')
-rw-r--r--src/app/qbs/commandlinefrontend.cpp4
-rw-r--r--src/app/qbs/parser/command.cpp53
-rw-r--r--src/app/qbs/parser/command.h13
-rw-r--r--src/app/qbs/parser/commandlineparser.cpp10
-rw-r--r--src/app/qbs/parser/commandlineparser.h1
-rw-r--r--src/app/qbs/parser/commandpool.cpp3
-rw-r--r--src/app/qbs/parser/commandtype.h2
7 files changed, 72 insertions, 14 deletions
diff --git a/src/app/qbs/commandlinefrontend.cpp b/src/app/qbs/commandlinefrontend.cpp
index 157796fd5..b85326db6 100644
--- a/src/app/qbs/commandlinefrontend.cpp
+++ b/src/app/qbs/commandlinefrontend.cpp
@@ -104,6 +104,7 @@ void CommandLineFrontend::start()
params.searchPaths = Preferences(m_settings).searchPaths(qbsRootPath);
params.pluginPaths = Preferences(m_settings).pluginPaths(qbsRootPath);
params.ignoreDifferentProjectFilePath = m_parser.force();
+ params.dryRun = m_parser.dryRun();
foreach (const QVariantMap &buildConfig, m_parser.buildConfigurations()) {
params.buildConfiguration = buildConfig;
SetupProjectJob * const job = Project::setupProject(params, m_settings,
@@ -282,6 +283,9 @@ void CommandLineFrontend::handleProjectsResolved()
if (m_canceled)
throw Error(Tr::tr("Execution canceled due to user request."));
switch (m_parser.command()) {
+ case ResolveCommandType:
+ qApp->quit();
+ break;
case CleanCommandType:
makeClean();
break;
diff --git a/src/app/qbs/parser/command.cpp b/src/app/qbs/parser/command.cpp
index a093a1c6e..1e92cef50 100644
--- a/src/app/qbs/parser/command.cpp
+++ b/src/app/qbs/parser/command.cpp
@@ -140,27 +140,26 @@ void Command::parseMore(QStringList &input)
addAllToAdditionalArguments(input);
}
-QString BuildCommand::shortDescription() const
+
+QString ResolveCommand::shortDescription() const
{
- return Tr::tr("Build (parts of) a number of projects. This is the default command.");
+ return Tr::tr("Resolve a project without building it.");
}
-QString BuildCommand::longDescription() const
+QString ResolveCommand::longDescription() const
{
QString description = Tr::tr("qbs %1 [options] [[variant] [property:value] ...] ...\n")
.arg(representation());
- description += Tr::tr("Builds a project in one or more configuration(s).\n");
+ description += Tr::tr("Resolves a project in one or more configuration(s).\n");
return description += supportedOptionsDescription();
}
-static QString buildCommandRepresentation() { return QLatin1String("build"); }
-
-QString BuildCommand::representation() const
+QString ResolveCommand::representation() const
{
- return buildCommandRepresentation();
+ return QLatin1String("resolve");
}
-static QList<CommandLineOption::Type> buildOptions()
+static QList<CommandLineOption::Type> resolveOptions()
{
return QList<CommandLineOption::Type>()
<< CommandLineOption::FileOptionType
@@ -169,13 +168,43 @@ static QList<CommandLineOption::Type> buildOptions()
<< CommandLineOption::QuietOptionType
<< CommandLineOption::ShowProgressOptionType
<< CommandLineOption::JobsOptionType
- << CommandLineOption::KeepGoingOptionType
<< CommandLineOption::DryRunOptionType
- << CommandLineOption::ProductsOptionType
- << CommandLineOption::ChangedFilesOptionType
<< CommandLineOption::ForceOptionType;
}
+QList<CommandLineOption::Type> ResolveCommand::supportedOptions() const
+{
+ return resolveOptions();
+}
+
+QString BuildCommand::shortDescription() const
+{
+ return Tr::tr("Build (parts of) a project. This is the default command.");
+}
+
+QString BuildCommand::longDescription() const
+{
+ QString description = Tr::tr("qbs %1 [options] [[variant] [property:value] ...] ...\n")
+ .arg(representation());
+ description += Tr::tr("Builds a project in one or more configuration(s).\n");
+ return description += supportedOptionsDescription();
+}
+
+static QString buildCommandRepresentation() { return QLatin1String("build"); }
+
+QString BuildCommand::representation() const
+{
+ return buildCommandRepresentation();
+}
+
+static QList<CommandLineOption::Type> buildOptions()
+{
+ QList<CommandLineOption::Type> options = resolveOptions();
+ return options << CommandLineOption::KeepGoingOptionType
+ << CommandLineOption::ProductsOptionType
+ << CommandLineOption::ChangedFilesOptionType;
+}
+
QList<CommandLineOption::Type> BuildCommand::supportedOptions() const
{
return buildOptions();
diff --git a/src/app/qbs/parser/command.h b/src/app/qbs/parser/command.h
index 6ebef1107..b5446c04f 100644
--- a/src/app/qbs/parser/command.h
+++ b/src/app/qbs/parser/command.h
@@ -67,6 +67,19 @@ private:
const CommandLineOptionPool &m_optionPool;
};
+class ResolveCommand : public Command
+{
+public:
+ ResolveCommand(CommandLineOptionPool &optionPool) : Command(optionPool) {}
+
+private:
+ CommandType type() const { return ResolveCommandType; }
+ QString shortDescription() const;
+ QString longDescription() const;
+ QString representation() const;
+ QList<CommandLineOption::Type> supportedOptions() const;
+};
+
class BuildCommand : public Command
{
public:
diff --git a/src/app/qbs/parser/commandlineparser.cpp b/src/app/qbs/parser/commandlineparser.cpp
index 1c3344f5f..0039142df 100644
--- a/src/app/qbs/parser/commandlineparser.cpp
+++ b/src/app/qbs/parser/commandlineparser.cpp
@@ -70,6 +70,8 @@ public:
void setupLogLevel();
void setupBuildOptions();
+ bool dryRun() const { return optionPool.dryRunOption()->enabled(); }
+
QString propertyName(const QString &aCommandLineName) const;
QStringList commandLine;
@@ -155,6 +157,11 @@ bool CommandLineParser::force() const
return d->optionPool.forceOption()->enabled();
}
+bool CommandLineParser::dryRun() const
+{
+ return d->dryRun();
+}
+
QStringList CommandLineParser::runArgs() const
{
Q_ASSERT(d->command->type() == RunCommandType);
@@ -296,6 +303,7 @@ Command *CommandLineParser::CommandLineParserPrivate::commandFromString(const QS
QList<Command *> CommandLineParser::CommandLineParserPrivate::allCommands() const
{
return QList<Command *>()
+ << commandPool.getCommand(ResolveCommandType)
<< commandPool.getCommand(BuildCommandType)
<< commandPool.getCommand(CleanCommandType)
<< commandPool.getCommand(RunCommandType)
@@ -392,7 +400,7 @@ void CommandLineParser::CommandLineParserPrivate::setupProjectFile()
void CommandLineParser::CommandLineParserPrivate::setupBuildOptions()
{
- buildOptions.dryRun = optionPool.dryRunOption()->enabled();
+ buildOptions.dryRun = dryRun();
buildOptions.changedFiles = optionPool.changedFilesOption()->arguments();
QDir currentDir;
for (int i = 0; i < buildOptions.changedFiles.count(); ++i) {
diff --git a/src/app/qbs/parser/commandlineparser.h b/src/app/qbs/parser/commandlineparser.h
index 0d6c4e753..2847453d2 100644
--- a/src/app/qbs/parser/commandlineparser.h
+++ b/src/app/qbs/parser/commandlineparser.h
@@ -58,6 +58,7 @@ public:
CleanOptions cleanOptions() const;
InstallOptions installOptions() const;
bool force() const;
+ bool dryRun() const;
QStringList runArgs() const;
QStringList products() const;
QList<QVariantMap> buildConfigurations() const;
diff --git a/src/app/qbs/parser/commandpool.cpp b/src/app/qbs/parser/commandpool.cpp
index 138a1eb2e..9b626124e 100644
--- a/src/app/qbs/parser/commandpool.cpp
+++ b/src/app/qbs/parser/commandpool.cpp
@@ -46,6 +46,9 @@ qbs::Command *CommandPool::getCommand(CommandType type) const
Command *& command = m_commands[type];
if (!command) {
switch (type) {
+ case ResolveCommandType:
+ command = new ResolveCommand(m_optionPool);
+ break;
case BuildCommandType:
command = new BuildCommand(m_optionPool);
break;
diff --git a/src/app/qbs/parser/commandtype.h b/src/app/qbs/parser/commandtype.h
index 4cdcd8e5f..58e5f7bbb 100644
--- a/src/app/qbs/parser/commandtype.h
+++ b/src/app/qbs/parser/commandtype.h
@@ -32,7 +32,7 @@
namespace qbs {
enum CommandType {
- BuildCommandType, CleanCommandType, RunCommandType, ShellCommandType,
+ ResolveCommandType, BuildCommandType, CleanCommandType, RunCommandType, ShellCommandType,
PropertiesCommandType, StatusCommandType, UpdateTimestampsCommandType,
InstallCommandType, HelpCommandType
};