diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2021-08-04 06:45:02 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2021-08-04 06:45:02 +0200 |
commit | ea57c514dc169afb3ece21ff2e4c1d2ab0c47d6a (patch) | |
tree | e71ca9c5adf25aabb7ddb6a5e887415ecbfb36c0 /libbuild2/build | |
parent | e767684a3462059852f7067a2297b1e18fdb3137 (diff) |
Take into account file-base'ness in ad hoc buildscript recipes
Diffstat (limited to 'libbuild2/build')
-rw-r--r-- | libbuild2/build/script/parser.cxx | 10 | ||||
-rw-r--r-- | libbuild2/build/script/parser.hxx | 12 | ||||
-rw-r--r-- | libbuild2/build/script/parser.test.cxx | 2 |
3 files changed, 17 insertions, 7 deletions
diff --git a/libbuild2/build/script/parser.cxx b/libbuild2/build/script/parser.cxx index b602880..43ec0d5 100644 --- a/libbuild2/build/script/parser.cxx +++ b/libbuild2/build/script/parser.cxx @@ -28,6 +28,7 @@ namespace build2 script parser:: pre_parse (const scope& bs, + const target_type& tt, const small_vector<action, 1>& as, istream& is, const path_name& pn, uint64_t line, optional<string> diag, const location& diag_loc) @@ -48,6 +49,7 @@ namespace build2 pbase_ = scope_->src_path_; + file_based_ = tt.is_a<file> (); perform_update_ = find (as.begin (), as.end (), perform_update_id) != as.end (); @@ -454,7 +456,7 @@ namespace build2 verify (); // Verify that depdb is not used for anything other than - // performing update. + // performing update on a file-based target. // assert (actions_ != nullptr); @@ -466,6 +468,10 @@ namespace build2 << ' ' << ctx.operation_table[a.operation ()]; } + if (!file_based_) + fail (l) << "'depdb' builtin can only be used for file-based " + << "targets"; + if (diag_line_) fail (diag_line_->second) << "'diag' builtin call before 'depdb' call" << @@ -1215,7 +1221,7 @@ namespace build2 void parser:: lookup_function (string&& name, const location& loc) { - if (perform_update_ && !impure_func_) + if (perform_update_ && file_based_ && !impure_func_) { const function_overloads* f (ctx.functions.find (name)); diff --git a/libbuild2/build/script/parser.hxx b/libbuild2/build/script/parser.hxx index 948c381..e744c08 100644 --- a/libbuild2/build/script/parser.hxx +++ b/libbuild2/build/script/parser.hxx @@ -46,7 +46,9 @@ namespace build2 // we will end up with mismatching diagnostics. // script - pre_parse (const scope&, const small_vector<action, 1>&, + pre_parse (const scope&, + const target_type&, + const small_vector<action, 1>&, istream&, const path_name&, uint64_t line, optional<string> diag_name, const location& diag_loc); @@ -156,9 +158,11 @@ namespace build2 script* script_; const small_vector<action, 1>* actions_; // Non-NULL during pre-parse. - // True if performing update is one of the actions. Only set for the - // pre-parse mode. + // True if this script is for file-based targets and performing update + // is one of the actions, respectively. Only set for the pre-parse + // mode. // + bool file_based_; bool perform_update_; // Current low-verbosity script diagnostics and its weight. @@ -220,7 +224,7 @@ namespace build2 lines depdb_preamble_; // Note: excludes 'depdb clear'. // If present, the first impure function called in the body of the - // script that performs update. + // script that performs update of a file-based target. // // Note that during the line pre-parsing we cannot tell if this is a // body or depdb preamble line. Thus, if we encounter an impure diff --git a/libbuild2/build/script/parser.test.cxx b/libbuild2/build/script/parser.test.cxx index c9356a8..da23564 100644 --- a/libbuild2/build/script/parser.test.cxx +++ b/libbuild2/build/script/parser.test.cxx @@ -208,7 +208,7 @@ namespace build2 parser p (ctx); path_name nm ("buildfile"); - script s (p.pre_parse (tt.base_scope (), acts, + script s (p.pre_parse (tt.base_scope (), tt.type (), acts, cin, nm, 11 /* line */, (m != mode::diag |