From 53f02bf28dae507a51515ed6ac03226d68816494 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 2 Feb 2017 10:20:50 +0200 Subject: Store extension in target map key rather than in target This is in preparation for locking its modification/access. --- build2/cli/rule.cxx | 11 +++++++---- build2/cli/target | 4 ++-- build2/cli/target.cxx | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) (limited to 'build2/cli') diff --git a/build2/cli/rule.cxx b/build2/cli/rule.cxx index 773d00c..262e89a 100644 --- a/build2/cli/rule.cxx +++ b/build2/cli/rule.cxx @@ -211,17 +211,20 @@ namespace build2 const char* option, const char* default_extension) { - assert (t.ext); // Should have been figured out in apply(). + // Should have been figured out in apply(). + // + const optional& e (*t.ext_); + assert (e); - if (*t.ext != default_extension) + if (*e != default_extension) { // CLI needs the extension with the leading dot (unless it is empty) // while we store the extension without. But if there is an extension, // then we can get it (with the dot) from the file name. // args.push_back (option); - args.push_back (t.ext->empty () - ? t.ext->c_str () + args.push_back (e->empty () + ? e->c_str () : t.path ().extension_cstring () - 1); } } diff --git a/build2/cli/target b/build2/cli/target index 0cc448d..f4ab7e7 100644 --- a/build2/cli/target +++ b/build2/cli/target @@ -49,8 +49,8 @@ namespace build2 //using mtime_target::mtime_target; // @@ GCC 4.8 - cli_cxx (dir_path d, dir_path o, string n, optional e) - : mtime_target (move (d), move (o), move (n), move (e)) + cli_cxx (dir_path d, dir_path o, string n) + : mtime_target (move (d), move (o), move (n)) { m[0] = m[1] = m[2] = nullptr; } diff --git a/build2/cli/target.cxx b/build2/cli/target.cxx index 3f09d30..48dc95b 100644 --- a/build2/cli/target.cxx +++ b/build2/cli/target.cxx @@ -48,7 +48,7 @@ namespace build2 return file_mtime (h->path ()); } - static target* + static pair> cli_cxx_factory (const target_type&, dir_path d, dir_path o, @@ -66,7 +66,7 @@ namespace build2 targets.insert (d, o, n, trace); targets.insert (d, o, n, trace); - return new cli_cxx (move (d), move (o), move (n), move (e)); + return make_pair (new cli_cxx (move (d), move (o), move (n)), move (e)); } const target_type cli_cxx::static_type -- cgit v1.1