aboutsummaryrefslogtreecommitdiff
path: root/build/b.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-08-31 13:45:57 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-08-31 13:45:57 +0200
commit5974cab56148a18628bfb423189e016ade2d40f9 (patch)
tree472a7966d0e1c5725f0736c73812cbdeaab827dc /build/b.cxx
parent2a9d673f298b623db061ee85d397563d644c8268 (diff)
Rework scoping logic
Now the src directory is entered into the scope map and points to the same scope as out. This means that targets that are in src, not out (e.g., source files) will "see" rules, variables, etc. This becomes important when we try, for example, to install a source file (say, a header) from src: we need the rule as well as the install.* variables.
Diffstat (limited to 'build/b.cxx')
-rw-r--r--build/b.cxx66
1 files changed, 32 insertions, 34 deletions
diff --git a/build/b.cxx b/build/b.cxx
index 38a944c..d2d813a 100644
--- a/build/b.cxx
+++ b/build/b.cxx
@@ -401,7 +401,7 @@ main (int argc, char* argv[])
// as a result of one of the preceding target processing.
//
// If we know src_root, set that variable as well. This could
- // be of use to the bootstrap file (other than src-root.build,
+ // be of use to the bootstrap files (other than src-root.build,
// which, BTW, doesn't need to exist if src_root == out_root).
//
scope& rs (create_root (out_root, src_root));
@@ -410,50 +410,48 @@ main (int argc, char* argv[])
// See if the bootstrap process set/changed src_root.
//
- {
- value& v (rs.assign ("src_root"));
+ value& v (rs.assign ("src_root"));
- if (v)
- {
- // If we also have src_root specified by the user, make
- // sure they match.
- //
- const dir_path& p (as<dir_path> (v));
+ if (v)
+ {
+ // If we also have src_root specified by the user, make
+ // sure they match.
+ //
+ const dir_path& p (as<dir_path> (v));
- if (src_root.empty ())
- src_root = p;
- else if (src_root != p)
- fail << "bootstrapped src_root " << p << " does not match "
- << "specified " << src_root;
- }
- else
+ if (src_root.empty ())
+ src_root = p;
+ else if (src_root != p)
+ fail << "bootstrapped src_root " << p << " does not match "
+ << "specified " << src_root;
+ }
+ else
+ {
+ // Neither bootstrap nor the user produced src_root.
+ //
+ if (src_root.empty ())
{
- // Bootstrap didn't produce src_root.
+ // If it also wasn't explicitly specified, see if it is
+ // the same as out_root.
//
- if (src_root.empty ())
+ if (is_src_root (out_root))
+ src_root = out_root;
+ else
{
- // If it also wasn't explicitly specified, see if it is
- // the same as out_root.
+ // If not, then assume we are running from src_base
+ // and calculate src_root based on out_root/out_base.
//
- if (is_src_root (out_root))
- src_root = out_root;
- else
- {
- // If not, then assume we are running from src_base
- // and calculate src_root based on out_root/out_base.
- //
- src_base = work;
- src_root = src_base.directory (out_base.leaf (out_root));
- guessing = true;
- }
+ src_base = work;
+ src_root = src_base.directory (out_base.leaf (out_root));
+ guessing = true;
}
-
- v = src_root;
}
- rs.src_path_ = &as<dir_path> (v);
+ v = src_root;
}
+ setup_root (rs);
+
// At this stage we should have both roots and out_base figured
// out. If src_base is still undetermined, calculate it.
//