aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-10-24 16:02:58 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-10-24 16:02:58 +0200
commitb7f2331713003e479388d9decc4621e3ee77f716 (patch)
treebf95cbf2a515db82026a7ff724c5baa258bfd1ff
parentf96f707ae4598e2ecc616a6e2aa47ace943c7eb5 (diff)
Add --no-sync option to bdep-init
This allows postponing initialization in the build configurations to a later explicit bdep-sync. One subtle difference with such an explicit sync is that it will be performed without having the project database open, which can be important if our initialization triggers an implicit sync (via a hook) of a project that uses the same database (as is the case with build system module projects).
-rw-r--r--bdep/init.cli7
-rw-r--r--bdep/init.cxx21
-rw-r--r--bdep/init.hxx6
3 files changed, 24 insertions, 10 deletions
diff --git a/bdep/init.cli b/bdep/init.cli
index cb9c9f8..5071913 100644
--- a/bdep/init.cli
+++ b/bdep/init.cli
@@ -166,5 +166,12 @@ namespace bdep
"<dir>",
"Create a new build configuration in <dir>."
}
+
+ bool --no-sync
+ {
+ "Enter the project into the database but do not initialize it in the
+ build configurations. The initialization can be finished later with
+ an explicit \l{bdep-sync(1)} command."
+ }
};
}
diff --git a/bdep/init.cxx b/bdep/init.cxx
index 1e794f8..86f570f 100644
--- a/bdep/init.cxx
+++ b/bdep/init.cxx
@@ -48,7 +48,8 @@ namespace bdep
database& db,
const configurations& cfgs,
const package_locations& pkgs,
- const strings& pkg_args)
+ const strings& pkg_args,
+ bool sync)
{
// We do each configuration in a separate transaction so that our state
// reflects the bpkg configuration as closely as possible.
@@ -121,10 +122,11 @@ namespace bdep
}
}
- // If we are initializing multiple packages, print their names.
+ // If we are initializing multiple packages or there will be no sync,
+ // print their names.
//
- if (verb && pkgs.size () > 1)
- text << "initializing package " << p.name;
+ if (verb && (pkgs.size () > 1 || !sync))
+ text << "initializing package " << p.name;;
c->packages.push_back (package_state {p.name});
}
@@ -146,7 +148,8 @@ namespace bdep
//
// Note: semantically equivalent to the first form of the sync command.
//
- cmd_sync (o, prj, c, pkg_args, false /* implicit */);
+ if (sync)
+ cmd_sync (o, prj, c, pkg_args, false /* implicit */);
db.update (c);
t.commit ();
@@ -163,8 +166,9 @@ namespace bdep
if (o.empty ())
{
- if (ca) fail << "both --empty and --config-add specified";
- if (cc) fail << "both --empty and --config-create specified";
+ if (ca) fail << "both --empty and --config-add specified";
+ if (cc) fail << "both --empty and --config-create specified";
+ if (o.no_sync ()) fail << "both --empty and --no-sync specified";
}
if (const char* n = cmd_config_validate_add (o))
@@ -265,7 +269,8 @@ namespace bdep
db,
cfgs,
pp.packages,
- scan_arguments (args) /* pkg_args */);
+ scan_arguments (args) /* pkg_args */,
+ !o.no_sync ());
return 0;
}
diff --git a/bdep/init.hxx b/bdep/init.hxx
index 8569f91..0aec927 100644
--- a/bdep/init.hxx
+++ b/bdep/init.hxx
@@ -27,7 +27,8 @@ namespace bdep
bool config_create_specified);
// Initialize each package in each configuration skipping those that are
- // already initialized. Then synchronize each configuration.
+ // already initialized. Then synchronize each configuration unless sync
+ // is false.
//
void
cmd_init (const common_options&,
@@ -35,7 +36,8 @@ namespace bdep
database&,
const configurations&,
const package_locations&,
- const strings& pkg_args);
+ const strings& pkg_args,
+ bool sync = true);
int
cmd_init (const cmd_init_options&, cli::group_scanner& args);