diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2020-06-03 08:42:26 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2020-06-03 08:42:26 +0200 |
commit | 1cc657a1ae2d496c0467a7c33257aa3cd2bfc3a8 (patch) | |
tree | 062e0eada1230ef19b0f51b2e77c00f2dd49a266 /libbuild2/rule.hxx | |
parent | bc3c8492f129d9295c9ef6c325bf2c99e88ca73e (diff) |
Add versioning for ad hoc C++ recipes
This will allow us to deal with backward-incompatible changes to cxx_rule
interface and semantics.
Diffstat (limited to 'libbuild2/rule.hxx')
-rw-r--r-- | libbuild2/rule.hxx | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/libbuild2/rule.hxx b/libbuild2/rule.hxx index 05be9eb..76ab306 100644 --- a/libbuild2/rule.hxx +++ b/libbuild2/rule.hxx @@ -209,6 +209,13 @@ namespace build2 // class LIBBUILD2_SYMEXPORT cxx_rule: public rule { + // For now this class is provided purely as an alias for rule in case the + // implementation (which is also called rule) needs to refer to something + // in its base. + }; + + class LIBBUILD2_SYMEXPORT cxx_rule_v1: public cxx_rule + { public: // A robust recipe may want to incorporate the recipe_state into its // up-to-date decision as if the recipe library was a prerequisite (it @@ -218,7 +225,7 @@ namespace build2 const location recipe_loc; // Buildfile location of the recipe. const target_state recipe_state; // State of recipe library target. - cxx_rule (const location& l, target_state s) + cxx_rule_v1 (const location& l, target_state s) : recipe_loc (l), recipe_state (s) {} // Return true by default. @@ -241,15 +248,10 @@ namespace build2 virtual void dump (ostream&, string&) const override; - adhoc_cxx_rule (const location& l, size_t b) - : adhoc_rule (l, b), impl (nullptr) {} + adhoc_cxx_rule (const location&, size_t, uint64_t version); virtual bool - recipe_text (context&, string&& t, attributes&) override - { - code = move (t); - return true; - } + recipe_text (context&, string&& t, attributes&) override; virtual ~adhoc_cxx_rule () override; @@ -258,6 +260,7 @@ namespace build2 // Note that this recipe (rule instance) can be shared between multiple // targets which could all be matched in parallel. // + uint64_t version; string code; mutable atomic<cxx_rule*> impl; }; |