aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/in/rule.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-07-08 14:55:35 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-07-24 13:53:25 +0200
commit83bb02cada0b894d9134cc5489999e0f0fe8bd7c (patch)
tree1dedff27ce2b7d54bd6b0875c9125f4dafde2e80 /libbuild2/in/rule.hxx
parent1ba934bb973c234b68751ee5866365c14da4e795 (diff)
Move in build system module to separate library
Diffstat (limited to 'libbuild2/in/rule.hxx')
-rw-r--r--libbuild2/in/rule.hxx90
1 files changed, 90 insertions, 0 deletions
diff --git a/libbuild2/in/rule.hxx b/libbuild2/in/rule.hxx
new file mode 100644
index 0000000..0daf6c0
--- /dev/null
+++ b/libbuild2/in/rule.hxx
@@ -0,0 +1,90 @@
+// file : libbuild2/in/rule.hxx -*- C++ -*-
+// copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
+// license : MIT; see accompanying LICENSE file
+
+#ifndef LIBBUILD2_IN_RULE_HXX
+#define LIBBUILD2_IN_RULE_HXX
+
+#include <libbuild2/types.hxx>
+#include <libbuild2/utility.hxx>
+
+#include <libbuild2/rule.hxx>
+
+#include <libbuild2/in/export.hxx>
+
+namespace build2
+{
+ namespace in
+ {
+ // Preprocess an .in file.
+ //
+ // Note that a derived rule can use the target data pad to cache data
+ // (e.g., in match()) to be used in substitute/lookup() calls.
+ //
+ // Note also that currently this rule ignores the dry-run mode (see
+ // perform_update() for the rationale).
+ //
+ class LIBBUILD2_IN_SYMEXPORT rule: public build2::rule
+ {
+ public:
+ // The rule id is used to form the rule name/version entry in depdb. The
+ // program argument is the pseudo-program name to use in the command
+ // line diagnostics.
+ //
+ rule (string rule_id,
+ string program,
+ char symbol = '$',
+ bool strict = true)
+ : rule_id_ (move (rule_id)),
+ program_ (move (program)),
+ symbol_ (symbol),
+ strict_ (strict) {}
+
+ virtual bool
+ match (action, target&, const string&) const override;
+
+ virtual recipe
+ apply (action, target&) const override;
+
+ virtual target_state
+ perform_update (action, const target&) const;
+
+ // Customization hooks.
+ //
+
+ // Perform prerequisite search.
+ //
+ virtual prerequisite_target
+ search (action,
+ const target&,
+ const prerequisite_member&,
+ include_type) const;
+
+ // Perform variable lookup.
+ //
+ virtual string
+ lookup (const location&,
+ action,
+ const target&,
+ const string& name) const;
+
+ // Perform variable substitution. Return nullopt if it should be
+ // ignored.
+ //
+ virtual optional<string>
+ substitute (const location&,
+ action,
+ const target&,
+ const string& name,
+ bool strict) const;
+
+ protected:
+ const string rule_id_;
+ const string program_;
+ char symbol_;
+ bool strict_;
+ };
+ }
+}
+
+#endif // LIBBUILD2_IN_RULE_HXX