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/module | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 build2/dist/module (limited to 'build2/dist/module') diff --git a/build2/dist/module b/build2/dist/module new file mode 100644 index 0000000..5510423 --- /dev/null +++ b/build2/dist/module @@ -0,0 +1,65 @@ +// file : build2/dist/module -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef BUILD2_DIST_MODULE +#define BUILD2_DIST_MODULE + +#include +#include + +#include +#include + +namespace build2 +{ + namespace dist + { + struct module: module_base + { + static const string name; + + const variable& var_dist_package; + + // Distribution post-processing callbacks. + // + // The last component in the pattern may contain shell wildcards. If the + // path contains a directory, then it is matched from the distribution + // root only. Otherwise, it is matched against all the files being + // distributed. For example: + // + // buildfile - every buildfile + // ./buildfile - root buildfile only + // tests/buildfile - tests/buildfile only + // + // The callback is called with the absolute path of the matching file + // after it has been copied to the distribution directory. The project's + // root scope and callback-specific data are passed along. + // + using callback_func = void (const path&, const scope&, void*); + + void + register_callback (path pattern, callback_func* f, void* data) + { + callbacks_.push_back (callback {move (pattern), f, data}); + } + + // Implementation details. + // + module (const variable& v_d_p) + : var_dist_package (v_d_p) {} + + public: + struct callback + { + const path pattern; + callback_func* function; + void* data; + }; + + vector callbacks_; + }; + } +} + +#endif // BUILD2_DIST_MODULE -- cgit v1.1