aboutsummaryrefslogtreecommitdiff
path: root/build2/dist/operation.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-04-26 15:52:15 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-04-26 15:53:23 +0200
commit8276cb927bafd338be237adbecf437e70042da99 (patch)
tree49218b58e1f50a65b58674177e6047f1ac9f6831 /build2/dist/operation.cxx
parent2fd9d3f177429b20797897360931badedbb0f0ef (diff)
Implement version module
Diffstat (limited to 'build2/dist/operation.cxx')
-rw-r--r--build2/dist/operation.cxx44
1 files changed, 39 insertions, 5 deletions
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 <build2/dist/operation>
+#include <butl/filesystem> // path_match()
+
#include <build2/file>
#include <build2/dump>
#include <build2/scope>
@@ -13,6 +15,8 @@
#include <build2/filesystem>
#include <build2/diagnostics>
+#include <build2/dist/module>
+
using namespace std;
using namespace butl;
@@ -27,7 +31,9 @@ namespace build2
// install <file> <dir>
//
- static void
+ // Return the destination file path.
+ //
+ static path
install (const process_path& cmd, const file&, const dir_path&);
// cd <root> && tar|zip ... <dir>/<pkg>.<ext> <pkg>
@@ -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> (module::name));
+
for (const void* v: files)
{
const file& t (*static_cast<const file*> (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 <file> <dir>
//
- 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