aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/rule-adhoc-buildscript.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-06-09 08:19:33 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-06-09 08:19:33 +0200
commit23cbbc7f7cdcb7721d8d1cf4e70ae58184f8cc7e (patch)
tree182c9d097535f704f7899a1de81472b7b936fd03 /libbuild2/rule-adhoc-buildscript.hxx
parentb8cffb11a45add241e4b8420ba96e116efccfbd9 (diff)
Factor ad hoc C++ and Buildscript rules into separate files
Diffstat (limited to 'libbuild2/rule-adhoc-buildscript.hxx')
-rw-r--r--libbuild2/rule-adhoc-buildscript.hxx56
1 files changed, 56 insertions, 0 deletions
diff --git a/libbuild2/rule-adhoc-buildscript.hxx b/libbuild2/rule-adhoc-buildscript.hxx
new file mode 100644
index 0000000..5f10ef4
--- /dev/null
+++ b/libbuild2/rule-adhoc-buildscript.hxx
@@ -0,0 +1,56 @@
+// file : libbuild2/rule-adhoc-buildscript.hxx -*- C++ -*-
+// license : MIT; see accompanying LICENSE file
+
+#ifndef LIBBUILD2_RULE_ADHOC_BUILDSCRIPT_HXX
+#define LIBBUILD2_RULE_ADHOC_BUILDSCRIPT_HXX
+
+#include <libbuild2/types.hxx>
+#include <libbuild2/forward.hxx>
+#include <libbuild2/utility.hxx>
+
+#include <libbuild2/rule.hxx>
+
+#include <libbuild2/build/script/script.hxx>
+
+namespace build2
+{
+ // Ad hoc buildscript rule.
+ //
+ // Note: not exported and should not be used directly (i.e., registered).
+ //
+ class adhoc_buildscript_rule: public adhoc_rule
+ {
+ public:
+ virtual bool
+ match (action, target&, const string&, optional<action>) const override;
+
+ virtual recipe
+ apply (action, target&) const override;
+
+ target_state
+ perform_update_file (action, const target&) const;
+
+ target_state
+ default_action (action, const target&) const;
+
+ adhoc_buildscript_rule (const location& l, size_t b)
+ : adhoc_rule ("<ad hoc buildscript recipe>", l, b) {}
+
+ virtual bool
+ recipe_text (context&, const target&, string&&, attributes&) override;
+
+ virtual void
+ dump_attributes (ostream&) const override;
+
+ virtual void
+ dump_text (ostream&, string&) const override;
+
+ public:
+ using script_type = build::script::script;
+
+ script_type script;
+ string checksum; // Script text hash.
+ };
+}
+
+#endif // LIBBUILD2_RULE_ADHOC_BUILDSCRIPT_HXX