aboutsummaryrefslogtreecommitdiff
path: root/bdep/new.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-07-17 14:49:04 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-07-17 14:49:04 +0200
commit1580b9fe0ab2b242227cdd7601766bdfce5493e2 (patch)
treee06a0c32d76865fb232a82cf390f8728ddfe8b1a /bdep/new.cxx
parentc70cc15b6ebe49150661e025855dc22ceb235905 (diff)
Diagnose improper project/package arrangements in new command
Diffstat (limited to 'bdep/new.cxx')
-rw-r--r--bdep/new.cxx24
1 files changed, 22 insertions, 2 deletions
diff --git a/bdep/new.cxx b/bdep/new.cxx
index 37a7b67..2b5402b 100644
--- a/bdep/new.cxx
+++ b/bdep/new.cxx
@@ -158,6 +158,26 @@ namespace bdep
fail << "package directory " << out << " is not a subdirectory of "
<< "project directory " << prj;
+ // As a sanity check, verify none of the directories between us and the
+ // project look like packages.
+ //
+ project_package pp (
+ find_project_package (out, true /* ignore_not_found */));
+
+ if (!pp.project.empty ())
+ {
+ if (pp.project != prj)
+ fail << prj << " is not a project directory" <<
+ info << pp.project << " looks like a project directory";
+
+ if (pp.package)
+ fail << "package directory " << out << " is inside another "
+ << "package directory " << prj / *pp.package <<
+ info << "nested packages are not allowed";
+ }
+ else
+ warn << prj << " does not look like a project directory";
+
pkg = out.leaf (prj);
}
else
@@ -167,8 +187,8 @@ namespace bdep
prj = out;
}
- // If the output directory already exists, make sure it is
- // empty. Otherwise create it.
+ // If the output directory already exists, make sure it is empty.
+ // Otherwise create it.
//
if (!exists (out))
mk (out);