aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-01-30 12:28:33 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-01-30 12:28:33 +0200
commit46f5d01e4f61cfba9e0f4bc7ecc59891c53ca8ec (patch)
tree9937800abbc5c50d0aa819d4956231262d7c1522
parent9f0bac92ada2a83e3a438e3fef28a6ed867710de (diff)
Add option documentation, reorganize things
-rw-r--r--build2/.gitignore2
-rw-r--r--build2/b.cli221
-rw-r--r--build2/b.cxx2
-rw-r--r--build2/buildfile33
-rw-r--r--build2/operation5
-rw-r--r--build2/options328
-rw-r--r--build2/options.cli31
-rw-r--r--build2/options.cxx549
-rw-r--r--build2/options.ixx165
9 files changed, 257 insertions, 1079 deletions
diff --git a/build2/.gitignore b/build2/.gitignore
index c9855e8..35d9f3d 100644
--- a/build2/.gitignore
+++ b/build2/.gitignore
@@ -1,2 +1,4 @@
b
b-*
+*-options
+*-options.?xx
diff --git a/build2/b.cli b/build2/b.cli
new file mode 100644
index 0000000..a34e336
--- /dev/null
+++ b/build2/b.cli
@@ -0,0 +1,221 @@
+// file : build2/options.cli
+// copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
+// license : MIT; see accompanying LICENSE file
+
+include <build2/types>;
+
+"\section=1"
+"\name=b"
+"\summary=build2 build driver"
+
+namespace build2
+{
+ {
+ "<options> <variable> <buildspec>
+ <meta-operation> <operation> <target> <src-base>",
+
+ "\h|SYNOPSIS|
+
+ \cb{b --help}\n
+ \cb{b --version}\n
+ \c{\b{b} [<options>] [<variables>] [<buildspec>]}
+
+ \h|DESCRIPTION|
+
+ The \cb{build2} driver performs a set of meta-operations on operations on
+ targets according to the build specification, or <buildspec> for short.
+ The buildspec has the following form:
+
+ \c{<meta-operation>(<operation>...(<target>...))...}
+
+ All three components can be omitted. If <meta-operation> is omitted, then
+ it defaults to \cb{perform}. If <operation> is omitted, then it default to
+ the default operation of this meta-operation. For \cb{perform} that would
+ be \cb{update}. Finally, if <target> is omitted, then it default to the
+ current directory. For example:
+
+ \
+ b # perform(update(./))
+ b foo/ # perform(update(foo/))
+ b foo/ bar/ # perform(update(foo/ bar/))
+ b update # perform(update(./))
+ b 'clean(../)' # perform(clean(../))
+ b perform # perform(update(./))
+ b configure # configure(?(./))
+ b clean update # perform(clean(./) update(./))
+ b configure update # configure(?(./)) perform(update(./))
+ \
+
+ Noice the question mark used to denote the default operation for the
+ \cb{configure} meta-operation. For \cb{configure} the default operation
+ is \"all operations\". That is, it will configure all the operations for
+ the specified target.
+
+ You can also \"generate\" multiple operation for the same set of targets.
+ Compare:
+
+ \
+ b 'clean(foo/ bar/)' 'update(foo/ bar/)'
+ b '{clean update}(foo/ bar/)'
+ \
+
+ Some more useful buildspec examples:
+
+ \
+ b '{clean update clean}(...)'
+ b '{clean test clean}(...)'
+ b '{clean disfigure}(...)' # similar to distclean
+ \
+
+ For each <target> the driver expects to find a \cb{buildfile} either in
+ the target's directory or, if the directory is part of the \cb{out} tree
+ (\cb{out_base}), in the corresponding \cb{src} directory (\cb{src_base}).
+
+ For example, assuming \cb{foo/} is the source directory of a project:
+
+ \
+ b foo/ # out_base=src_base=foo/
+ b foo-out/ # out_base=foo-out/ src_base=foo/
+ b foo-out/exe{foo} # out_base=foo-out/ src_base=foo/
+ \
+
+ In the above example, we assumed that the \c{build2} driver was able to
+ determine the association between \cb{out_base} and \cb{src_base}. This is
+ achieved in one of two ways: the \cb{config} module (which implements the
+ \cb{configure} and \cb{disfigure} meta-operations) saves this association
+ as part of the persistent configuration. If, however, the association
+ hasn't been saved, then we have to specify \cb{src_base} explicitly using
+ the following extended <target> syntax:
+
+ \c{<src-base>/@<target>}
+
+ Continuing with the previous example:
+
+ \
+ b foo/@foo-out/exe{foo} # out_base=foo-out/ src_base=foo/
+ \
+
+ Normally, you would only need to specify \cb{src_base} explicitly once,
+ during configuration. For example, a typical usage would be:
+
+ \
+ b foo/
+ b 'configure(foo/@foo-out/)' # src_base is saved
+ b foo-out/ # no need to specify src_base
+ b 'clean(foo-out/exe{foo}' # no need to specify src_base
+ \
+
+ \cb{build2} has the following build-in and pre-defined meta-operations.
+
+ \dl|
+
+ \li|\cb{perform}
+
+ Perform an operation.|
+
+ \li|\cb{configure}
+
+ Configure all operations in a project. Implemented by the \cb{config}
+ module.|
+
+ \li|\cb{disfigure}
+
+ Disfigure all operations in a project. Implemented by the \cb{config}
+ module.|
+
+ \li|\cb{dist}
+
+ Prepare a distribution for all operations in a project. Implemented
+ by the \cb{dist} module.||
+
+ \cb{build2} has the following build-in and pre-defined operations.
+
+ \dl|
+
+ \li|\cb{update}
+
+ Update a target.|
+
+ \li|\cb{clean}
+
+ Clean a target.|
+
+ \li|\cb{test}
+
+ Test a target. Performs \cb{update} as a pre-operation. Implemented by
+ the \cb{test} module.|
+
+ \li|\cb{install}
+
+ Install a target. Performs \cb{update} as a pre-operation. Implemented
+ by the \cb{install} module.||
+
+ Before <buildspec> (but after <options>) you can set one or more
+ \c{build2} <variables>. This is normally used to pass the configuration
+ values, for example:
+
+ \
+ b config.cxx=clang++ config.cxx.coptions=-O3 \
+ config.install.root=/usr/local config.install.root.sudo=sudo \
+ configure
+ \
+ "
+ }
+
+ class options
+ {
+ "\h|OPTIONS|"
+
+ bool -v
+ {
+ "Print actual commands being executed. This is equivalent to
+ \cb{--verbose 2}."
+ }
+
+ bool -q
+ {
+ "Run quietly, only printing error messages. This is equivalent to
+ \cb{--verbose 0}."
+ }
+
+ std::uint16_t --verbose = 1
+ {
+ "<level>",
+ "Set the diagnostics verbosity to <level> between 0 and 6. Level 0
+ disables any non-error messages while level 6 produces lots of
+ information, with level 1 beeing the default. The following additional
+ types of diagnostics are produced at each level:
+
+ \ol|
+
+ \li|High-level information messages.|
+
+ \li|Essential underlying commands being executed.|
+
+ \li|All underlying commands being executed.|
+
+ \li|Information that could be helpful to the user.|
+
+ \li|Information that could be helpful to the developer.|
+
+ \li|Even more detailed information, including state dumps.||"
+ };
+
+ bool --help {"Print usage information and exit."};
+ bool --version {"Print version and exit."};
+ };
+
+ "\h|EXIT STATUS|
+
+ Non-zero exit status is returned in case of an error.
+ "
+
+ "\h|ENVIRONMENT|
+
+ The \cb{HOME} environment variable is used to determine the user's home
+ directory. If it is not set, then \cb{getpwuid(3)} is used instead. This
+ value is used to shorten paths printed in diagnostics by replacing it with
+ '\cb{~}'. It is also made available to the buildfiles as the \cb{build.home}
+ variable.
+ "
+}
diff --git a/build2/b.cxx b/build2/b.cxx
index c6a118e..96a480a 100644
--- a/build2/b.cxx
+++ b/build2/b.cxx
@@ -39,7 +39,7 @@
#include <build2/lexer>
#include <build2/parser>
-#include <build2/options>
+#include <build2/b-options>
using namespace std;
diff --git a/build2/buildfile b/build2/buildfile
index 6fd0cac..412b348 100644
--- a/build2/buildfile
+++ b/build2/buildfile
@@ -7,6 +7,7 @@ import libs = libbutl%lib{butl}
exe{b}: \
{hxx ixx txx cxx}{ algorithm } \
{ cxx}{ b } \
+ {hxx ixx cxx}{ b-options } \
{hxx txx cxx}{ context } \
{hxx cxx}{ diagnostics } \
{hxx cxx}{ dump } \
@@ -15,7 +16,6 @@ exe{b}: \
{hxx cxx}{ module } \
{hxx cxx}{ name } \
{hxx cxx}{ operation } \
- {hxx ixx cxx}{ options } \
{hxx cxx}{ parser } \
{hxx cxx}{ path-io } \
{hxx cxx}{ prerequisite } \
@@ -59,6 +59,33 @@ install/{hxx }{ utility } \
test/{hxx cxx}{ rule } \
$libs
-#@@ TODO, also remove gen files from the repository/add to .gitignore
+# Load the cli module but only if it's available. This way a distribution
+# that includes pre-generated files can be built without installing cli.
+# This is also the reason why above we explicitly spelled out individual
+# source files instead of using the cli.cxx{} group (it won't be there
+# unless the module is loaded).
#
-# cli --generate-specifier --cli-namespace cl --include-with-brackets --include-prefix build2 --guard-prefix BUILD2 --hxx-suffix "" options.cli
+using? cli
+
+if! $cli.loaded
+{
+ define cli: file
+ cli{*}: extension = cli
+}
+
+{hxx ixx cxx}{b-options}: cli{b}
+
+cli.options += -I $src_root --include-with-brackets --include-prefix build2 \
+--guard-prefix BUILD2 --cli-namespace build2::cl --generate-file-scanner \
+--generate-specifier
+
+# Usage options.
+#
+cli.options += --suppress-undocumented --long-usage --ansi-color \
+--page-usage 'build2::print_$name$_' --option-length 23
+
+# Include generated cli files into the distribution.
+#
+hxx{*-options}: dist = true
+ixx{*-options}: dist = true
+cxx{*-options}: dist = true
diff --git a/build2/operation b/build2/operation
index 7b1dd70..c5af3ed 100644
--- a/build2/operation
+++ b/build2/operation
@@ -109,8 +109,9 @@ namespace build2
const meta_operation_id disfigure_id = 3;
const meta_operation_id dist_id = 4;
- // The default operation is a special marker that can be used to
- // indicate that no operation was explicitly specified by the user.
+ // The default operation is a special marker that can be used to indicate
+ // that no operation was explicitly specified by the user. If adding
+ // something here remember to update the man page.
//
const operation_id default_id = 1; // Shall be first.
const operation_id update_id = 2;
diff --git a/build2/options b/build2/options
deleted file mode 100644
index 596980e..0000000
--- a/build2/options
+++ /dev/null
@@ -1,328 +0,0 @@
-// -*- C++ -*-
-//
-// This file was generated by CLI, a command line interface
-// compiler for C++.
-//
-
-#ifndef BUILD2_OPTIONS
-#define BUILD2_OPTIONS
-
-// Begin prologue.
-//
-//
-// End prologue.
-
-#include <iosfwd>
-#include <string>
-#include <cstddef>
-#include <exception>
-
-#ifndef CLI_POTENTIALLY_UNUSED
-# if defined(_MSC_VER) || defined(__xlC__)
-# define CLI_POTENTIALLY_UNUSED(x) (void*)&x
-# else
-# define CLI_POTENTIALLY_UNUSED(x) (void)x
-# endif
-#endif
-
-namespace cl
-{
- class usage_para
- {
- public:
- enum value
- {
- none,
- text,
- option
- };
-
- usage_para (value);
-
- operator value () const
- {
- return v_;
- }
-
- private:
- value v_;
- };
-
- class unknown_mode
- {
- public:
- enum value
- {
- skip,
- stop,
- fail
- };
-
- unknown_mode (value);
-
- operator value () const
- {
- return v_;
- }
-
- private:
- value v_;
- };
-
- // Exceptions.
- //
-
- class exception: public std::exception
- {
- public:
- virtual void
- print (::std::ostream&) const = 0;
- };
-
- ::std::ostream&
- operator<< (::std::ostream&, const exception&);
-
- class unknown_option: public exception
- {
- public:
- virtual
- ~unknown_option () throw ();
-
- unknown_option (const std::string& option);
-
- const std::string&
- option () const;
-
- virtual void
- print (::std::ostream&) const;
-
- virtual const char*
- what () const throw ();
-
- private:
- std::string option_;
- };
-
- class unknown_argument: public exception
- {
- public:
- virtual
- ~unknown_argument () throw ();
-
- unknown_argument (const std::string& argument);
-
- const std::string&
- argument () const;
-
- virtual void
- print (::std::ostream&) const;
-
- virtual const char*
- what () const throw ();
-
- private:
- std::string argument_;
- };
-
- class missing_value: public exception
- {
- public:
- virtual
- ~missing_value () throw ();
-
- missing_value (const std::string& option);
-
- const std::string&
- option () const;
-
- virtual void
- print (::std::ostream&) const;
-
- virtual const char*
- what () const throw ();
-
- private:
- std::string option_;
- };
-
- class invalid_value: public exception
- {
- public:
- virtual
- ~invalid_value () throw ();
-
- invalid_value (const std::string& option,
- const std::string& value);
-
- const std::string&
- option () const;
-
- const std::string&
- value () const;
-
- virtual void
- print (::std::ostream&) const;
-
- virtual const char*
- what () const throw ();
-
- private:
- std::string option_;
- std::string value_;
- };
-
- class eos_reached: public exception
- {
- public:
- virtual void
- print (::std::ostream&) const;
-
- virtual const char*
- what () const throw ();
- };
-
- class scanner
- {
- public:
- virtual
- ~scanner ();
-
- virtual bool
- more () = 0;
-
- virtual const char*
- peek () = 0;
-
- virtual const char*
- next () = 0;
-
- virtual void
- skip () = 0;
- };
-
- class argv_scanner: public scanner
- {
- public:
- argv_scanner (int& argc, char** argv, bool erase = false);
- argv_scanner (int start, int& argc, char** argv, bool erase = false);
-
- int
- end () const;
-
- virtual bool
- more ();
-
- virtual const char*
- peek ();
-
- virtual const char*
- next ();
-
- virtual void
- skip ();
-
- private:
- int i_;
- int& argc_;
- char** argv_;
- bool erase_;
- };
-
- template <typename X>
- struct parser;
-}
-
-#include <cstdint>
-
-class options
-{
- public:
- options ();
-
- options (int& argc,
- char** argv,
- bool erase = false,
- ::cl::unknown_mode option = ::cl::unknown_mode::fail,
- ::cl::unknown_mode argument = ::cl::unknown_mode::stop);
-
- options (int start,
- int& argc,
- char** argv,
- bool erase = false,
- ::cl::unknown_mode option = ::cl::unknown_mode::fail,
- ::cl::unknown_mode argument = ::cl::unknown_mode::stop);
-
- options (int& argc,
- char** argv,
- int& end,
- bool erase = false,
- ::cl::unknown_mode option = ::cl::unknown_mode::fail,
- ::cl::unknown_mode argument = ::cl::unknown_mode::stop);
-
- options (int start,
- int& argc,
- char** argv,
- int& end,
- bool erase = false,
- ::cl::unknown_mode option = ::cl::unknown_mode::fail,
- ::cl::unknown_mode argument = ::cl::unknown_mode::stop);
-
- options (::cl::scanner&,
- ::cl::unknown_mode option = ::cl::unknown_mode::fail,
- ::cl::unknown_mode argument = ::cl::unknown_mode::stop);
-
- // Option accessors.
- //
- const bool&
- help () const;
-
- const bool&
- version () const;
-
- const bool&
- v () const;
-
- const bool&
- q () const;
-
- const std::uint16_t&
- verbose () const;
-
- bool
- verbose_specified () const;
-
- // Print usage information.
- //
- static ::cl::usage_para
- print_usage (::std::ostream&,
- ::cl::usage_para = ::cl::usage_para::none);
-
- // Implementation details.
- //
- protected:
- bool
- _parse (const char*, ::cl::scanner&);
-
- private:
- void
- _parse (::cl::scanner&,
- ::cl::unknown_mode option,
- ::cl::unknown_mode argument);
-
- public:
- bool help_;
- bool version_;
- bool v_;
- bool q_;
- std::uint16_t verbose_;
- bool verbose_specified_;
-};
-
-#include <build2/options.ixx>
-
-// Begin epilogue.
-//
-//
-// End epilogue.
-
-#endif // BUILD2_OPTIONS
diff --git a/build2/options.cli b/build2/options.cli
deleted file mode 100644
index 3fd2c02..0000000
--- a/build2/options.cli
+++ /dev/null
@@ -1,31 +0,0 @@
-// file : build2/options.cli
-// copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
-// license : MIT; see accompanying LICENSE file
-
-include <cstdint>;
-
-class options
-{
- bool --help {"Print usage information and exit."};
- bool --version {"Print version and exit."};
-
- bool -v
- {
- "Print actual commands being executed. This is equivalent to
- \cb{--verbose 2}."
- };
-
- bool -q
- {
- "Run quietly, only printing error messages. This is equivalent
- to \cb{--verbose 0}."
- };
-
- std::uint16_t --verbose = 1
- {
- "<level>",
- "Set the diagnostics verbosity to <level> between 0 (disabled) and
- 6 (lots of information). The default is 1. @@ Need to document
- further."
- };
-};
diff --git a/build2/options.cxx b/build2/options.cxx
deleted file mode 100644
index aa72be1..0000000
--- a/build2/options.cxx
+++ /dev/null
@@ -1,549 +0,0 @@
-// -*- C++ -*-
-//
-// This file was generated by CLI, a command line interface
-// compiler for C++.
-//
-
-// Begin prologue.
-//
-//
-// End prologue.
-
-#include <build2/options>
-
-#include <map>
-#include <set>
-#include <string>
-#include <vector>
-#include <ostream>
-#include <sstream>
-
-namespace cl
-{
- // unknown_option
- //
- unknown_option::
- ~unknown_option () throw ()
- {
- }
-
- void unknown_option::
- print (::std::ostream& os) const
- {
- os << "unknown option '" << option ().c_str () << "'";
- }
-
- const char* unknown_option::
- what () const throw ()
- {
- return "unknown option";
- }
-
- // unknown_argument
- //
- unknown_argument::
- ~unknown_argument () throw ()
- {
- }
-
- void unknown_argument::
- print (::std::ostream& os) const
- {
- os << "unknown argument '" << argument ().c_str () << "'";
- }
-
- const char* unknown_argument::
- what () const throw ()
- {
- return "unknown argument";
- }
-
- // missing_value
- //
- missing_value::
- ~missing_value () throw ()
- {
- }
-
- void missing_value::
- print (::std::ostream& os) const
- {
- os << "missing value for option '" << option ().c_str () << "'";
- }
-
- const char* missing_value::
- what () const throw ()
- {
- return "missing option value";
- }
-
- // invalid_value
- //
- invalid_value::
- ~invalid_value () throw ()
- {
- }
-
- void invalid_value::
- print (::std::ostream& os) const
- {
- os << "invalid value '" << value ().c_str () << "' for option '"
- << option ().c_str () << "'";
- }
-
- const char* invalid_value::
- what () const throw ()
- {
- return "invalid option value";
- }
-
- // eos_reached
- //
- void eos_reached::
- print (::std::ostream& os) const
- {
- os << what ();
- }
-
- const char* eos_reached::
- what () const throw ()
- {
- return "end of argument stream reached";
- }
-
- // scanner
- //
- scanner::
- ~scanner ()
- {
- }
-
- // argv_scanner
- //
- bool argv_scanner::
- more ()
- {
- return i_ < argc_;
- }
-
- const char* argv_scanner::
- peek ()
- {
- if (i_ < argc_)
- return argv_[i_];
- else
- throw eos_reached ();
- }
-
- const char* argv_scanner::
- next ()
- {
- if (i_ < argc_)
- {
- const char* r (argv_[i_]);
-
- if (erase_)
- {
- for (int i (i_ + 1); i < argc_; ++i)
- argv_[i - 1] = argv_[i];
-
- --argc_;
- argv_[argc_] = 0;
- }
- else
- ++i_;
-
- return r;
- }
- else
- throw eos_reached ();
- }
-
- void argv_scanner::
- skip ()
- {
- if (i_ < argc_)
- ++i_;
- else
- throw eos_reached ();
- }
-
- template <typename X>
- struct parser
- {
- static void
- parse (X& x, bool& xs, scanner& s)
- {
- std::string o (s.next ());
-
- if (s.more ())
- {
- std::string v (s.next ());
- std::istringstream is (v);
- if (!(is >> x && is.eof ()))
- throw invalid_value (o, v);
- }
- else
- throw missing_value (o);
-
- xs = true;
- }
- };
-
- template <>
- struct parser<bool>
- {
- static void
- parse (bool& x, scanner& s)
- {
- s.next ();
- x = true;
- }
- };
-
- template <>
- struct parser<std::string>
- {
- static void
- parse (std::string& x, bool& xs, scanner& s)
- {
- const char* o (s.next ());
-
- if (s.more ())
- x = s.next ();
- else
- throw missing_value (o);
-
- xs = true;
- }
- };
-
- template <typename X>
- struct parser<std::vector<X> >
- {
- static void
- parse (std::vector<X>& c, bool& xs, scanner& s)
- {
- X x;
- bool dummy;
- parser<X>::parse (x, dummy, s);
- c.push_back (x);
- xs = true;
- }
- };
-
- template <typename X>
- struct parser<std::set<X> >
- {
- static void
- parse (std::set<X>& c, bool& xs, scanner& s)
- {
- X x;
- bool dummy;
- parser<X>::parse (x, dummy, s);
- c.insert (x);
- xs = true;
- }
- };
-
- template <typename K, typename V>
- struct parser<std::map<K, V> >
- {
- static void
- parse (std::map<K, V>& m, bool& xs, scanner& s)
- {
- const char* o (s.next ());
-
- if (s.more ())
- {
- std::string ov (s.next ());
- std::string::size_type p = ov.find ('=');
-
- K k = K ();
- V v = V ();
- std::string kstr (ov, 0, p);
- std::string vstr (ov, (p != std::string::npos ? p + 1 : ov.size ()));
-
- int ac (2);
- char* av[] =
- {
- const_cast<char*> (o), 0
- };
-
- bool dummy;
- if (!kstr.empty ())
- {
- av[1] = const_cast<char*> (kstr.c_str ());
- argv_scanner s (0, ac, av);
- parser<K>::parse (k, dummy, s);
- }
-
- if (!vstr.empty ())
- {
- av[1] = const_cast<char*> (vstr.c_str ());
- argv_scanner s (0, ac, av);
- parser<V>::parse (v, dummy, s);
- }
-
- m[k] = v;
- }
- else
- throw missing_value (o);
-
- xs = true;
- }
- };
-
- template <typename X, typename T, T X::*M>
- void
- thunk (X& x, scanner& s)
- {
- parser<T>::parse (x.*M, s);
- }
-
- template <typename X, typename T, T X::*M, bool X::*S>
- void
- thunk (X& x, scanner& s)
- {
- parser<T>::parse (x.*M, x.*S, s);
- }
-}
-
-#include <map>
-#include <cstring>
-
-// options
-//
-
-options::
-options ()
-: help_ (),
- version_ (),
- v_ (),
- q_ (),
- verbose_ (1),
- verbose_specified_ (false)
-{
-}
-
-options::
-options (int& argc,
- char** argv,
- bool erase,
- ::cl::unknown_mode opt,
- ::cl::unknown_mode arg)
-: help_ (),
- version_ (),
- v_ (),
- q_ (),
- verbose_ (1),
- verbose_specified_ (false)
-{
- ::cl::argv_scanner s (argc, argv, erase);
- _parse (s, opt, arg);
-}
-
-options::
-options (int start,
- int& argc,
- char** argv,
- bool erase,
- ::cl::unknown_mode opt,
- ::cl::unknown_mode arg)
-: help_ (),
- version_ (),
- v_ (),
- q_ (),
- verbose_ (1),
- verbose_specified_ (false)
-{
- ::cl::argv_scanner s (start, argc, argv, erase);
- _parse (s, opt, arg);
-}
-
-options::
-options (int& argc,
- char** argv,
- int& end,
- bool erase,
- ::cl::unknown_mode opt,
- ::cl::unknown_mode arg)
-: help_ (),
- version_ (),
- v_ (),
- q_ (),
- verbose_ (1),
- verbose_specified_ (false)
-{
- ::cl::argv_scanner s (argc, argv, erase);
- _parse (s, opt, arg);
- end = s.end ();
-}
-
-options::
-options (int start,
- int& argc,
- char** argv,
- int& end,
- bool erase,
- ::cl::unknown_mode opt,
- ::cl::unknown_mode arg)
-: help_ (),
- version_ (),
- v_ (),
- q_ (),
- verbose_ (1),
- verbose_specified_ (false)
-{
- ::cl::argv_scanner s (start, argc, argv, erase);
- _parse (s, opt, arg);
- end = s.end ();
-}
-
-options::
-options (::cl::scanner& s,
- ::cl::unknown_mode opt,
- ::cl::unknown_mode arg)
-: help_ (),
- version_ (),
- v_ (),
- q_ (),
- verbose_ (1),
- verbose_specified_ (false)
-{
- _parse (s, opt, arg);
-}
-
-::cl::usage_para options::
-print_usage (::std::ostream& os, ::cl::usage_para p)
-{
- CLI_POTENTIALLY_UNUSED (os);
-
- if (p == ::cl::usage_para::text)
- os << ::std::endl;
-
- os << "--help Print usage information and exit." << ::std::endl;
-
- os << "--version Print version and exit." << ::std::endl;
-
- os << "-v Print actual commands being executed." << ::std::endl;
-
- os << "-q Run quietly, only printing error messages." << ::std::endl;
-
- os << "--verbose <level> Set the diagnostics verbosity to <level> between 0 (disabled)" << ::std::endl
- << " and 6 (lots of information)." << ::std::endl;
-
- p = ::cl::usage_para::option;
-
- return p;
-}
-
-typedef
-std::map<std::string, void (*) (options&, ::cl::scanner&)>
-_cli_options_map;
-
-static _cli_options_map _cli_options_map_;
-
-struct _cli_options_map_init
-{
- _cli_options_map_init ()
- {
- _cli_options_map_["--help"] =
- &::cl::thunk< options, bool, &options::help_ >;
- _cli_options_map_["--version"] =
- &::cl::thunk< options, bool, &options::version_ >;
- _cli_options_map_["-v"] =
- &::cl::thunk< options, bool, &options::v_ >;
- _cli_options_map_["-q"] =
- &::cl::thunk< options, bool, &options::q_ >;
- _cli_options_map_["--verbose"] =
- &::cl::thunk< options, std::uint16_t, &options::verbose_,
- &options::verbose_specified_ >;
- }
-};
-
-static _cli_options_map_init _cli_options_map_init_;
-
-bool options::
-_parse (const char* o, ::cl::scanner& s)
-{
- _cli_options_map::const_iterator i (_cli_options_map_.find (o));
-
- if (i != _cli_options_map_.end ())
- {
- (*(i->second)) (*this, s);
- return true;
- }
-
- return false;
-}
-
-void options::
-_parse (::cl::scanner& s,
- ::cl::unknown_mode opt_mode,
- ::cl::unknown_mode arg_mode)
-{
- bool opt = true;
-
- while (s.more ())
- {
- const char* o = s.peek ();
-
- if (std::strcmp (o, "--") == 0)
- {
- s.skip ();
- opt = false;
- continue;
- }
-
- if (opt && _parse (o, s));
- else if (opt && std::strncmp (o, "-", 1) == 0 && o[1] != '\0')
- {
- switch (opt_mode)
- {
- case ::cl::unknown_mode::skip:
- {
- s.skip ();
- continue;
- }
- case ::cl::unknown_mode::stop:
- {
- break;
- }
- case ::cl::unknown_mode::fail:
- {
- throw ::cl::unknown_option (o);
- }
- }
-
- break;
- }
- else
- {
- switch (arg_mode)
- {
- case ::cl::unknown_mode::skip:
- {
- s.skip ();
- continue;
- }
- case ::cl::unknown_mode::stop:
- {
- break;
- }
- case ::cl::unknown_mode::fail:
- {
- throw ::cl::unknown_argument (o);
- }
- }
-
- break;
- }
- }
-}
-
-// Begin epilogue.
-//
-//
-// End epilogue.
-
diff --git a/build2/options.ixx b/build2/options.ixx
deleted file mode 100644
index 245e0c0..0000000
--- a/build2/options.ixx
+++ /dev/null
@@ -1,165 +0,0 @@
-// -*- C++ -*-
-//
-// This file was generated by CLI, a command line interface
-// compiler for C++.
-//
-
-// Begin prologue.
-//
-//
-// End prologue.
-
-namespace cl
-{
- // usage_para
- //
- inline usage_para::
- usage_para (value v)
- : v_ (v)
- {
- }
-
- // unknown_mode
- //
- inline unknown_mode::
- unknown_mode (value v)
- : v_ (v)
- {
- }
-
- // exception
- //
- inline ::std::ostream&
- operator<< (::std::ostream& os, const exception& e)
- {
- e.print (os);
- return os;
- }
-
- // unknown_option
- //
- inline unknown_option::
- unknown_option (const std::string& option)
- : option_ (option)
- {
- }
-
- inline const std::string& unknown_option::
- option () const
- {
- return option_;
- }
-
- // unknown_argument
- //
- inline unknown_argument::
- unknown_argument (const std::string& argument)
- : argument_ (argument)
- {
- }
-
- inline const std::string& unknown_argument::
- argument () const
- {
- return argument_;
- }
-
- // missing_value
- //
- inline missing_value::
- missing_value (const std::string& option)
- : option_ (option)
- {
- }
-
- inline const std::string& missing_value::
- option () const
- {
- return option_;
- }
-
- // invalid_value
- //
- inline invalid_value::
- invalid_value (const std::string& option,
- const std::string& value)
- : option_ (option), value_ (value)
- {
- }
-
- inline const std::string& invalid_value::
- option () const
- {
- return option_;
- }
-
- inline const std::string& invalid_value::
- value () const
- {
- return value_;
- }
-
- // argv_scanner
- //
- inline argv_scanner::
- argv_scanner (int& argc, char** argv, bool erase)
- : i_ (1), argc_ (argc), argv_ (argv), erase_ (erase)
- {
- }
-
- inline argv_scanner::
- argv_scanner (int start, int& argc, char** argv, bool erase)
- : i_ (start), argc_ (argc), argv_ (argv), erase_ (erase)
- {
- }
-
- inline int argv_scanner::
- end () const
- {
- return i_;
- }
-}
-
-// options
-//
-
-inline const bool& options::
-help () const
-{
- return this->help_;
-}
-
-inline const bool& options::
-version () const
-{
- return this->version_;
-}
-
-inline const bool& options::
-v () const
-{
- return this->v_;
-}
-
-inline const bool& options::
-q () const
-{
- return this->q_;
-}
-
-inline const std::uint16_t& options::
-verbose () const
-{
- return this->verbose_;
-}
-
-inline bool options::
-verbose_specified () const
-{
- return this->verbose_specified_;
-}
-
-// Begin epilogue.
-//
-//
-// End epilogue.