aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build/file.cxx22
-rw-r--r--build/name.cxx2
-rw-r--r--tests/amalgam/unnamed/build/bootstrap.build3
-rw-r--r--tests/amalgam/unnamed/buildfile3
-rw-r--r--tests/amalgam/unnamed/sub/build/bootstrap.build2
-rw-r--r--tests/amalgam/unnamed/sub/buildfile2
-rw-r--r--tests/amalgam/unnamed/test.out2
-rwxr-xr-xtests/amalgam/unnamed/test.sh3
8 files changed, 34 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 << ' ';
}
diff --git a/tests/amalgam/unnamed/build/bootstrap.build b/tests/amalgam/unnamed/build/bootstrap.build
new file mode 100644
index 0000000..30065f4
--- /dev/null
+++ b/tests/amalgam/unnamed/build/bootstrap.build
@@ -0,0 +1,3 @@
+project = amalgam-unnamed
+amalgamation = # Disabled.
+using config
diff --git a/tests/amalgam/unnamed/buildfile b/tests/amalgam/unnamed/buildfile
new file mode 100644
index 0000000..5aa12c3
--- /dev/null
+++ b/tests/amalgam/unnamed/buildfile
@@ -0,0 +1,3 @@
+.: sub/
+include sub/
+print $subprojects
diff --git a/tests/amalgam/unnamed/sub/build/bootstrap.build b/tests/amalgam/unnamed/sub/build/bootstrap.build
new file mode 100644
index 0000000..ce3735a
--- /dev/null
+++ b/tests/amalgam/unnamed/sub/build/bootstrap.build
@@ -0,0 +1,2 @@
+project =
+using config
diff --git a/tests/amalgam/unnamed/sub/buildfile b/tests/amalgam/unnamed/sub/buildfile
new file mode 100644
index 0000000..8717375
--- /dev/null
+++ b/tests/amalgam/unnamed/sub/buildfile
@@ -0,0 +1,2 @@
+./:
+print "'$project'"
diff --git a/tests/amalgam/unnamed/test.out b/tests/amalgam/unnamed/test.out
new file mode 100644
index 0000000..1738349
--- /dev/null
+++ b/tests/amalgam/unnamed/test.out
@@ -0,0 +1,2 @@
+''
+sub/=sub/
diff --git a/tests/amalgam/unnamed/test.sh b/tests/amalgam/unnamed/test.sh
new file mode 100755
index 0000000..b898b3c
--- /dev/null
+++ b/tests/amalgam/unnamed/test.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+valgrind -q b -q | diff -u test.out -