From c2b4305349ca855c497904282db354de56c74842 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 7 Aug 2018 14:59:07 +0200 Subject: Add support for default extension specification, trailing dot escaping For example: cxx{*}: extension = cxx cxx{foo} # foo.cxx cxx{foo.test} # foo.test (probably what we want...) cxx{foo.test...} # foo.test.cxx (... is this) cxx{foo..} # foo. cxx{foo....} # foo.. cxx{foo.....} # error (must come in escape pair) --- build2/b.cxx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'build2/b.cxx') diff --git a/build2/b.cxx b/build2/b.cxx index de4ee0c..aedda7f 100644 --- a/build2/b.cxx +++ b/build2/b.cxx @@ -694,8 +694,9 @@ main (int argc, char* argv[]) const string& v (tn.value); // Handle a few common cases as special: empty name, '.', '..', as - // well as dir{foo/bar} (without trailing '/'). This code must be - // consistent with find_target_type() and other places. + // well as dir{foo/bar} (without trailing '/'). This logic must be + // consistent with find_target_type() and other places (grep for + // ".."). // if (v.empty () || v == "." || v == ".." || tn.type == "dir") out_base = dir_path (v); @@ -1274,10 +1275,11 @@ main (int argc, char* argv[]) // Find the target type and extract the extension. // - optional e; - const target_type* ti (bs.find_target_type (tn, e, l)); + auto rp (bs.find_target_type (tn, l)); + const target_type* tt (rp.first); + optional& e (rp.second); - if (ti == nullptr) + if (tt == nullptr) fail (l) << "unknown target type " << tn.type; if (mif->search != nullptr) @@ -1303,7 +1305,7 @@ main (int argc, char* argv[]) mif->search (mparams, rs, bs, - target_key {ti, &d, &out, &tn.value, e}, + target_key {tt, &d, &out, &tn.value, e}, l, tgs); } -- cgit v1.1