aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bdep/new-types.hxx18
-rw-r--r--bdep/new.cli22
-rw-r--r--bdep/new.cxx78
-rw-r--r--tests/init.testscript4
-rw-r--r--tests/new.testscript52
-rw-r--r--tests/release.testscript22
6 files changed, 158 insertions, 38 deletions
diff --git a/bdep/new-types.hxx b/bdep/new-types.hxx
index 96aaa7c..d1ef18f 100644
--- a/bdep/new-types.hxx
+++ b/bdep/new-types.hxx
@@ -59,7 +59,7 @@ namespace bdep
case type::empty: return "empty";
}
- return string (); // Should never reach.
+ return std::string (); // Should never reach.
}
friend ostream&
@@ -92,17 +92,23 @@ namespace bdep
cmd_new_lang_template (): lang (cxx) {}
const std::string
- string () const
+ string (bool lower = false) const
{
using lang = cmd_new_lang_template;
switch (*this)
{
- case lang::c: return "c";
- case lang::cxx: return "c++";
+ case lang::c: return lower ? "c" : "C";
+ case lang::cxx: return lower ? "c++" : "C++";
}
- return string (); // Should never reach.
+ return std::string (); // Should never reach.
+ }
+
+ friend ostream&
+ operator<< (ostream& os, const cmd_new_lang_template& l)
+ {
+ return os << l.string ();
}
};
@@ -139,7 +145,7 @@ namespace bdep
case vcs::none: return "none";
}
- return string (); // Should never reach.
+ return std::string (); // Should never reach.
}
};
diff --git a/bdep/new.cli b/bdep/new.cli
index 1e206df..6bab278 100644
--- a/bdep/new.cli
+++ b/bdep/new.cli
@@ -130,6 +130,10 @@ namespace bdep
Add support for unit testing.|
+ \li|\n\ \ \ \cb{no-readme}
+
+ Don't add \cb{README.md}.|
+
\li|\n\ \ \ \cb{alt-naming}
Use the alternative build file/directory naming scheme.||
@@ -153,6 +157,10 @@ namespace bdep
Don't add support for generating the version header.|
+ \li|\n\ \ \ \cb{no-readme}
+
+ Don't add \cb{README.md}.|
+
\li|\n\ \ \ \cb{alt-naming}
Use the alternative build file/directory naming scheme.||
@@ -168,6 +176,10 @@ namespace bdep
Don't add support for testing.|
+ \li|\n\ \ \ \cb{no-readme}
+
+ Don't add \cb{README.md}.|
+
\li|\n\ \ \ \cb{alt-naming}
Use the alternative build file/directory naming scheme.||
@@ -178,7 +190,11 @@ namespace bdep
An empty project that can be filled with packages (see
\cb{--package}). Note that the project language is ignored for this
- project type.||
+ project type. Recognized empty project options:|
+
+ \li|\n\ \ \ \cb{no-readme}
+
+ Don't add \cb{README.md}.||
The project language can be specified with the \c{\b{--lang}|\b{-l}}
option. Valid values for this option and their semantics are described
@@ -286,6 +302,7 @@ namespace bdep
{
bool no-tests;
bool unit-tests;
+ bool no-readme;
bool alt-naming;
};
@@ -294,17 +311,20 @@ namespace bdep
bool no-tests;
bool unit-tests;
bool no-version;
+ bool no-readme;
bool alt-naming;
};
class cmd_new_bare_options
{
bool no-tests;
+ bool no-readme;
bool alt-naming;
};
class cmd_new_empty_options
{
+ bool no-readme;
};
// --lang options
diff --git a/bdep/new.cxx b/bdep/new.cxx
index 11ac8f4..88563bc 100644
--- a/bdep/new.cxx
+++ b/bdep/new.cxx
@@ -46,7 +46,7 @@ namespace bdep
fail << "both --no-init and " << m << " specified";
if (const char* n = (o.no_init () ? "--no-init" :
- m ? m : nullptr))
+ m ? m : nullptr))
{
if (ca) fail << "both " << n << " and --config-add specified";
if (cc) fail << "both " << n << " and --config-create specified";
@@ -74,26 +74,29 @@ namespace bdep
// will most likely be wrong). All this seems reasonable for what this
// mode is expected to be used ("end-product" kind of projects).
//
- bool altn (false); // alt-naming
- bool itest (false); // !no-tests
- bool utest (false); // unit-tests
- bool ver (false); // !no-version
+ bool readme (false); // !no-readme
+ bool altn (false); // alt-naming
+ bool itest (false); // !no-tests
+ bool utest (false); // unit-tests
+ bool ver (false); // !no-version
switch (t)
{
case type::exe:
{
- altn = t.exe_opt.alt_naming ();
- itest = !t.exe_opt.no_tests ();
- utest = t.exe_opt.unit_tests ();
+ readme = !t.exe_opt.no_readme () && !o.subdirectory ();
+ 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 () && !o.subdirectory ();
- utest = t.lib_opt.unit_tests ();
- ver = !t.lib_opt.no_version () && !o.subdirectory ();
+ readme = !t.lib_opt.no_readme () && !o.subdirectory ();
+ altn = t.lib_opt.alt_naming ();
+ itest = !t.lib_opt.no_tests () && !o.subdirectory ();
+ utest = t.lib_opt.unit_tests ();
+ ver = !t.lib_opt.no_version () && !o.subdirectory ();
break;
}
case type::bare:
@@ -101,8 +104,9 @@ namespace bdep
if (o.subdirectory ())
fail << "cannot create bare source subdirectory";
- altn = t.bare_opt.alt_naming ();
- itest = !t.bare_opt.no_tests ();
+ readme = !t.bare_opt.no_readme ();
+ altn = t.bare_opt.alt_naming ();
+ itest = !t.bare_opt.no_tests ();
break;
}
case type::empty:
@@ -111,6 +115,7 @@ namespace bdep
o.package () ? "package" : nullptr))
fail << "cannot create empty " << w;
+ readme = !t.empty_opt.no_readme ();
break;
}
}
@@ -468,6 +473,36 @@ namespace bdep
os.close ();
}
+ // README.md
+ //
+ if (readme)
+ {
+ os.open (f = out / "README.md");
+ switch (t)
+ {
+ case type::exe:
+ case type::lib:
+ {
+ // @@ Maybe we should generate a "Hello, World" description and
+ // usage example as a guide, at least for a library?
+
+ os << "# " << n << " - " << l << " " << t << endl
+ << endl
+ << "TODO" << endl;
+ break;
+ }
+ case type::bare:
+ case type::empty:
+ {
+ os << "# " << n << endl
+ << endl
+ << "TODO" << endl;
+ break;
+ }
+ }
+ os.close ();
+ }
+
if (t == type::empty)
break;
@@ -528,9 +563,11 @@ namespace bdep
<< "version: 0.1.0-a.0.z" << endl;
if (pn)
os << "project: " << *pn << endl;
- os << "summary: " << s << " " << t << endl
- << "license: TODO" << endl
- << "url: https://example.org/" << (pn ? pn->string () : n) << endl
+ os << "summary: " << s << " " << l << " " << t << endl
+ << "license: TODO" << endl;
+ if (readme)
+ os << "description-file: README.md" << endl;
+ os << "url: https://example.org/" << (pn ? pn->string () : n) << endl
<< "email: " << pe << endl
<< "depends: * build2 >= 0.10.0" << endl
<< "depends: * bpkg >= 0.10.0" << endl
@@ -727,7 +764,10 @@ namespace bdep
if (!sub)
{
os.open (f = out / buildfile_file);
- os << "./: {*/ -" << build_dir.posix_representation () << "} manifest" << endl;
+
+ os << "./: {*/ -" << build_dir.posix_representation () << "}" <<
+ (readme ? " doc{README.md}" : "") << " manifest" << endl;
+
if (itest && t == type::lib) // Have tests/ subproject.
os << endl
<< "# Don't install tests." << endl
@@ -1621,7 +1661,7 @@ namespace bdep
add_var ("base", move (b));
add_var ("stem", move (s));
add_var ("type", t.string ());
- add_var ("lang", l.string ());
+ add_var ("lang", l.string (true /* lower */));
add_var ("vcs", vc.string ());
add_var ("root", prj.string ());
diff --git a/tests/init.testscript b/tests/init.testscript
index 4b4c8c7..002f2b2 100644
--- a/tests/init.testscript
+++ b/tests/init.testscript
@@ -135,7 +135,9 @@ deinit += -d prj
#
mkdir --no-cleanup prj/prj.pkg;
- mv prj/prj prj/build prj/buildfile prj/manifest prj/.gitignore prj/prj.pkg/;
+ mv prj/prj prj/build prj/buildfile prj/manifest prj/README.md \
+ prj/.gitignore prj/prj.pkg/;
+
mv prj/prj.pkg prj/prj;
cat <<EOI >=prj/packages.manifest;
diff --git a/tests/new.testscript b/tests/new.testscript
index 17f26a7..8a6ff65 100644
--- a/tests/new.testscript
+++ b/tests/new.testscript
@@ -98,6 +98,50 @@ status += -d prj
EOE
}
+ : exe-readme
+ :
+ {
+ : add
+ :
+ {
+ $* foo 2>>/"EOE" &foo/***;
+ created new executable project foo in $~/foo/
+ EOE
+
+ test -f foo/README.md;
+
+ cat foo/manifest >>~%EOE%;
+ %.+
+ description-file: README.md
+ %.+
+ EOE
+
+ cat foo/buildfile >>~%EOE%;
+ %.*
+ %.+ doc\{README.md\}.*%
+ %.*
+ EOE
+
+ $build foo/ $cxx 2>>~%EOE%
+ %(c\+\+|ld) .+%{2}
+ EOE
+ }
+
+ : omit
+ :
+ {
+ $* -t exe,no-readme foo 2>>/"EOE" &foo/***;
+ created new executable project foo in $~/foo/
+ EOE
+
+ test -f foo/README.md == 1;
+
+ $build foo/ $cxx 2>>~%EOE%
+ %(c\+\+|ld) .+%{2}
+ EOE
+ }
+ }
+
: lib-no-version
:
{
@@ -198,6 +242,10 @@ status += -d prj
created new empty project prj in $~/prj/
EOE
+ # While at it, test that README.md is created.
+ #
+ test -f prj/README.md;
+
$* --package -t lib libprj -d prj 2>>/"EOE";
created new library package libprj in $~/prj/libprj/
EOE
@@ -252,6 +300,10 @@ status += -d prj
created new library source subdirectory libprj in $~/prj/libprj/
EOE
+ # While at it, test that README.md is not created.
+ #
+ test -f prj/libprj/README.md == 1;
+
$build prj/ $cxx 2>>~%EOE%
%(c\+\+|ar|ld) .+%{6}
EOE
diff --git a/tests/release.testscript b/tests/release.testscript
index fc10ff7..0715280 100644
--- a/tests/release.testscript
+++ b/tests/release.testscript
@@ -87,7 +87,7 @@ log2 = $gp2 log '--pretty=format:"%d %s"'
%.*
name: prj
version: 0.2.0-a.0.z
- summary: prj executable
+ summary: prj C++ executable
%.*
EOO
}
@@ -452,23 +452,23 @@ log2 = $gp2 log '--pretty=format:"%d %s"'
{
$clone_root_repos;
- echo 'description-file: README' >+ prj/manifest;
- $gp commit -a -m 'Add description';
+ rm prj/README.md;
+ $gp commit -a -m 'Remove description';
$* 2>>~%EOE% != 0;
- %error: unable to read .+README referenced by description-file manifest value in .+manifest: .+%
+ %error: unable to read .+README\.md referenced by description-file manifest value in .+manifest: .+%
EOE
- touch prj/README;
- $gp add README;
- $gp commit -m 'Add README file';
+ touch prj/README.md;
+ $gp add README.md;
+ $gp commit -m 'Add README.md file';
$* 2>>~%EOE% != 0;
- %error: description-file manifest value in .+manifest references empty file .+README%
+ %error: description-file manifest value in .+manifest references empty file .+README.md%
EOE
- echo '.' >= prj/README;
- $gp commit -a -m 'Fill README file';
+ echo '.' >= prj/README.md;
+ $gp commit -a -m 'Fill README.md file';
$*
}
@@ -897,7 +897,7 @@ log2 = $gp2 log '--pretty=format:"%d %s"'
%.*
name: prj
version: 0.2.0-a.0.z
- summary: prj executable
+ summary: prj C++ executable
%.*
EOO