aboutsummaryrefslogtreecommitdiff
path: root/build/parser.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-07-07 13:00:45 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-07-07 13:49:16 +0200
commit402bb6e6b297614226c4f848ebdb13fd49a95d76 (patch)
tree0a8a59e2bf1b7c0d6d7efb1dcf7e9bee1bea76cc /build/parser.cxx
parent49d5628e35593a5300d39596286c768d7aa435b6 (diff)
Relax requirement on amalgamation src_root to track sub-project
Diffstat (limited to 'build/parser.cxx')
-rw-r--r--build/parser.cxx64
1 files changed, 32 insertions, 32 deletions
diff --git a/build/parser.cxx b/build/parser.cxx
index 59e3783..e051124 100644
--- a/build/parser.cxx
+++ b/build/parser.cxx
@@ -521,56 +521,56 @@ namespace build
p /= path ("buildfile");
}
- bool in_out (false);
- if (p.absolute ())
+ // Determine new out_base.
+ //
+ dir_path out_base;
+
+ if (p.relative ())
+ {
+ out_base = scope_->path () / p.directory ();
+ out_base.normalize ();
+ }
+ else
{
p.normalize ();
// Make sure the path is in this project. Include is only meant
- // to be used for intra-project inclusion.
+ // to be used for intra-project inclusion (plus amalgamation).
//
+ bool in_out (false);
if (!p.sub (*src_root_) && !(in_out = p.sub (*out_root_)))
fail (l) << "out of project include " << p;
- }
- else
- {
- // Use the src directory corresponding to the current directory scope.
- //
- p = src_out (scope_->path (), *out_root_, *src_root_) / p;
- p.normalize ();
- }
- if (!root_->buildfiles.insert (p).second)
- {
- level4 ([&]{trace (l) << "skipping already included " << p;});
- continue;
- }
-
- // Determine new bases.
- //
- dir_path out_base;
- dir_path src_base;
-
- if (in_out)
- {
- out_base = p.directory ();
- src_base = src_out (out_base, *out_root_, *src_root_);
- }
- else
- {
- src_base = p.directory ();
- out_base = out_src (src_base, *out_root_, *src_root_);
+ out_base = in_out
+ ? p.directory ()
+ : out_src (p.directory (), *out_root_, *src_root_);
}
// Create and bootstrap root scope(s) of subproject(s) that
// this out_base belongs to. If any were created, load them
- // and update parser state.
+ // and update parser state. Note that we need to do this
+ // before figuring out absolute buildfile path since we may
+ // switch the project root (i.e., include into a sub-project).
//
scope* ors (switch_root (&create_bootstrap_inner (*root_, out_base)));
if (root_ != ors)
load_root_pre (*root_); // Loads outer roots recursively.
+ // Determine src_base and buildfile, if relative.
+ //
+ dir_path src_base (src_out (out_base, *out_root_, *src_root_));
+
+ if (p.relative ())
+ p = src_base / p.leaf ();
+
+ if (!root_->buildfiles.insert (p).second) // Note: may be "new" root.
+ {
+ level4 ([&]{trace (l) << "skipping already included " << p;});
+ switch_root (ors); // Restore old root.
+ continue;
+ }
+
ifstream ifs (p.string ());
if (!ifs.is_open ())