aboutsummaryrefslogtreecommitdiff
path: root/bdep/sync.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-04-26 09:48:58 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-04-26 09:48:58 +0200
commite86333fa8790f624d82ecea2a8da40f85a1d3630 (patch)
tree91166f5070c5a43310faa3883030ccdf23182193 /bdep/sync.cxx
parent7839410d934bb36fdac2e4125c72febf73991320 (diff)
Add support for forwarded configurations
Diffstat (limited to 'bdep/sync.cxx')
-rw-r--r--bdep/sync.cxx78
1 files changed, 77 insertions, 1 deletions
diff --git a/bdep/sync.cxx b/bdep/sync.cxx
index 370e4f4..6c29a50 100644
--- a/bdep/sync.cxx
+++ b/bdep/sync.cxx
@@ -70,7 +70,7 @@ namespace bdep
}) != prj_pkgs.end ())
{
// The project package itself must always be upgraded to the latest
- // version/iteration. So we have to translate our option to their
+ // version/iteration. So we have to translate our options to their
// dependency-only --{upgrade,patch}-{recursive,immediate}.
//
args.push_back ("{");
@@ -119,6 +119,82 @@ namespace bdep
"--plan", "synchronizing:",
(yes ? "--yes" : nullptr),
args);
+
+
+ // Handle configuration forwarding.
+ //
+ // We do it here (instead of, say init) because a change in a package may
+ // introduce new subprojects. Though it would be nice to only do this if
+ // the package was upgraded (probably by comparing before/after versions
+ // @@ TODO: changed flag below).
+ //
+ // Also, the current thinking is that config set --[no-]forward is best
+ // implemented by just changing the flag on the configuration and then
+ // requiring an explicit sync to configure/disfigure forwards.
+ //
+ // @@ TODO: could optimize out version query/comparison if pkg-build
+ // signalled that nothing has changed (the --exit-result idea). Would
+ // be nice to optimize the whole thing. Maybe --force flag (for things
+ // like config set --no-forward)? Or maybe we should require explicit
+ // sync for certain changes (and pass --implicit or some such in hook
+ // -- after all, configuring forward of a project being bootstrapped
+ // might get tricky).
+ //
+ package_locations pls (load_packages (prj));
+
+ for (const package_state& p: c->packages)
+ {
+ // If this is a forwarded configuration, make sure forwarding is
+ // configured and is up-to-date. Otherwise, make sure it is disfigured
+ // (the config set --no-forward case).
+ //
+ dir_path src (prj);
+ {
+ auto i (find_if (pls.begin (),
+ pls.end (),
+ [&p] (const package_location& pl)
+ {
+ return p.name == pl.name;
+ }));
+
+ if (i == pls.end ())
+ fail << "package " << p.name << " is not listed in " << prj;
+
+ src /= i->path;
+ }
+
+ // We could run 'b info' and used the 'forwarded' value but this is
+ // both faster and simpler.
+ //
+ path f (src / "build" / "bootstrap" / "out-root.build");
+ bool e (exists (f));
+
+ const char* o (nullptr);
+ if (c->forward)
+ {
+ bool changed (true);
+
+ if (changed || !e)
+ o = "configure:";
+ }
+ else
+ {
+ //@@ This is broken: we will disfigure forwards to other configs.
+ // Looks like we will need to test that the forward is to this
+ // config. 'b info' here we come?
+
+ //if (e)
+ // o = "disfigure:";
+ }
+
+ if (o != nullptr)
+ {
+ dir_path out (dir_path (c->path) /= p.name);
+ string arg (src.representation () + '@' + out.representation () +
+ ",forward");
+ run_b (co, o, arg);
+ }
+ }
}
void