From 4bbb90782628d40cd52e03e078611ad38cd74936 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 22 Apr 2020 12:50:14 +0200 Subject: Update metadata protocol --- cli/cli/buildfile | 3 ++- cli/cli/cli.cxx | 10 +++++++--- cli/cli/options.cli | 3 ++- cli/cli/options.cxx | 11 +++++++++-- cli/cli/options.hxx | 17 +++++++++++++---- cli/cli/options.ixx | 18 +++++++++++++++--- cli/cli/version.hxx.in | 2 +- 7 files changed, 49 insertions(+), 15 deletions(-) (limited to 'cli') diff --git a/cli/cli/buildfile b/cli/cli/buildfile index ff562c2..b468ab4 100644 --- a/cli/cli/buildfile +++ b/cli/cli/buildfile @@ -9,7 +9,8 @@ import libs = libcutl%lib{cutl} # exe{cli}: { - cli.version = $version.project_id + export.metadata = 1 + cli.version = $version cli.checksum = $version } diff --git a/cli/cli/cli.cxx b/cli/cli/cli.cxx index c57caee..6c51aae 100644 --- a/cli/cli/cli.cxx +++ b/cli/cli/cli.cxx @@ -34,13 +34,17 @@ main (int argc, char* argv[]) // Handle --build2-metadata (see also buildfile). // - if (ops.build2_metadata ()) + if (ops.build2_metadata_specified ()) { ostream& o (cout); + // Note that the export.metadata variable should be the first non- + // blank/comment line. + // o << "# build2 buildfile cli" << endl - << "cli.version = '" << CLI_VERSION_ID << '\'' << endl - << "cli.checksum = '" << CLI_CHECKSUM << '\'' << endl; + << "export.metadata = 1" << endl + << "cli.version = [string] '" << CLI_VERSION_FULL << '\'' << endl + << "cli.checksum = [string] '" << CLI_VERSION_FULL << '\'' << endl; return 0; } diff --git a/cli/cli/options.cli b/cli/cli/options.cli index e564bc4..ff462d3 100644 --- a/cli/cli/options.cli +++ b/cli/cli/options.cli @@ -10,12 +10,13 @@ include ; include ; include ; include ; +include ; include ; class options { - bool --build2-metadata; // Leave undocumented/hidden. + std::uint64_t --build2-metadata; // Leave undocumented/hidden. bool --help {"Print usage information and exit."}; bool --version {"Print version and exit."}; diff --git a/cli/cli/options.cxx b/cli/cli/options.cxx index cc22a35..463973a 100644 --- a/cli/cli/options.cxx +++ b/cli/cli/options.cxx @@ -629,6 +629,7 @@ namespace cli options:: options () : build2_metadata_ (), + build2_metadata_specified_ (false), help_ (), version_ (), include_path_ (), @@ -769,6 +770,7 @@ options (int& argc, ::cli::unknown_mode opt, ::cli::unknown_mode arg) : build2_metadata_ (), + build2_metadata_specified_ (false), help_ (), version_ (), include_path_ (), @@ -912,6 +914,7 @@ options (int start, ::cli::unknown_mode opt, ::cli::unknown_mode arg) : build2_metadata_ (), + build2_metadata_specified_ (false), help_ (), version_ (), include_path_ (), @@ -1055,6 +1058,7 @@ options (int& argc, ::cli::unknown_mode opt, ::cli::unknown_mode arg) : build2_metadata_ (), + build2_metadata_specified_ (false), help_ (), version_ (), include_path_ (), @@ -1200,6 +1204,7 @@ options (int start, ::cli::unknown_mode opt, ::cli::unknown_mode arg) : build2_metadata_ (), + build2_metadata_specified_ (false), help_ (), version_ (), include_path_ (), @@ -1341,6 +1346,7 @@ options (::cli::scanner& s, ::cli::unknown_mode opt, ::cli::unknown_mode arg) : build2_metadata_ (), + build2_metadata_specified_ (false), help_ (), version_ (), include_path_ (), @@ -1483,7 +1489,7 @@ print_usage (::std::ostream& os, ::cli::usage_para p) if (p == ::cli::usage_para::text) os << ::std::endl; - os << "--build2-metadata" << std::endl; + os << "--build2-metadata " << std::endl; os << "--help Print usage information and exit." << ::std::endl; @@ -1734,7 +1740,8 @@ struct _cli_options_map_init _cli_options_map_init () { _cli_options_map_["--build2-metadata"] = - &::cli::thunk< options, bool, &options::build2_metadata_ >; + &::cli::thunk< options, std::uint64_t, &options::build2_metadata_, + &options::build2_metadata_specified_ >; _cli_options_map_["--help"] = &::cli::thunk< options, bool, &options::help_ >; _cli_options_map_["--version"] = diff --git a/cli/cli/options.hxx b/cli/cli/options.hxx index b253092..b54d81f 100644 --- a/cli/cli/options.hxx +++ b/cli/cli/options.hxx @@ -400,6 +400,8 @@ namespace cli #include +#include + #include class options @@ -441,14 +443,20 @@ class options // Option accessors and modifiers. // - const bool& + const std::uint64_t& build2_metadata () const; - bool& + std::uint64_t& build2_metadata (); void - build2_metadata (const bool&); + build2_metadata (const std::uint64_t&); + + bool + build2_metadata_specified () const; + + void + build2_metadata_specified (bool); const bool& help () const; @@ -1489,7 +1497,8 @@ class options ::cli::unknown_mode argument); public: - bool build2_metadata_; + std::uint64_t build2_metadata_; + bool build2_metadata_specified_; bool help_; bool version_; std::vector include_path_; diff --git a/cli/cli/options.ixx b/cli/cli/options.ixx index 12d40db..5916883 100644 --- a/cli/cli/options.ixx +++ b/cli/cli/options.ixx @@ -255,24 +255,36 @@ namespace cli // options // -inline const bool& options:: +inline const std::uint64_t& options:: build2_metadata () const { return this->build2_metadata_; } -inline bool& options:: +inline std::uint64_t& options:: build2_metadata () { return this->build2_metadata_; } inline void options:: -build2_metadata(const bool& x) +build2_metadata(const std::uint64_t& x) { this->build2_metadata_ = x; } +inline bool options:: +build2_metadata_specified () const +{ + return this->build2_metadata_specified_; +} + +inline void options:: +build2_metadata_specified(bool x) +{ + this->build2_metadata_specified_ = x; +} + inline const bool& options:: help () const { diff --git a/cli/cli/version.hxx.in b/cli/cli/version.hxx.in index 90b649a..ceb5389 100644 --- a/cli/cli/version.hxx.in +++ b/cli/cli/version.hxx.in @@ -36,7 +36,7 @@ #define CLI_SNAPSHOT $cli.version.snapshot_sn$ULL #define CLI_SNAPSHOT_ID "$cli.version.snapshot_id$" -#define CLI_CHECKSUM "$cli.version$" +#define CLI_VERSION_FULL "$cli.version$" #include -- cgit v1.1