aboutsummaryrefslogtreecommitdiff
path: root/bdep/init.cxx
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 /bdep/init.cxx
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).
Diffstat (limited to 'bdep/init.cxx')
-rw-r--r--bdep/init.cxx21
1 files changed, 13 insertions, 8 deletions
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;
}