aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/recipe.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-04-28 07:29:11 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-04-30 14:44:21 +0200
commit9498585efc6e92eabca596d2ecbb78ffb343bca2 (patch)
tree6cee37adc289643e37f7c5827490669a6e9e1dda /libbuild2/recipe.hxx
parent68cc1badd2eb96fd1f89e8b6519d45039ff983ba (diff)
Factor recipe to separate header/source files
Diffstat (limited to 'libbuild2/recipe.hxx')
-rw-r--r--libbuild2/recipe.hxx53
1 files changed, 53 insertions, 0 deletions
diff --git a/libbuild2/recipe.hxx b/libbuild2/recipe.hxx
new file mode 100644
index 0000000..508c059
--- /dev/null
+++ b/libbuild2/recipe.hxx
@@ -0,0 +1,53 @@
+// file : libbuild2/recipe.hxx -*- C++ -*-
+// license : MIT; see accompanying LICENSE file
+
+#ifndef LIBBUILD2_RECIPE_HXX
+#define LIBBUILD2_RECIPE_HXX
+
+#include <libbuild2/types.hxx>
+#include <libbuild2/forward.hxx>
+#include <libbuild2/utility.hxx>
+
+#include <libbuild2/action.hxx>
+#include <libbuild2/target-state.hxx>
+
+#include <libbuild2/export.hxx>
+
+namespace build2
+{
+ // The returned target state is normally changed or unchanged. If there is
+ // an error, then the recipe should throw failed rather than returning (this
+ // is the only exception that a recipe can throw).
+ //
+ // The return value of the recipe is used to update the target state. If it
+ // is target_state::group then the target's state is the group's state.
+ //
+ // The recipe may also return postponed in which case the target state is
+ // assumed to be unchanged (normally this means a prerequisite was postponed
+ // and while the prerequisite will be re-examined via another dependency,
+ // this target is done).
+ //
+ // Note that max size for the "small capture optimization" in std::function
+ // ranges (in pointer sizes) from 0 (GCC prior to 5) to 2 (GCC 5) to 6 (VC
+ // 14.2). With the size ranging (in bytes for 64-bit target) from 32 (GCC)
+ // to 64 (VC).
+ //
+ using recipe_function = target_state (action, const target&);
+ using recipe = function<recipe_function>;
+
+ // Commonly-used recipes.
+ //
+ // The default recipe executes the action on all the prerequisites in a
+ // loop, skipping ignored. Specifically, for actions with the "first"
+ // execution mode, it calls execute_prerequisites() while for those with
+ // "last" -- reverse_execute_prerequisites() (see <libbuild2/operation.hxx>,
+ // <libbuild2/algorithm.hxx> for details). The group recipe calls the
+ // group's recipe.
+ //
+ LIBBUILD2_SYMEXPORT extern const recipe empty_recipe;
+ LIBBUILD2_SYMEXPORT extern const recipe noop_recipe;
+ LIBBUILD2_SYMEXPORT extern const recipe default_recipe;
+ LIBBUILD2_SYMEXPORT extern const recipe group_recipe;
+}
+
+#endif // LIBBUILD2_RECIPE_HXX