From 8276cb927bafd338be237adbecf437e70042da99 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 26 Apr 2017 15:52:15 +0200 Subject: Implement version module --- build2/dist/operation.cxx | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) (limited to 'build2/dist/operation.cxx') diff --git a/build2/dist/operation.cxx b/build2/dist/operation.cxx index 033748e..859225d 100644 --- a/build2/dist/operation.cxx +++ b/build2/dist/operation.cxx @@ -4,6 +4,8 @@ #include +#include // path_match() + #include #include #include @@ -13,6 +15,8 @@ #include #include +#include + using namespace std; using namespace butl; @@ -27,7 +31,9 @@ namespace build2 // install // - static void + // Return the destination file path. + // + static path install (const process_path& cmd, const file&, const dir_path&); // cd && tar|zip ... /. @@ -286,23 +292,49 @@ namespace build2 install (dist_cmd, td); - // Copy over all the files. + // Copy over all the files. Apply post-processing callbacks. // + module& mod (*rs->modules.lookup (module::name)); + for (const void* v: files) { const file& t (*static_cast (v)); // Figure out where this file is inside the target directory. // + bool src (t.dir.sub (src_root)); + dir_path d (td); - d /= t.dir.sub (src_root) + d /= src ? t.dir.leaf (src_root) : t.dir.leaf (out_root); if (!exists (d)) install (dist_cmd, d); - install (dist_cmd, t, d); + path r (install (dist_cmd, t, d)); + + for (module::callback cb: mod.callbacks_) + { + const path& pat (cb.pattern); + + // If we have a directory, then it should be relative to the project + // root. + // + if (!pat.simple ()) + { + assert (pat.relative ()); + + dir_path d ((src ? src_root : out_root) / pat.directory ()); + d.normalize (); + + if (d != t.dir) + continue; + } + + if (path_match (pat.leaf ().string (), t.path ().leaf ().string ())) + cb.function (r, *rs, cb.data); + } } // Archive if requested. @@ -367,7 +399,7 @@ namespace build2 // install // - static void + static path install (const process_path& cmd, const file& t, const dir_path& d) { dir_path reld (relative (d)); @@ -417,6 +449,8 @@ namespace build2 throw failed (); } + + return d / relf.leaf (); } static void -- cgit v1.1