aboutsummaryrefslogtreecommitdiffstats
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
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>
-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
-rw-r--r--src/lib/api/internaljobs.cpp3
-rw-r--r--src/lib/tools/setupprojectparameters.cpp8
-rw-r--r--src/lib/tools/setupprojectparameters.h1
-rw-r--r--tests/auto/blackbox/tst_blackbox.cpp42
-rw-r--r--tests/auto/blackbox/tst_blackbox.h4
12 files changed, 127 insertions, 17 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
};
diff --git a/src/lib/api/internaljobs.cpp b/src/lib/api/internaljobs.cpp
index 453e46b40..5f11750e0 100644
--- a/src/lib/api/internaljobs.cpp
+++ b/src/lib/api/internaljobs.cpp
@@ -206,7 +206,8 @@ void InternalSetupProjectJob::execute()
m_buildProject->rescueDependencies(loadResult.loadedProject);
}
- storeBuildGraph(m_buildProject.data());
+ if (!m_parameters.dryRun)
+ storeBuildGraph(m_buildProject.data());
// The evalutation context cannot be re-used for building, which runs in a different thread.
m_buildProject->setEvaluationContext(RulesEvaluationContextPtr());
diff --git a/src/lib/tools/setupprojectparameters.cpp b/src/lib/tools/setupprojectparameters.cpp
index 97d809737..44dc6349a 100644
--- a/src/lib/tools/setupprojectparameters.cpp
+++ b/src/lib/tools/setupprojectparameters.cpp
@@ -30,7 +30,8 @@
namespace qbs {
-SetupProjectParameters::SetupProjectParameters() : ignoreDifferentProjectFilePath(false)
+SetupProjectParameters::SetupProjectParameters()
+ : ignoreDifferentProjectFilePath(false), dryRun(false)
{
}
@@ -76,4 +77,9 @@ SetupProjectParameters::SetupProjectParameters() : ignoreDifferentProjectFilePat
* is different from \c projectFilePath
*/
+ /*!
+ * \variable SetupProjectParameters::dryRun
+ * \brief true iff the build graph should not be saved
+ */
+
} // namespace qbs
diff --git a/src/lib/tools/setupprojectparameters.h b/src/lib/tools/setupprojectparameters.h
index d0b1d3047..ad9545af2 100644
--- a/src/lib/tools/setupprojectparameters.h
+++ b/src/lib/tools/setupprojectparameters.h
@@ -47,6 +47,7 @@ public:
QStringList pluginPaths;
QVariantMap buildConfiguration;
bool ignoreDifferentProjectFilePath;
+ bool dryRun;
};
} // namespace qbs
diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp
index f938981ba..937421f3e 100644
--- a/tests/auto/blackbox/tst_blackbox.cpp
+++ b/tests/auto/blackbox/tst_blackbox.cpp
@@ -242,7 +242,47 @@ void TestBlackbox::build_project_dry_run()
QCOMPARE(runQbs(QStringList() << "-n"), 0);
const QStringList &buildDirContents
= QDir(buildDir).entryList(QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs);
- QVERIFY2(buildDirContents.count() == 1, qPrintable(buildDirContents.join(" ")));
+ QVERIFY2(buildDirContents.isEmpty(), qPrintable(buildDirContents.join(" ")));
+}
+
+void TestBlackbox::resolve_project_data()
+{
+ return build_project_data();
+}
+
+void TestBlackbox::resolve_project()
+{
+ QFETCH(QString, projectSubDir);
+ QFETCH(QString, productFileName);
+ if (!projectSubDir.startsWith('/'))
+ projectSubDir.prepend('/');
+ QVERIFY2(QFile::exists(testDataDir + projectSubDir), qPrintable(testDataDir + projectSubDir));
+ QDir::setCurrent(testDataDir + projectSubDir);
+ rmDirR(buildDir);
+
+ QCOMPARE(runQbs(QStringList() << QLatin1String("resolve")), 0);
+ QVERIFY2(!QFile::exists(productFileName), qPrintable(productFileName));
+ QVERIFY(QFile::exists(buildGraphPath));
+}
+
+void TestBlackbox::resolve_project_dry_run_data()
+{
+ return resolve_project_data();
+}
+
+void TestBlackbox::resolve_project_dry_run()
+{
+ QFETCH(QString, projectSubDir);
+ QFETCH(QString, productFileName);
+ if (!projectSubDir.startsWith('/'))
+ projectSubDir.prepend('/');
+ QVERIFY2(QFile::exists(testDataDir + projectSubDir), qPrintable(testDataDir + projectSubDir));
+ QDir::setCurrent(testDataDir + projectSubDir);
+ rmDirR(buildDir);
+
+ QCOMPARE(runQbs(QStringList() << QLatin1String("resolve") << QLatin1String("-n")), 0);
+ QVERIFY2(!QFile::exists(productFileName), qPrintable(productFileName));
+ QVERIFY2(!QFile::exists(buildGraphPath), qPrintable(buildGraphPath));
}
void TestBlackbox::clean()
diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h
index 20c3c4a54..d1d32e05e 100644
--- a/tests/auto/blackbox/tst_blackbox.h
+++ b/tests/auto/blackbox/tst_blackbox.h
@@ -65,6 +65,10 @@ private slots:
void build_project();
void build_project_dry_run_data();
void build_project_dry_run();
+ void resolve_project_data();
+ void resolve_project();
+ void resolve_project_dry_run_data();
+ void resolve_project_dry_run();
void clean();
void track_qrc();
void track_qobject_change();