aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-07-18 14:53:21 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-07-18 14:53:21 +0200
commitcb17adc24f95042976972c68b37e136306af8d38 (patch)
tree592c681b3a325c0801770ac09c8515a1b45e18e4
parent63b1aa8702a3dfcfc0f3285f8f1c45ce4805bbc7 (diff)
Diagnose nested projects in new command
-rw-r--r--bdep/new.cxx52
1 files changed, 32 insertions, 20 deletions
diff --git a/bdep/new.cxx b/bdep/new.cxx
index 2b5402b..7cdddc8 100644
--- a/bdep/new.cxx
+++ b/bdep/new.cxx
@@ -158,26 +158,6 @@ 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
@@ -187,6 +167,38 @@ namespace bdep
prj = out;
}
+ // Do some sanity check (nested packages, etc; you would be surprised what
+ // people come up with).
+ //
+ {
+ project_package pp (
+ find_project_package (out, true /* ignore_not_found */));
+
+ if (o.package ())
+ {
+ 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";
+ }
+ else
+ {
+ if (!pp.project.empty ())
+ fail << "project directory " << out << " is inside another "
+ << "project directory " << pp.project <<
+ info << "nested projects are not allowed";
+ }
+ }
+
// If the output directory already exists, make sure it is empty.
// Otherwise create it.
//