diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2018-06-28 09:44:15 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2018-06-28 09:44:15 +0200 |
commit | 3cc5e3bd441fc9d18fece3d9e99fae75c78438e7 (patch) | |
tree | a9a08c453370847e0d352d47e19fbfcb7cc757ef /build2/prerequisite.hxx | |
parent | c0f72d47fc25981dcc1f55e12dfa0fdba7b70242 (diff) |
Implement support for excluded and ad hoc prerequisites
The inclusion/exclusion is controlled via the 'include' prerequisite-specific
variable. Valid values are:
false - exclude
true - include
adhoc - include but treat as an ad hoc input
For example:
lib{foo}: cxx{win32-utility}: include = ($cxx.targe.class == 'windows')
exe{bar}: libs{plugin}: include = adhoc
Diffstat (limited to 'build2/prerequisite.hxx')
-rw-r--r-- | build2/prerequisite.hxx | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/build2/prerequisite.hxx b/build2/prerequisite.hxx index eb9f3b3..6ae6ec7 100644 --- a/build2/prerequisite.hxx +++ b/build2/prerequisite.hxx @@ -5,11 +5,10 @@ #ifndef BUILD2_PREREQUISITE_HXX #define BUILD2_PREREQUISITE_HXX -#include <unordered_set> - #include <build2/types.hxx> #include <build2/utility.hxx> +#include <build2/action.hxx> #include <build2/variable.hxx> #include <build2/target-key.hxx> #include <build2/diagnostics.hxx> @@ -182,6 +181,38 @@ namespace build2 } using prerequisites = vector<prerequisite>; + + // Helpers for dealing with the prerequisite inclusion/exclusion (the + // 'include' buildfile variable, see var_include in context.hxx). + // + // Note that the include(prerequisite_member) overload is also provided. + // + // @@ Maybe this filtering should be incorporated into *_prerequisites() and + // *_prerequisite_members() logic? Could make normal > adhoc > excluded and + // then pass the "threshold". + // + class include_type + { + public: + enum value {excluded, adhoc, normal}; + + include_type (value v): v_ (v) {} + include_type (bool v): v_ (v ? normal : excluded) {} + + operator value () const {return v_;} + explicit operator bool () const {return v_ != excluded;} + + private: + value v_; + }; + + include_type + include (action, + const target&, + const prerequisite&, + const target* = nullptr); } +#include <build2/prerequisite.ixx> + #endif // BUILD2_PREREQUISITE_HXX |