aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-03-07 09:03:33 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-03-07 09:03:33 +0200
commitf599f30ee51c8a6f796d5b9a35e8e17ee54333ee (patch)
treedd96b66b8a59ec5d05201d9958801f4d3bf21cd1
parent22d2704c963f26f05f2b42433c8d0a7dc9b5b645 (diff)
Add support for alternative build file/directory naming scheme
Specifically, the bdep-new --type|-t now has the new 'alt-naming' sub-option that can be used to create projects with the alternative naming.
-rw-r--r--bdep/new.cli9
-rw-r--r--bdep/new.cxx39
-rw-r--r--bdep/sync.cxx22
-rw-r--r--bdep/sync.hxx3
-rw-r--r--tests/new.testscript24
5 files changed, 84 insertions, 13 deletions
diff --git a/bdep/new.cli b/bdep/new.cli
index 67a3ed1..c7e7fcb 100644
--- a/bdep/new.cli
+++ b/bdep/new.cli
@@ -78,6 +78,8 @@ namespace bdep
\cb{no-tests} \- Don't add support for functional/integration testing.
\cb{unit-tests} \- Add support for unit testing.
+
+ \cb{alt-naming} \- Use the alternative build file/directory naming scheme.
|
\li|\cb{lib}
@@ -88,6 +90,8 @@ namespace bdep
\cb{no-tests} \- Don't add support for functional/integration testing.
\cb{unit-tests} \- Add support for unit testing.
+
+ \cb{alt-naming} \- Use the alternative build file/directory naming scheme.
|
\li|\cb{bare}
@@ -95,6 +99,8 @@ namespace bdep
A project without any source code. Recognized bare project options:
\cb{no-tests} \- Don't add support for testing.
+
+ \cb{alt-naming} \- Use the alternative build file/directory naming scheme.
|
\li|\cb{empty}
@@ -149,17 +155,20 @@ namespace bdep
{
bool no-tests;
bool unit-tests;
+ bool alt-naming;
};
class cmd_new_lib_options
{
bool no-tests;
bool unit-tests;
+ bool alt-naming;
};
class cmd_new_bare_options
{
bool no-tests;
+ bool alt-naming;
};
class cmd_new_empty_options
diff --git a/bdep/new.cxx b/bdep/new.cxx
index 8fc0312..37fd235 100644
--- a/bdep/new.cxx
+++ b/bdep/new.cxx
@@ -60,12 +60,37 @@ namespace bdep
//
const type& t (o.type ());
- bool itest (t == type::exe ? !t.exe_opt.no_tests () :
- t == type::lib ? !t.lib_opt.no_tests () :
- t == type::bare ? !t.bare_opt.no_tests () : false);
+ bool altn (false); // alt-naming
+ bool itest (false); // !no-tests
+ bool utest (false); // unit-tests
- bool utest (t == type::exe ? t.exe_opt.unit_tests () :
- t == type::lib ? t.lib_opt.unit_tests () : false);
+ switch (t)
+ {
+ case type::exe:
+ {
+ altn = t.exe_opt.alt_naming ();
+ itest = !t.exe_opt.no_tests ();
+ utest = t.exe_opt.unit_tests ();
+ break;
+ }
+ case type::lib:
+ {
+ altn = t.lib_opt.alt_naming ();
+ itest = !t.lib_opt.no_tests ();
+ utest = t.lib_opt.unit_tests ();
+ break;
+ }
+ case type::bare:
+ {
+ altn = t.bare_opt.alt_naming ();
+ itest = !t.bare_opt.no_tests ();
+ break;
+ }
+ case type::empty:
+ {
+ break;
+ }
+ }
// Validate language options.
//
@@ -101,10 +126,8 @@ namespace bdep
if (a.empty ())
fail << "project name argument expected";
- // Build file/directory naming scheme.
+ // Standard/alternative build file/directory naming scheme.
//
- bool altn (false);
-
const dir_path build_dir (altn ? "build2" : "build");
const string build_ext (altn ? "build2" : "build");
const path buildfile_file (altn ? "build2file" : "buildfile");
diff --git a/bdep/sync.cxx b/bdep/sync.cxx
index d4f3983..f8df4dc 100644
--- a/bdep/sync.cxx
+++ b/bdep/sync.cxx
@@ -402,17 +402,29 @@ namespace bdep
}
// We could run 'b info' and used the 'forwarded' value but this is
- // both faster and simpler.
+ // both faster and simpler. Or at least it was until we got the
+ // alternative naming scheme.
//
- path f (src / "build" / "bootstrap" / "out-root.build");
- bool e (exists (f));
+ auto check = [&src] ()
+ {
+ path f (src / "build2" / "bootstrap" / "out-root.build2");
+ bool e (exists (f));
+
+ if (!e)
+ {
+ f = src / "build" / "bootstrap" / "out-root.build";
+ e = exists (f);
+ }
+
+ return e;
+ };
const char* o (nullptr);
if (prj.config->forward)
{
bool changed (true);
- if (changed || !e)
+ if (changed || !check ())
o = "configure:";
}
else if (!prj.implicit) // Requires explicit sync.
@@ -421,7 +433,7 @@ namespace bdep
// Looks like we will need to test that the forward is to this
// config. 'b info' here we come?
- //if (e)
+ //if (check ())
// o = "disfigure:";
}
diff --git a/bdep/sync.hxx b/bdep/sync.hxx
index 68f5e54..2183021 100644
--- a/bdep/sync.hxx
+++ b/bdep/sync.hxx
@@ -43,6 +43,9 @@ namespace bdep
const dir_path& cfg,
const dir_path& prj = dir_path ());
+ // Note that the hook is installed into the bpkg-created configuration which
+ // always uses the standard build file/directory naming scheme.
+ //
extern const path hook_file; // build/bootstrap/pre-bdep-sync.build
}
diff --git a/tests/new.testscript b/tests/new.testscript
index 8bfdc36..ca33056 100644
--- a/tests/new.testscript
+++ b/tests/new.testscript
@@ -68,6 +68,30 @@ status += -d prj
EOE
}
+ : exe-alt-naming
+ :
+ {
+ $* -t exe,alt-naming,unit-tests -l c++ foo 2>>/"EOE" &foo/***;
+ created new executable project foo in $~/foo/
+ EOE
+
+ $build foo/ $cxx 2>>~%EOE%
+ %(c\+\+|ld|ar) .+%{5}
+ EOE
+ }
+
+ : lib-alt-naming
+ :
+ {
+ $* -t lib,alt-naming,unit-tests -l c++ libfoo 2>>/"EOE" &libfoo/***;
+ created new library project libfoo in $~/libfoo/
+ EOE
+
+ $build libfoo/ $cxx 2>>~%EOE%
+ %(version\.in|c\+\+|ar|ld) .+%{11}
+ EOE
+ }
+
: lib-binless
:
{