From f93038fbee1631b95922b0742e0fd00fa8dae02e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 27 Jan 2017 15:25:26 +0200 Subject: Add notion of phase, enforce --- build2/target.cxx | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) (limited to 'build2/target.cxx') diff --git a/build2/target.cxx b/build2/target.cxx index 81d613f..24bd246 100644 --- a/build2/target.cxx +++ b/build2/target.cxx @@ -625,36 +625,41 @@ namespace build2 // target_set). Also, a buildfile could load from a directory that is // not a subdirectory of out_base. So for now we just assume that this // is so. And so it is. - - // Relock for exclusive access. // - rlock rl (model_lock); - - pair sp (switch_scope (*s.root_scope (), out_base)); - - if (sp.second != nullptr) // Ignore scopes out of any project. + bool retest (false); { - scope& base (sp.first); - scope& root (*sp.second); + // Relock for exclusive access and change to the load phase. + // + rlock rl (model_lock); + phase_guard pg (run_phase::load); - path bf (base.src_path () / "buildfile"); + pair sp (switch_scope (*s.root_scope (), out_base)); - if (exists (bf)) + if (sp.second != nullptr) // Ignore scopes out of any project. { - l5 ([&]{trace << "loading buildfile " << bf << " for " << pk;}); + scope& base (sp.first); + scope& root (*sp.second); - if (source_once (root, base, bf, root)) - { - // If we loaded the buildfile, examine the target again. - // - if (t == nullptr) - t = search_existing_target (pk); + path bf (base.src_path () / "buildfile"); - if (t != nullptr && !t->implied) - return t; + if (exists (bf)) + { + l5 ([&]{trace << "loading buildfile " << bf << " for " << pk;}); + retest = source_once (root, base, bf, root); } } } + + // If we loaded the buildfile, examine the target again. + // + if (retest) + { + if (t == nullptr) + t = search_existing_target (pk); + + if (t != nullptr && !t->implied) + return t; + } } fail << "no explicit target for prerequisite " << pk << -- cgit v1.1