aboutsummaryrefslogtreecommitdiff
path: root/build2/dist/operation.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-09-06 18:24:03 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-09-06 18:24:03 +0200
commit2f1988e89e07437be4d76a39242cde7ab13cf946 (patch)
tree0f9f529046e61df018ffad34cff30485607c5d98 /build2/dist/operation.cxx
parent6f7340c123185c14c204470795e41a6cfb15d819 (diff)
Call dist callback in subprojects
This fixes a bug with no updating manifest versions in build2-toolchain subprojects.
Diffstat (limited to 'build2/dist/operation.cxx')
-rw-r--r--build2/dist/operation.cxx38
1 files changed, 30 insertions, 8 deletions
diff --git a/build2/dist/operation.cxx b/build2/dist/operation.cxx
index cdc0b6d..01339b4 100644
--- a/build2/dist/operation.cxx
+++ b/build2/dist/operation.cxx
@@ -303,18 +303,39 @@ namespace build2
// Figure out where this file is inside the target directory.
//
bool src (t.dir.sub (src_root));
+ dir_path dl (src ? t.dir.leaf (src_root) : t.dir.leaf (out_root));
- dir_path d (td);
- d /= src
- ? t.dir.leaf (src_root)
- : t.dir.leaf (out_root);
-
+ dir_path d (td / dl);
if (!exists (d))
install (dist_cmd, d);
path r (install (dist_cmd, t, d));
- for (module::callback cb: mod.callbacks_)
+ // See if this file is in a subproject.
+ //
+ const scope* srs (rs);
+ const module::callbacks* cbs (&mod.callbacks_);
+
+ if (auto l = rs->vars[var_subprojects])
+ {
+ for (auto p: cast<subprojects> (l))
+ {
+ const dir_path& pd (p.second);
+ if (dl.sub (pd))
+ {
+ srs = &scopes.find (out_root / pd);
+
+ if (auto* m = srs->modules.lookup<module> (module::name))
+ cbs = &m->callbacks_;
+ else
+ fail << "dist module not loaded in subproject " << pd;
+
+ break;
+ }
+ }
+ }
+
+ for (module::callback cb: *cbs)
{
const path& pat (cb.pattern);
@@ -325,7 +346,8 @@ namespace build2
{
assert (pat.relative ());
- dir_path d ((src ? src_root : out_root) / pat.directory ());
+ dir_path d ((src ? srs->src_path () : srs->out_path ()) /
+ pat.directory ());
d.normalize ();
if (d != t.dir)
@@ -333,7 +355,7 @@ namespace build2
}
if (path_match (pat.leaf ().string (), t.path ().leaf ().string ()))
- cb.function (r, *rs, cb.data);
+ cb.function (r, *srs, cb.data);
}
}