aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2024-03-25 07:12:37 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2024-03-25 07:12:37 +0200
commit7ea85767a2b0dd7d16f60f83a194ff05a2e2f619 (patch)
tree936722ac12529c12a790ded777d3e52fb970701e
parent9f93b7a33f484b4ccdec2a47748f27338c99afbe (diff)
Add third-party sub-option to bdep-new --type empty option
-rw-r--r--bdep/new.cli7
-rw-r--r--bdep/new.cxx53
2 files changed, 58 insertions, 2 deletions
diff --git a/bdep/new.cli b/bdep/new.cli
index b9d308a..7bbfe8f 100644
--- a/bdep/new.cli
+++ b/bdep/new.cli
@@ -479,6 +479,12 @@ namespace bdep
An empty project that can be filled with packages (see
\cb{--package}). Recognized empty project sub-options:|
+ \li|\n\ \ \ \cb{third-party}
+
+ Create a project for converting an existing third-party project to
+ \cb{build2}. This sub-option adjusts the generated \cb{README.md}
+ template wording to reflect such a conversion.|
+
\li|\n\ \ \ \cb{no-readme}
See \cb{common} sub-options below.||
@@ -695,6 +701,7 @@ namespace bdep
class cmd_new_empty_options
{
+ bool third-party;
bool no-readme;
};
diff --git a/bdep/new.cxx b/bdep/new.cxx
index 185b099..229a21d 100644
--- a/bdep/new.cxx
+++ b/bdep/new.cxx
@@ -431,6 +431,49 @@ namespace bdep
<< '\n'
<< "<DESCRIPTION-OF-CONFIG-VARIABLES>" << '\n';
}
+
+ // Generate README.md for a multi-package repository root (--type empty).
+ //
+ static void
+ generate_empty_readme (ostream& os,
+ const string& n,
+ bool tp /* third-party */)
+ {
+ os << "# " << n << " - <SUMMARY>" << '\n'
+ << '\n';
+
+ if (tp)
+ {
+ os << "This is a `build2` package reporitory for [`" << n << "`](https://<UPSTREAM-URL>)," << '\n'
+ << "a <SUMMARY-OF-FUNCTIONALITY>." << '\n';
+ }
+ else
+ {
+ os << "`" << n << "` is a <SUMMARY-OF-FUNCTIONALITY>." << '\n';
+ }
+
+ os << '\n'
+ << "This file contains setup instructions and other details that are more" << '\n'
+ << "appropriate for development rather than consumption. If you want to use" << '\n'
+ << "`" << n << "` in your `build2`-based project, then instead see the accompanying" << '\n';
+ if (tp)
+ os << "[`PACKAGE-README.md`](<PACKAGE>/PACKAGE-README.md) file." << '\n';
+ else
+ os << "package [`README.md`](<PACKAGE>/README.md) file." << '\n';
+
+ os << '\n'
+ << "The development setup for `" << n << "` uses the standard `bdep`-based workflow." << '\n'
+ << "For example:" << '\n'
+ << '\n'
+ << "```" << '\n'
+ << "git clone .../" << n << ".git" << '\n'
+ << "cd " << n << '\n'
+ << '\n'
+ << "bdep init -C @gcc cc config.cxx=g++" << '\n'
+ << "bdep update" << '\n'
+ << "bdep test" << '\n'
+ << "```" << '\n';
+ }
}
int bdep::
@@ -573,7 +616,7 @@ cmd_new (cmd_new_options&& o, cli::group_scanner& args)
// wrong). All this seems reasonable for what this mode is expected to be
// used ("end-product" kind of projects).
//
- bool third_party (false); // third-party
+ bool third_party (false); // third-party (only exe and lib)
bool readme (false); // !no-readme && !third_party
bool pkg_readme (false); // !no-package-readme && third-party
bool altn (false); // alt-naming
@@ -673,6 +716,8 @@ cmd_new (cmd_new_options&& o, cli::group_scanner& args)
pkg ? "package" : nullptr))
fail << "cannot create empty " << w;
+ // Note: don't initialize third_party.
+ //
readme = !t.empty_opt.no_readme ();
break;
}
@@ -1931,11 +1976,15 @@ cmd_new (cmd_new_options&& o, cli::group_scanner& args)
break;
}
case type::bare:
- case type::empty:
{
os << "# " << n << '\n';
break;
}
+ case type::empty:
+ {
+ generate_empty_readme (os, n, t.empty_opt.third_party ());
+ break;
+ }
}
os.close ();
}