From 4be404cd8b7f4c7b450364defea92cd02e9b7a62 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 21 Jul 2015 15:51:54 +0200 Subject: Improve nested operations support The idea is this: we need to be able to override "conditional, inner for outer" recipes with the "unconditional inner" ones. Here is the concrete scenario: we have {update, test} action and the lib{} target that is both mentioned as a prerequisite of ./ and exe{}, which is a test. At first, we want to ignore lib{} when reached as a prerequisite of ./. But then we get to it via exe{} (which is a test and thus should be updated). At this point we should override the recipe for lib{} with the one that would update it rather than ignore. --- build/operation | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'build/operation') diff --git a/build/operation b/build/operation index 75d6526..6fde9fd 100644 --- a/build/operation +++ b/build/operation @@ -79,6 +79,19 @@ namespace build action_id outer_id; }; + // This is an "overrides" comparison, i.e., it returns true + // if the recipe for x overrides recipe for y. The idea is + // that for the same inner operation, action with an outer + // operation is "weaker" than the one without. + // + inline bool + operator> (action x, action y) + { + return x.inner_id != y.inner_id || + (x.outer_id != y.outer_id && y.outer_id != 0); + } + + /* inline bool operator== (action x, action y) { @@ -87,6 +100,7 @@ namespace build inline bool operator!= (action x, action y) {return !(x == y);} + */ std::ostream& operator<< (std::ostream&, action); -- cgit v1.1