summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-04-21 12:02:15 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-04-21 12:02:15 +0200
commit3183f3bb927a90783ae0aeaf190a0919377aabe4 (patch)
tree0e66080e788c61651ae44de62a6d722bef8a0fe1 /cli
parent7b04b179fb7831087474d9cba104fa6076e31c47 (diff)
Add metadata
Diffstat (limited to 'cli')
-rw-r--r--cli/buildfile6
-rw-r--r--cli/cli.cxx13
-rw-r--r--cli/options.cli2
-rw-r--r--cli/options.cxx22
-rw-r--r--cli/options.hxx10
-rw-r--r--cli/options.ixx18
-rw-r--r--cli/version.hxx.in2
7 files changed, 67 insertions, 6 deletions
diff --git a/cli/buildfile b/cli/buildfile
index 7d634e0..d6723d0 100644
--- a/cli/buildfile
+++ b/cli/buildfile
@@ -4,6 +4,12 @@
import libs = libcutl%lib{cutl}
exe{cli}: cxx{cli} libue{cli}
+{
+ # Target metadata, see also --build2-metadata in cli.cxx.
+ #
+ cli.version = $version.project_id
+ cli.checksum = $version
+}
libue{cli}: {hxx ixx txx cxx}{** -cli -version -options} \
{hxx}{version} {hxx ixx cxx}{options} \
diff --git a/cli/cli.cxx b/cli/cli.cxx
index 0c7f3a1..c57caee 100644
--- a/cli/cli.cxx
+++ b/cli/cli.cxx
@@ -32,6 +32,19 @@ main (int argc, char* argv[])
cli::argv_file_scanner scan (argc, argv, "--options-file");
options ops (scan);
+ // Handle --build2-metadata (see also buildfile).
+ //
+ if (ops.build2_metadata ())
+ {
+ ostream& o (cout);
+
+ o << "# build2 buildfile cli" << endl
+ << "cli.version = '" << CLI_VERSION_ID << '\'' << endl
+ << "cli.checksum = '" << CLI_CHECKSUM << '\'' << endl;
+
+ return 0;
+ }
+
// Handle --version
//
if (ops.version ())
diff --git a/cli/options.cli b/cli/options.cli
index 3f7b24d..e564bc4 100644
--- a/cli/options.cli
+++ b/cli/options.cli
@@ -15,6 +15,8 @@ include <cli/option-types.hxx>;
class options
{
+ bool --build2-metadata; // Leave undocumented/hidden.
+
bool --help {"Print usage information and exit."};
bool --version {"Print version and exit."};
diff --git a/cli/options.cxx b/cli/options.cxx
index 1e782e3..cc22a35 100644
--- a/cli/options.cxx
+++ b/cli/options.cxx
@@ -628,7 +628,8 @@ namespace cli
options::
options ()
-: help_ (),
+: build2_metadata_ (),
+ help_ (),
version_ (),
include_path_ (),
include_path_specified_ (false),
@@ -767,7 +768,8 @@ options (int& argc,
bool erase,
::cli::unknown_mode opt,
::cli::unknown_mode arg)
-: help_ (),
+: build2_metadata_ (),
+ help_ (),
version_ (),
include_path_ (),
include_path_specified_ (false),
@@ -909,7 +911,8 @@ options (int start,
bool erase,
::cli::unknown_mode opt,
::cli::unknown_mode arg)
-: help_ (),
+: build2_metadata_ (),
+ help_ (),
version_ (),
include_path_ (),
include_path_specified_ (false),
@@ -1051,7 +1054,8 @@ options (int& argc,
bool erase,
::cli::unknown_mode opt,
::cli::unknown_mode arg)
-: help_ (),
+: build2_metadata_ (),
+ help_ (),
version_ (),
include_path_ (),
include_path_specified_ (false),
@@ -1195,7 +1199,8 @@ options (int start,
bool erase,
::cli::unknown_mode opt,
::cli::unknown_mode arg)
-: help_ (),
+: build2_metadata_ (),
+ help_ (),
version_ (),
include_path_ (),
include_path_specified_ (false),
@@ -1335,7 +1340,8 @@ options::
options (::cli::scanner& s,
::cli::unknown_mode opt,
::cli::unknown_mode arg)
-: help_ (),
+: build2_metadata_ (),
+ help_ (),
version_ (),
include_path_ (),
include_path_specified_ (false),
@@ -1477,6 +1483,8 @@ print_usage (::std::ostream& os, ::cli::usage_para p)
if (p == ::cli::usage_para::text)
os << ::std::endl;
+ os << "--build2-metadata" << std::endl;
+
os << "--help Print usage information and exit." << ::std::endl;
os << "--version Print version and exit." << ::std::endl;
@@ -1725,6 +1733,8 @@ struct _cli_options_map_init
{
_cli_options_map_init ()
{
+ _cli_options_map_["--build2-metadata"] =
+ &::cli::thunk< options, bool, &options::build2_metadata_ >;
_cli_options_map_["--help"] =
&::cli::thunk< options, bool, &options::help_ >;
_cli_options_map_["--version"] =
diff --git a/cli/options.hxx b/cli/options.hxx
index 6533432..b253092 100644
--- a/cli/options.hxx
+++ b/cli/options.hxx
@@ -442,6 +442,15 @@ class options
// Option accessors and modifiers.
//
const bool&
+ build2_metadata () const;
+
+ bool&
+ build2_metadata ();
+
+ void
+ build2_metadata (const bool&);
+
+ const bool&
help () const;
bool&
@@ -1480,6 +1489,7 @@ class options
::cli::unknown_mode argument);
public:
+ bool build2_metadata_;
bool help_;
bool version_;
std::vector<std::string> include_path_;
diff --git a/cli/options.ixx b/cli/options.ixx
index 2b63fa8..12d40db 100644
--- a/cli/options.ixx
+++ b/cli/options.ixx
@@ -256,6 +256,24 @@ namespace cli
//
inline const bool& options::
+build2_metadata () const
+{
+ return this->build2_metadata_;
+}
+
+inline bool& options::
+build2_metadata ()
+{
+ return this->build2_metadata_;
+}
+
+inline void options::
+build2_metadata(const bool& x)
+{
+ this->build2_metadata_ = x;
+}
+
+inline const bool& options::
help () const
{
return this->help_;
diff --git a/cli/version.hxx.in b/cli/version.hxx.in
index 610315e..90b649a 100644
--- a/cli/version.hxx.in
+++ b/cli/version.hxx.in
@@ -36,6 +36,8 @@
#define CLI_SNAPSHOT $cli.version.snapshot_sn$ULL
#define CLI_SNAPSHOT_ID "$cli.version.snapshot_id$"
+#define CLI_CHECKSUM "$cli.version$"
+
#include <cutl/version.hxx>
$libcutl.check(LIBCUTL_VERSION, LIBCUTL_SNAPSHOT)$