aboutsummaryrefslogtreecommitdiff
path: root/build2/cc/msvc.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-02-07 10:05:47 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-02-13 12:42:42 +0200
commitbcfcc38538af8bb896551c9e5730767807ad7a67 (patch)
tree722e71364bf6d8080ca61d8b2d02879520d90765 /build2/cc/msvc.cxx
parent7b9eb752cad04aaadc4552d0f26d307b04af1869 (diff)
Tighten code that operates during both search/match and execute
Diffstat (limited to 'build2/cc/msvc.cxx')
-rw-r--r--build2/cc/msvc.cxx40
1 files changed, 29 insertions, 11 deletions
diff --git a/build2/cc/msvc.cxx b/build2/cc/msvc.cxx
index fc2979c..86a7d38 100644
--- a/build2/cc/msvc.cxx
+++ b/build2/cc/msvc.cxx
@@ -225,7 +225,8 @@ namespace build2
const prerequisite_key& p,
otype lt,
const char* pfx,
- const char* sfx)
+ const char* sfx,
+ bool exist)
{
// Pretty similar logic to search_library().
//
@@ -267,7 +268,15 @@ namespace build2
{
// Enter the target.
//
- T& t (targets.insert<T> (d, dir_path (), name, e, trace));
+ auto p (targets.insert (T::static_type,
+ d,
+ dir_path (),
+ name,
+ e,
+ true, // Implied.
+ trace));
+ assert (!exist || !p.second);
+ T& t (static_cast<T&> (p.first));
if (t.path ().empty ())
t.path (move (f));
@@ -282,14 +291,15 @@ namespace build2
liba* common::
msvc_search_static (const process_path& ld,
const dir_path& d,
- const prerequisite_key& p) const
+ const prerequisite_key& p,
+ bool exist) const
{
liba* r (nullptr);
- auto search = [&r, &ld, &d, &p, this] (const char* pf, const char* sf)
- -> bool
+ auto search = [&r, &ld, &d, &p, exist, this] (
+ const char* pf, const char* sf) -> bool
{
- r = msvc_search_library<liba> (x, ld, d, p, otype::a, pf, sf);
+ r = msvc_search_library<liba> (x, ld, d, p, otype::a, pf, sf, exist);
return r != nullptr;
};
@@ -309,20 +319,28 @@ namespace build2
libs* common::
msvc_search_shared (const process_path& ld,
const dir_path& d,
- const prerequisite_key& p) const
+ const prerequisite_key& pk,
+ bool exist) const
{
tracer trace (x, "msvc_search_shared");
libs* r (nullptr);
- auto search = [&r, &ld, &d, &p, &trace, this] (
+ auto search = [&r, &ld, &d, &pk, &trace, exist, this] (
const char* pf, const char* sf) -> bool
{
if (libi* i =
- msvc_search_library<libi> (x, ld, d, p, otype::s, pf, sf))
+ msvc_search_library<libi> (x, ld, d, pk, otype::s, pf, sf, exist))
{
- r = &targets.insert<libs> (
- d, dir_path (), *p.tk.name, nullopt, trace);
+ auto p (targets.insert (libs::static_type,
+ d,
+ dir_path (),
+ *pk.tk.name,
+ nullopt,
+ true, // Implied.
+ trace));
+ assert (!exist || !p.second);
+ r = static_cast<libs*> (&p.first);
if (r->member == nullptr)
{