diff options
Diffstat (limited to 'build2/in')
-rw-r--r-- | build2/in/init.cxx | 2 | ||||
-rw-r--r-- | build2/in/rule.cxx | 11 | ||||
-rw-r--r-- | build2/in/rule.hxx | 19 |
3 files changed, 25 insertions, 7 deletions
diff --git a/build2/in/init.cxx b/build2/in/init.cxx index 337722a..a87f8b3 100644 --- a/build2/in/init.cxx +++ b/build2/in/init.cxx @@ -18,7 +18,7 @@ namespace build2 { namespace in { - static const rule rule_; + static const rule rule_ ("in", "in"); bool base_init (scope& rs, diff --git a/build2/in/rule.cxx b/build2/in/rule.cxx index de43e4d..6be2e71 100644 --- a/build2/in/rule.cxx +++ b/build2/in/rule.cxx @@ -55,7 +55,7 @@ namespace build2 // Derive the file name. // - // If this is an executable with an uspecified extension, then default + // If this is an executable with an unspecified extension, then default // to no extension (i.e., a shell script). // t.derive_path (t.is_a<exe> () ? "" : nullptr); @@ -187,7 +187,7 @@ namespace build2 // First should come the rule name/version. // - if (dd.expect ("in 1") != nullptr) + if (dd.expect (rule_id_ + " 1") != nullptr) l4 ([&]{trace << "rule mismatch forcing update of " << t;}); // Then the substitution symbol. @@ -253,6 +253,9 @@ namespace build2 // // <ln> <name> <hash> // + // Note that <name> can contain spaces (see the constraint check + // expressions in the version module). + // char* e (nullptr); uint64_t ln (strtoull (s->c_str (), &e, 10)); @@ -296,9 +299,9 @@ namespace build2 } if (verb >= 2) - text << "in " << ip << " >" << tp; + text << program_ << ' ' << ip << " >" << tp; else if (verb) - text << "in " << ip; + text << program_ << ' ' << ip; // Read and process the file, one line at a time. // diff --git a/build2/in/rule.hxx b/build2/in/rule.hxx index a68e80c..17fbaed 100644 --- a/build2/in/rule.hxx +++ b/build2/in/rule.hxx @@ -16,11 +16,24 @@ namespace build2 { // 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. + // class rule: public build2::rule { public: - rule (char symbol = '$', bool strict = true) - : symbol_ (symbol), strict_ (strict) {} + // 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; @@ -46,6 +59,8 @@ namespace build2 perform_update (action, const target&) const; protected: + const string rule_id_; + const string program_; char symbol_; bool strict_; }; |