aboutsummaryrefslogtreecommitdiff
path: root/build2
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-04-29 08:58:07 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-04-29 08:58:07 +0200
commitf912a6c1090875b16792da4848c47759a38f1ef4 (patch)
treef1541ca7fcbeec048f50b956df3024155ee058b7 /build2
parentc0ff56e222b25561c39600a2787d8099d1098a10 (diff)
Fix bug in default target logic
Diffstat (limited to 'build2')
-rw-r--r--build2/parser.cxx50
-rw-r--r--build2/target.cxx46
2 files changed, 55 insertions, 41 deletions
diff --git a/build2/parser.cxx b/build2/parser.cxx
index 47eca4b..d84ebfa 100644
--- a/build2/parser.cxx
+++ b/build2/parser.cxx
@@ -4055,34 +4055,46 @@ namespace build2
// target via an alias. If there are no targets in this buildfile,
// then we don't do anything.
//
- if (default_target_ == nullptr || // No targets in this buildfile.
- targets.find (dir::static_type, // Explicit current dir target.
- scope_->out_path (),
- dir_path (), // Out tree target.
- string (),
- nullopt,
- trace) != nullptr)
+ if (default_target_ == nullptr) // No targets in this buildfile.
return;
target& dt (*default_target_);
- l5 ([&]{trace (t) << "creating current directory alias for " << dt;});
-
- // While this target is not explicitly mentioned in the buildfile, we say
- // that we behave as if it were. Thus not implied.
- //
- target& ct (
- targets.insert (dir::static_type,
+ target* ct (
+ const_cast<target*> ( // Ok (serial execution).
+ targets.find (dir::static_type, // Explicit current dir target.
scope_->out_path (),
- dir_path (),
+ dir_path (), // Out tree target.
string (),
nullopt,
- false,
- trace).first);
+ trace)));
+
+ if (ct == nullptr)
+ {
+ l5 ([&]{trace (t) << "creating current directory alias for " << dt;});
+ // While this target is not explicitly mentioned in the buildfile, we
+ // say that we behave as if it were. Thus not implied.
+ //
+ ct = &targets.insert (dir::static_type,
+ scope_->out_path (),
+ dir_path (),
+ string (),
+ nullopt,
+ false,
+ trace).first;
+ // Fall through.
+ }
+ else if (ct->implied)
+ {
+ ct->implied = false;
+ // Fall through.
+ }
+ else
+ return; // Existing and not implied.
- ct.prerequisites_state_.store (2, memory_order_relaxed);
- ct.prerequisites_.emplace_back (prerequisite (dt));
+ ct->prerequisites_state_.store (2, memory_order_relaxed);
+ ct->prerequisites_.emplace_back (prerequisite (dt));
}
void parser::
diff --git a/build2/target.cxx b/build2/target.cxx
index 1922570..f7500f7 100644
--- a/build2/target.cxx
+++ b/build2/target.cxx
@@ -819,31 +819,33 @@ namespace build2
t = search_existing_target (pk);
if (t != nullptr && !t->implied)
- return t;
-
- // Ok, no luck, switch the scope.
- //
- pair<scope&, scope*> sp (
- switch_scope (*s.rw ().root_scope (), out_base));
-
- if (sp.second != nullptr) // Ignore scopes out of any project.
+ retest = true;
+ else
{
- scope& base (sp.first);
- scope& root (*sp.second);
+ // Ok, no luck, switch the scope.
+ //
+ pair<scope&, scope*> sp (
+ switch_scope (*s.rw ().root_scope (), out_base));
- const dir_path& src_base (base.src_path ());
-
- path bf (src_base / "buildfile");
-
- if (exists (bf))
- {
- l5 ([&]{trace << "loading buildfile " << bf << " for " << pk;});
- retest = source_once (root, base, bf, root);
- }
- else if (exists (src_base))
+ if (sp.second != nullptr) // Ignore scopes out of any project.
{
- t = dir::search_implied (base, pk, trace);
- retest = (t != nullptr);
+ scope& base (sp.first);
+ scope& root (*sp.second);
+
+ const dir_path& src_base (base.src_path ());
+
+ path bf (src_base / "buildfile");
+
+ if (exists (bf))
+ {
+ l5 ([&]{trace << "loading buildfile " << bf << " for " << pk;});
+ retest = source_once (root, base, bf, root);
+ }
+ else if (exists (src_base))
+ {
+ t = dir::search_implied (base, pk, trace);
+ retest = (t != nullptr);
+ }
}
}
}