diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-09-11 13:08:53 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-09-11 13:08:53 +0200 |
commit | a7362cf29a76ef679c9a1ce74715a5d087851b91 (patch) | |
tree | b26ff0e7f59ca47e5d4f1c84f5c7ab99c2beca44 /build | |
parent | f57f97a7fde4ebe69c160530d61fcd958aac0cf3 (diff) |
Add support for unnamed projects
Sometimes (e.g., in bpkg configuration) we don't have a project name.
In fact, it is not really a project; it can never be referenced in an
import directive.
So we now have a notion of an unnamed project. Such a project should
still have the 'project' variable set first thing in bootstrap.build
but its value should be empty.
Note that we can still amalgamate such projects just liked named ones.
Diffstat (limited to 'build')
-rw-r--r-- | build/file.cxx | 22 | ||||
-rw-r--r-- | build/name.cxx | 2 |
2 files changed, 19 insertions, 5 deletions
diff --git a/build/file.cxx b/build/file.cxx index f6fdd10..8f51660 100644 --- a/build/file.cxx +++ b/build/file.cxx @@ -338,7 +338,7 @@ namespace build name = move (as<string> (v)); } - level5 ([&]{trace << "extracted project name " << name << " for " + level5 ([&]{trace << "extracted project name '" << name << "' for " << *src_root;}); return name; } @@ -379,6 +379,15 @@ namespace build // string name (find_project_name (sd, dir_path (), &src)); + // If the name is empty, then is is an unnamed project. While the + // 'project' variable stays empty, here we come up with a surrogate + // name for a key. The idea is that such a key should never conflict + // with a real project name. We ensure this by using the project's + // sub-directory and appending trailing '/' to it. + // + if (name.empty ()) + name = dir.posix_string () + '/'; + // @@ Can't use move() because we may need the values in diagnostics // below. Looks like C++17 try_emplace() is what we need. // @@ -571,9 +580,14 @@ namespace build // was specified by the user so it is most likely in our // src. // - i = v.data_.emplace ( - i, - find_project_name (out_root / d, src_root / d)); + string n (find_project_name (out_root / d, src_root / d)); + + // See find_subprojects() for details on unnamed projects. + // + if (n.empty ()) + n = d.posix_string () + '/'; + + i = v.data_.emplace (i, move (n)); i->pair = '='; ++i; diff --git a/build/name.cxx b/build/name.cxx index 4061c78..1bb8d31 100644 --- a/build/name.cxx +++ b/build/name.cxx @@ -53,7 +53,7 @@ namespace build os << n; if (n.pair != '\0') - os << n.pair; + os << n.pair; else if (i != e) os << ' '; } |