aboutsummaryrefslogtreecommitdiff
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
parent6f7340c123185c14c204470795e41a6cfb15d819 (diff)
Call dist callback in subprojects
This fixes a bug with no updating manifest versions in build2-toolchain subprojects.
-rw-r--r--build2/dist/module.hxx6
-rw-r--r--build2/dist/operation.cxx38
-rw-r--r--build2/file.cxx1
3 files changed, 35 insertions, 10 deletions
diff --git a/build2/dist/module.hxx b/build2/dist/module.hxx
index e6eb975..b66ca73 100644
--- a/build2/dist/module.hxx
+++ b/build2/dist/module.hxx
@@ -36,6 +36,9 @@ namespace build2
// after it has been copied to the distribution directory. The project's
// root scope and callback-specific data are passed along.
//
+ // Note that if registered, the callbacks are also called (recursively)
+ // in subprojects.
+ //
using callback_func = void (const path&, const scope&, void*);
void
@@ -56,8 +59,9 @@ namespace build2
callback_func* function;
void* data;
};
+ using callbacks = vector<callback>;
- vector<callback> callbacks_;
+ callbacks callbacks_;
};
}
}
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);
}
}
diff --git a/build2/file.cxx b/build2/file.cxx
index 89120d3..8a0f2dc 100644
--- a/build2/file.cxx
+++ b/build2/file.cxx
@@ -407,7 +407,6 @@ namespace build2
// Scan the specified directory for any subprojects. If a subdirectory
// is a subproject, then enter it into the map, handling the duplicates.
- // Otherwise, scan the subdirectory recursively.
//
static void
find_subprojects (scope& s,