aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bdep/build.txx2
-rw-r--r--bdep/config.cli3
-rw-r--r--bdep/config.cxx34
-rw-r--r--bdep/deinit.cxx2
-rw-r--r--bdep/fetch.cxx2
-rw-r--r--bdep/init.cxx2
-rw-r--r--bdep/project.cxx33
-rw-r--r--bdep/project.hxx11
-rw-r--r--bdep/status.cxx2
-rw-r--r--bdep/sync.cxx2
10 files changed, 70 insertions, 23 deletions
diff --git a/bdep/build.txx b/bdep/build.txx
index 8c5bc65..804d590 100644
--- a/bdep/build.txx
+++ b/bdep/build.txx
@@ -48,7 +48,7 @@ namespace bdep
database db (open (prj, trace));
transaction t (db.begin ());
- configurations cfgs (find_configurations (prj, t, o));
+ configurations cfgs (find_configurations (o, prj, t));
t.commit ();
// If specified, verify packages are present in each configuration.
diff --git a/bdep/config.cli b/bdep/config.cli
index cf95175..20f2a1f 100644
--- a/bdep/config.cli
+++ b/bdep/config.cli
@@ -110,7 +110,8 @@ namespace bdep
\li|\cb{remove}
The \cb{remove} subcommand removes one or more build configurations
- from the project's build configuration set. See
+ from the project's build configuration set. Note that only
+ configurations that have no initialized packages can be removed. See
\l{bdep-projects-configs(1)} for various ways to specify build
configurations.|
diff --git a/bdep/config.cxx b/bdep/config.cxx
index 796f534..8193140 100644
--- a/bdep/config.cxx
+++ b/bdep/config.cxx
@@ -287,9 +287,39 @@ namespace bdep
}
static int
- cmd_config_remove (const cmd_config_options&, cli::scanner&)
+ cmd_config_remove (const cmd_config_options& o, cli::scanner&)
{
- fail << "@@ TODO" << endf;
+ tracer trace ("config_remove");
+
+ dir_path prj (find_project (o));
+ database db (open (prj, trace));
+
+ transaction t (db.begin ());
+
+ configurations cfgs (
+ find_configurations (o,
+ prj,
+ t,
+ false /* fallback_default */,
+ false /* validate */));
+
+ for (const shared_ptr<configuration>& c: cfgs)
+ {
+ if (!c->packages.empty ())
+ fail << "configuration " << *c << " contains initialized packages" <<
+ info << "use deinit command to deinitialize packages" <<
+ info << "use status command to list initialized packages";
+
+ db.erase (c);
+ }
+
+ t.commit ();
+
+ if (verb)
+ for (const shared_ptr<configuration>& c: cfgs)
+ text << "removed configuration " << *c;
+
+ return 0;
}
static int
diff --git a/bdep/deinit.cxx b/bdep/deinit.cxx
index 434fdee..2264d79 100644
--- a/bdep/deinit.cxx
+++ b/bdep/deinit.cxx
@@ -106,7 +106,7 @@ namespace bdep
database db (open (prj, trace));
transaction t (db.begin ());
- configurations cfgs (find_configurations (prj, t, o));
+ configurations cfgs (find_configurations (o, prj, t));
t.commit ();
// If specified, verify packages are present in each configuration.
diff --git a/bdep/fetch.cxx b/bdep/fetch.cxx
index 487292d..dda9793 100644
--- a/bdep/fetch.cxx
+++ b/bdep/fetch.cxx
@@ -36,7 +36,7 @@ namespace bdep
database db (open (prj, trace));
transaction t (db.begin ());
- configurations cfgs (find_configurations (prj, t, o));
+ configurations cfgs (find_configurations (o, prj, t));
t.commit ();
bool first (true);
diff --git a/bdep/init.cxx b/bdep/init.cxx
index 1adeb9a..5534575 100644
--- a/bdep/init.cxx
+++ b/bdep/init.cxx
@@ -197,7 +197,7 @@ namespace bdep
// wants us to use.
//
transaction t (db.begin ());
- cfgs = find_configurations (prj, t, o);
+ cfgs = find_configurations (o, prj, t);
t.commit ();
}
}
diff --git a/bdep/project.cxx b/bdep/project.cxx
index b3b76b3..dacb921 100644
--- a/bdep/project.cxx
+++ b/bdep/project.cxx
@@ -15,9 +15,11 @@ using namespace std;
namespace bdep
{
configurations
- find_configurations (const dir_path& prj,
+ find_configurations (const project_options& po,
+ const dir_path& prj,
transaction& t,
- const project_options& po)
+ bool fallback_default,
+ bool validate)
{
configurations r;
@@ -85,26 +87,37 @@ namespace bdep
{
for (auto c: pointer_result (db.query<configuration> ()))
add (c);
+
+ if (r.empty ())
+ fail << "no existing configurations";
}
// default
//
if (r.empty ())
{
- if (auto c = db.query_one<configuration> (query::default_))
- add (c);
+ if (fallback_default)
+ {
+ if (auto c = db.query_one<configuration> (query::default_))
+ add (c);
+ else
+ fail << "no default configuration in project " << prj <<
+ info << "use (@<cfg-name> | --config|-c <cfg-dir> | --all|-a) to "
+ << "specify configuration explicitly";
+ }
else
- fail << "no default configuration in project " << prj <<
- info << "use (@<cfg-name> | --config|-c <cfg-dir> | --all|-a) to "
- << "specify configuration explicitly";
+ fail << "no configurations specified";
}
// Validate all the returned configuration directories are still there.
//
- for (const shared_ptr<configuration>& c: r)
+ if (validate)
{
- if (!exists (c->path))
- fail << "configuration directory " << c->path << " no longer exists";
+ for (const shared_ptr<configuration>& c: r)
+ {
+ if (!exists (c->path))
+ fail << "configuration directory " << c->path << " no longer exists";
+ }
}
return r;
diff --git a/bdep/project.hxx b/bdep/project.hxx
index a01e5d7..2fc4fec 100644
--- a/bdep/project.hxx
+++ b/bdep/project.hxx
@@ -134,15 +134,18 @@ namespace bdep
};
// Given the project directory, database, and options resolve all the
- // mentioned configurations or find the default configuration if none were
- // mentioned.
+ // mentioned configurations or, unless fallback_default is false, find the
+ // default configuration if none were mentioned. Unless validate is false,
+ // also validate that the configuration directories still exist.
//
using configurations = vector<shared_ptr<configuration>>;
configurations
- find_configurations (const dir_path& prj,
+ find_configurations (const project_options&,
+ const dir_path& prj,
transaction&,
- const project_options&);
+ bool fallback_default = true,
+ bool validate = true);
// Given the project options (and CWD) locate the packages and their
// project. The result is an absolute and normalized project directory and a
diff --git a/bdep/status.cxx b/bdep/status.cxx
index d0f7aba..c9f62d0 100644
--- a/bdep/status.cxx
+++ b/bdep/status.cxx
@@ -105,7 +105,7 @@ namespace bdep
database db (open (prj, trace));
transaction t (db.begin ());
- configurations cfgs (find_configurations (prj, t, o));
+ configurations cfgs (find_configurations (o, prj, t));
t.commit ();
// If specified, verify packages are present in each configuration.
diff --git a/bdep/sync.cxx b/bdep/sync.cxx
index a10e877..b1589ad 100644
--- a/bdep/sync.cxx
+++ b/bdep/sync.cxx
@@ -662,7 +662,7 @@ namespace bdep
database db (open (pp.project, trace));
transaction t (db.begin ());
- cfgs = find_configurations (pp.project, t, o);
+ cfgs = find_configurations (o, pp.project, t);
t.commit ();
}