From a8e16d5eb61eb4e7eaa135413b1af13c1f9ef82b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 16 May 2019 16:49:02 +0200 Subject: Add license=name project type sub-option in bdep-new If unspecified, the default is now 'proprietary' instead of TODO. --- bdep/new.cli | 63 +++++++++++++++++++++++++++++++++++++----------------- bdep/new.cxx | 69 ++++++++++++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 99 insertions(+), 33 deletions(-) diff --git a/bdep/new.cli b/bdep/new.cli index 6bab278..faf412d 100644 --- a/bdep/new.cli +++ b/bdep/new.cli @@ -107,7 +107,7 @@ namespace bdep The project parameters such as type (executable, library, etc), language, and version control system can be customized as described next. Some of - these parameters also support parameter-specific options (such as the + these parameters also support parameter-specific sub-options (such as the file extensions to use in a C++ project) that can be specified with a comma after the parameter value. @@ -120,7 +120,7 @@ namespace bdep \li|\cb{exe} A project that builds a sample executable. Recognized - executable project options:| + executable project sub-options:| \li|\n\ \ \ \cb{no-tests} @@ -130,20 +130,20 @@ namespace bdep Add support for unit testing.| - \li|\n\ \ \ \cb{no-readme} + \li|\n\ \ \ \c{\b{license=}\i{name}}| - Don't add \cb{README.md}.| + \li|\ \ \ \cb{no-readme}| - \li|\n\ \ \ \cb{alt-naming} + \li|\ \ \ \cb{alt-naming} - Use the alternative build file/directory naming scheme.|| + See \cb{common} sub-options below.|| \dl| \li|\cb{lib} A project that builds a sample library. Recognized library - project options:| + project sub-options:| \li|\n\ \ \ \cb{no-tests} @@ -157,32 +157,32 @@ namespace bdep Don't add support for generating the version header.| - \li|\n\ \ \ \cb{no-readme} + \li|\n\ \ \ \c{\b{license=}\i{name}}| - Don't add \cb{README.md}.| + \li|\ \ \ \cb{no-readme}| - \li|\n\ \ \ \cb{alt-naming} + \li|\ \ \ \cb{alt-naming} - Use the alternative build file/directory naming scheme.|| + See \cb{common} sub-options below.|| \dl| \li|\cb{bare} A project without any source code that can be filled later - (see \cb{--subdirectory}). Recognized bare project options:| + (see \cb{--subdirectory}). Recognized bare project sub-options:| \li|\n\ \ \ \cb{no-tests} Don't add support for testing.| - \li|\n\ \ \ \cb{no-readme} + \li|\n\ \ \ \c{\b{license=}\i{name}}| - Don't add \cb{README.md}.| + \li|\ \ \ \cb{no-readme}| - \li|\n\ \ \ \cb{alt-naming} + \li|\ \ \ \cb{alt-naming} - Use the alternative build file/directory naming scheme.|| + See \cb{common} sub-options below.|| \dl| @@ -190,11 +190,33 @@ 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. Recognized empty project options:| + project type. Recognized empty project sub-options:| + + \li|\n\ \ \ \cb{no-readme} + + See \cb{common} sub-options below.|| + + \dl| + + \li|\cb{common} + + Common project type sub-options:| + + \li|\n\ \ \ \c{\b{license=}\i{name}} + + Specify the project's license. Commonly used license names are + \cb{MIT}, \cb{ASLv2} (Apache License 2.0), \cb{GPLv3}, and + \cb{proprietary}. If unspecified, then \cb{proprietary} is + assumed. See the \l{bpkg#manifest-package-license \cb{license}} + package manifest value for details.| \li|\n\ \ \ \cb{no-readme} - Don't add \cb{README.md}.|| + Don't add \cb{README.md}.| + + \li|\n\ \ \ \cb{alt-naming} + + Use the alternative build file/directory naming scheme.|| The project language can be specified with the \c{\b{--lang}|\b{-l}} option. Valid values for this option and their semantics are described @@ -210,7 +232,7 @@ namespace bdep \li|\cb{c++} - A C++ project. Recognized language options:| + A C++ project. Recognized language sub-options:| \li|\n\ \ \ \cb{binless} @@ -302,6 +324,7 @@ namespace bdep { bool no-tests; bool unit-tests; + string license = "proprietary"; bool no-readme; bool alt-naming; }; @@ -311,6 +334,7 @@ namespace bdep bool no-tests; bool unit-tests; bool no-version; + string license = "proprietary"; bool no-readme; bool alt-naming; }; @@ -318,6 +342,7 @@ namespace bdep class cmd_new_bare_options { bool no-tests; + string license = "proprietary"; bool no-readme; bool alt-naming; }; diff --git a/bdep/new.cxx b/bdep/new.cxx index 88563bc..8f81ba3 100644 --- a/bdep/new.cxx +++ b/bdep/new.cxx @@ -80,23 +80,29 @@ namespace bdep bool utest (false); // unit-tests bool ver (false); // !no-version + string license; + switch (t) { case type::exe: { - 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 (); + 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 (); + + license = t.exe_opt.license (); break; } case type::lib: { - 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 (); + 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 (); + + license = t.lib_opt.license (); break; } case type::bare: @@ -104,9 +110,11 @@ namespace bdep if (o.subdirectory ()) fail << "cannot create bare source subdirectory"; - readme = !t.bare_opt.no_readme (); - 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 (); + + license = t.bare_opt.license (); break; } case type::empty: @@ -120,6 +128,36 @@ namespace bdep } } + // Full name for some common license abbreviations. + // + string license_full; + { + auto cmp = [&license] (const char* n) + { + return casecmp (license, n) == 0; + }; + + license_full = + cmp ("MIT") ? "MIT License" : + cmp ("BSD3") ? "New 3-clause BSD License" : + cmp ("BSD2") ? "Simplified 2-clause BSD License" : + cmp ("BSD4") ? "Original 4-clause BSD License" : + cmp ("GPLv2") ? "GNU General Public License v2.0" : + cmp ("GPLv3") ? "GNU General Public License v3.0" : + cmp ("LGPLv2") ? "GNU Lesser General Public License v2.0" : + cmp ("LGPLv2.1") ? "GNU Lesser General Public License v2.1" : + cmp ("LGPLv3") ? "GNU Lesser General Public License v3.0" : + cmp ("ASLv1") ? "Apache License v1.0" : + cmp ("ASLv1.1") ? "Apache License v1.1" : + cmp ("ASLv2") ? "Apache License v2.0" : + cmp ("MPLv2") ? "Mozilla Public License v2.0" : + ""; + + if (cmp ("BSD")) + warn << "BSD license name is ambiguous" << + info << "consider changing to BSD3 for \"New 3-clause BSD License\""; + } + // Validate language options. // const lang& l (o.lang ()); @@ -563,8 +601,11 @@ namespace bdep << "version: 0.1.0-a.0.z" << endl; if (pn) os << "project: " << *pn << endl; - os << "summary: " << s << " " << l << " " << t << endl - << "license: TODO" << endl; + os << "summary: " << s << " " << l << " " << t << endl; + if (license_full.empty ()) + os << "license: " << license << endl; + else + os << "license: " << license << " ; " << license_full << endl; if (readme) os << "description-file: README.md" << endl; os << "url: https://example.org/" << (pn ? pn->string () : n) << endl -- cgit v1.1