aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bdep/bdep.cli2
-rw-r--r--bdep/new.cli168
-rw-r--r--bdep/new.cxx83
3 files changed, 128 insertions, 125 deletions
diff --git a/bdep/bdep.cli b/bdep/bdep.cli
index a25c06e..7c77958 100644
--- a/bdep/bdep.cli
+++ b/bdep/bdep.cli
@@ -161,7 +161,7 @@ namespace bdep
project naming):
\
- $ bdep new -t exe -l c++ hello
+ $ bdep new -l c++ -t exe hello
\
Similar to version control tools, we normally run \cb{bdep} from the
diff --git a/bdep/new.cli b/bdep/new.cli
index 8715f72..9340f85 100644
--- a/bdep/new.cli
+++ b/bdep/new.cli
@@ -28,9 +28,9 @@ namespace bdep
\b{bdep new} [<options>] \b{--package} [<prj-spec>] <spec> [<name>]\n
\b{bdep new} [<options>] \b{--subdirectory} [<prj-spec>] <spec> [<name>]}
- \c{<spec> \ \ \ \ = [<type>] [<lang>] [<vcs>]\n
- <type> \ \ \ \ = \b{--type}|\b{-t} (\b{exe}|\b{lib}|\b{bare}|\b{empty})[\b{,}<type-opt>...]\n
+ \c{<spec> \ \ \ \ = [<lang>] [<type>] [<vcs>]\n
<lang> \ \ \ \ = \b{--lang}|\b{-l} (\b{c}|\b{c++})[\b{,}<lang-opt>...]\n
+ <type> \ \ \ \ = \b{--type}|\b{-t} (\b{exe}|\b{lib}|\b{bare}|\b{empty})[\b{,}<type-opt>...]\n
<vcs> \ \ \ \ \ = \b{--vcs}|\b{-s} \ (\b{git}|\b{none})[\b{,}<vcs-opt>...]\n
<prj-spec> = \b{--directory}|\b{-d} <prj-dir>\n
<cfg-args> = [\b{--} <bpkg-options>] [\b{--existing}|\b{-e} | (<module> | <cfg-var>)...]}
@@ -50,7 +50,7 @@ namespace bdep
\l{bdep-init(1)} command with the \cb{--empty} option. For example:
\
- $ bdep new -t exe -l c++ hello
+ $ bdep new -l c++ -t exe hello
\
Similarly, the second and third forms add an existing or create new build
@@ -59,7 +59,7 @@ namespace bdep
\cb{--config-create} option, respectively. For example:
\
- $ bdep new -t exe -l c++ -C @gcc hello cc config.cxx=g++
+ $ bdep new -l c++ -t exe -C @gcc hello cc config.cxx=g++
\
The \cb{--package} form adds the new package to the
@@ -72,8 +72,8 @@ namespace bdep
$ bdep new -t empty hello
$ cd hello
- $ bdep new --package -t lib -l c++ libhello
- $ bdep new --package -t exe -l c++ hello
+ $ bdep new --package -l c++ -t lib libhello
+ $ bdep new --package -l c++ -t exe hello
$ bdep init -C @gcc cc config.cxx=g++
\
@@ -93,8 +93,8 @@ namespace bdep
$ bdep new -t bare hello
$ cd hello
- $ bdep new --subdirectory -t lib -l c++ libhello
- $ bdep new --subdirectory -t exe -l c++ hello
+ $ bdep new --subdirectory -l c++ -t lib libhello
+ $ bdep new --subdirectory -l c++ -t exe hello
$ bdep init -C @gcc cc config.cxx=g++
\
@@ -121,24 +121,93 @@ namespace bdep
$ git clone .../libhello.git
$ cd libhello
- $ bdep new -t lib -l c++
+ $ bdep new -l c++ -t lib
\
- The project parameters such as type (executable, library, etc), language,
+ The project parameters such as language, type (executable, library, etc),
and version control system can be customized as described next. Some of
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.
+ The project language can be specified with the \c{\b{--lang}|\b{-l}}
+ option. Valid values for this option and their semantics are described
+ next. If unspecified, a C++ project is created by default.
+
+ \dl|
+
+ \li|\cb{c}
+
+ A C project.||
+
+ \dl|
+
+ \li|\cb{c++}
+
+ A C++ project. Recognized language sub-options:|
+
+ \li|\n\ \ \ \cb{binless}
+
+ Create a header-only library.|
+
+ \li|\n\ \ \ \cb{cpp}
+
+ Use the \cb{.cpp}, \cb{.hpp}, \cb{.ipp}, \cb{.tpp}, and \cb{.mpp}
+ source file extensions (alias for \cb{extension=?pp}).|
+
+ \li|\n\ \ \ \c{\b{extension=}\i{pattern}}
+
+ Derive source file extensions from \ci{pattern} by replacing
+ every \cb{?} with one of the \cb{c} (source), \cb{h} (header),
+ \cb{i} (inline), \cb{t} (template), or \cb{m} (module interface)
+ letters. If unspecified and no individual extensions are specified
+ with the below options, then \cb{?xx} is used by default.|
+
+ \li|\n\ \ \ \c{\b{hxx=}\i{extension}}
+
+ Use the specified \ci{extension} for header files instead of
+ the default \cb{.hxx}.|
+
+ \li|\n\ \ \ \c{\b{cxx=}\i{extension}}
+
+ Use the specified \ci{extension} for source files instead of
+ the default \cb{.cxx}.|
+
+ \li|\n\ \ \ \c{\b{ixx=}\i{extension}}
+
+ Use the specified \ci{extension} for inline files. If
+ unspecified, then assume no inline files are used by the
+ project.|
+
+ \li|\n\ \ \ \c{\b{txx=}\i{extension}}
+
+ Use the specified \ci{extension} for template files. If
+ unspecified, then assume no template files are used by the
+ project.|
+
+ \li|\n\ \ \ \c{\b{mxx=}\i{extension}}
+
+ Use the specified \ci{extension} for module interface files. If
+ unspecified, then assume no modules are used by the project.||
+
+ As an example, the following command creates a header-only C++ library
+ that uses the \cb{.h} extension for header files and \cb{.cpp} \- for
+ source files:
+
+ \
+ $ bdep new -l c++,binless,hxx=h,cxx=cpp -t lib libhello
+ \
+
The project type can be specified with the \c{\b{--type}|\b{-t}} option.
- Valid values for this option and their semantics are described next. If
- unspecified, an executable project is created by default.
+ The \cb{empty} project type is language-agnostic with the semantics and
+ valid sub-options for the rest being language-dependant, as described
+ next. If unspecified, an executable project is created by default.
\dl|
\li|\cb{exe}
- A project that builds a sample executable. Recognized
+ A project that builds a sample C or C++ executable. Recognized
executable project sub-options:|
\li|\n\ \ \ \cb{no-tests}
@@ -165,7 +234,7 @@ namespace bdep
\li|\cb{lib}
- A project that builds a sample library. Recognized library
+ A project that builds a sample C or C++ library. Recognized library
project sub-options:|
\li|\n\ \ \ \cb{no-tests}
@@ -220,8 +289,7 @@ namespace bdep
\li|\cb{empty}
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 sub-options:|
+ \cb{--package}). Recognized empty project sub-options:|
\li|\n\ \ \ \cb{no-readme}
@@ -249,74 +317,6 @@ namespace bdep
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
- next. If unspecified, a C++ project is created by default.
-
- \dl|
-
- \li|\cb{c}
-
- A C project.||
-
- \dl|
-
- \li|\cb{c++}
-
- A C++ project. Recognized language sub-options:|
-
- \li|\n\ \ \ \cb{binless}
-
- Create a header-only library.|
-
- \li|\n\ \ \ \cb{cpp}
-
- Use the \cb{.cpp}, \cb{.hpp}, \cb{.ipp}, \cb{.tpp}, and \cb{.mpp}
- source file extensions (alias for \cb{extension=?pp}).|
-
- \li|\n\ \ \ \c{\b{extension=}\i{pattern}}
-
- Derive source file extensions from \ci{pattern} by replacing
- every \cb{?} with one of the \cb{c} (source), \cb{h} (header),
- \cb{i} (inline), \cb{t} (template), or \cb{m} (module interface)
- letters. If unspecified and no individual extensions are specified
- with the below options, then \cb{?xx} is used by default.|
-
- \li|\n\ \ \ \c{\b{hxx=}\i{extension}}
-
- Use the specified \ci{extension} for header files instead of
- the default \cb{.hxx}.|
-
- \li|\n\ \ \ \c{\b{cxx=}\i{extension}}
-
- Use the specified \ci{extension} for source files instead of
- the default \cb{.cxx}.|
-
- \li|\n\ \ \ \c{\b{ixx=}\i{extension}}
-
- Use the specified \ci{extension} for inline files. If
- unspecified, then assume no inline files are used by the
- project.|
-
- \li|\n\ \ \ \c{\b{txx=}\i{extension}}
-
- Use the specified \ci{extension} for template files. If
- unspecified, then assume no template files are used by the
- project.|
-
- \li|\n\ \ \ \c{\b{mxx=}\i{extension}}
-
- Use the specified \ci{extension} for module interface files. If
- unspecified, then assume no modules are used by the project.||
-
- As an example, the following command creates a header-only C++ library
- that uses the \cb{.h} extension for header files and \cb{.cpp} \- for
- source files:
-
- \
- $ bdep new -t lib -l c++,binless,hxx=h,cxx=cpp libhello
- \
-
The project version control system can be specified with the
\c{\b{--vcs}|\b{-s}} option. Valid values for this option and their
semantics are described next. If unspecified, \cb{git} is assumed by
diff --git a/bdep/new.cxx b/bdep/new.cxx
index 80b4f40..3e7f295 100644
--- a/bdep/new.cxx
+++ b/bdep/new.cxx
@@ -246,6 +246,43 @@ namespace bdep
fail << "--wipe specified without --config-create";
}
+ // Validate language options.
+ //
+ const lang& l (o.lang ());
+
+ switch (l)
+ {
+ case lang::c:
+ {
+ break;
+ }
+ case lang::cxx:
+ {
+ auto& o (l.cxx_opt);
+
+ if (o.cpp () && o.extension_specified ())
+ fail << "'extension' and 'cpp' are mutually exclusive c++ options";
+
+ // Verify that none of the extensions are specified as empty, except
+ // for hxx.
+ //
+ auto empty_ext = [] (const string& v, const char* o)
+ {
+ if (v.empty () || (v.size () == 1 && v[0] == '.'))
+ fail << "empty extension specified with '" << o << "' c++ option";
+ };
+
+ if (o.extension_specified ()) empty_ext (o.extension (), "extension");
+
+ if (o.cxx_specified ()) empty_ext (o.cxx (), "cxx");
+ if (o.ixx_specified ()) empty_ext (o.ixx (), "ixx");
+ if (o.txx_specified ()) empty_ext (o.txx (), "txx");
+ if (o.mxx_specified ()) empty_ext (o.mxx (), "mxx");
+
+ break;
+ }
+ }
+
// Validate type options.
//
const type& t (o.type ());
@@ -329,6 +366,12 @@ namespace bdep
break;
}
}
+
+ // @@ TODO: move into the lib case once binless is a project type
+ // suboption.
+ //
+ if (l == lang::cxx && l.cxx_opt.binless () && t != type::lib)
+ fail << "'binless' is only valid for libraries";
}
// Standard/alternative build file/directory naming scheme.
@@ -337,46 +380,6 @@ namespace bdep
const string build_ext (altn ? "build2" : "build");
const path buildfile_file (altn ? "build2file" : "buildfile");
- // Validate language options.
- //
- const lang& l (o.lang ());
-
- switch (l)
- {
- case lang::c:
- {
- break;
- }
- case lang::cxx:
- {
- auto& o (l.cxx_opt);
-
- if (o.cpp () && o.extension_specified ())
- fail << "'extension' and 'cpp' are mutually exclusive c++ options";
-
- // Verify that none of the extensions are specified as empty, except
- // for hxx.
- //
- auto empty_ext = [] (const string& v, const char* o)
- {
- if (v.empty () || (v.size () == 1 && v[0] == '.'))
- fail << "empty extension specified with '" << o << "' c++ option";
- };
-
- if (o.extension_specified ()) empty_ext (o.extension (), "extension");
-
- if (o.cxx_specified ()) empty_ext (o.cxx (), "cxx");
- if (o.ixx_specified ()) empty_ext (o.ixx (), "ixx");
- if (o.txx_specified ()) empty_ext (o.txx (), "txx");
- if (o.mxx_specified ()) empty_ext (o.mxx (), "mxx");
-
- if (o.binless () && t != type::lib)
- fail << "'binless' is only valid for libraries";
-
- break;
- }
- }
-
// Validate vcs options.
//
vcs vc (o.vcs ());