From 57b10c06925d0bdf6ffb38488ee908f085109e95 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 4 Jul 2019 19:12:15 +0300 Subject: Move config, dist, test, and install modules into library --- libbuild2/dist/module.hxx | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 libbuild2/dist/module.hxx (limited to 'libbuild2/dist/module.hxx') diff --git a/libbuild2/dist/module.hxx b/libbuild2/dist/module.hxx new file mode 100644 index 0000000..abc1400 --- /dev/null +++ b/libbuild2/dist/module.hxx @@ -0,0 +1,71 @@ +// file : libbuild2/dist/module.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2019 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef LIBBUILD2_DIST_MODULE_HXX +#define LIBBUILD2_DIST_MODULE_HXX + +#include +#include + +#include +#include + +#include + +namespace build2 +{ + namespace dist + { + struct LIBBUILD2_SYMEXPORT 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. + // + // Note that if registered, the callbacks are also called (recursively) + // in subprojects. + // + 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; + }; + using callbacks = vector; + + callbacks callbacks_; + }; + } +} + +#endif // LIBBUILD2_DIST_MODULE_HXX -- cgit v1.1