From 52191803ef99412ee7441585f82463999482930b Mon Sep 17 00:00:00 2001 From: "James P. Howard, II" Date: Fri, 17 Jun 2022 21:13:05 -0400 Subject: [PATCH] Redo versioning with neargye-semver --- conanfile.py | 1 + examples/boltzmann1d/boltzmann1d.cc | 2 +- examples/boltzmann2d/boltzmann2d.cc | 2 +- include/kami/config.h.in | 21 ++++++++++----------- test/unit-kami-agent.cc | 2 +- test/unit-kami-agentid.cc | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/conanfile.py b/conanfile.py index 259a3b3..3eecffa 100644 --- a/conanfile.py +++ b/conanfile.py @@ -47,3 +47,4 @@ class KamiConan(ConanFile): self.requires("fmt/7.1.3") self.requires("spdlog/1.8.5") self.requires("cli11/1.9.1") + self.requires("neargye-semver/0.3.0") diff --git a/examples/boltzmann1d/boltzmann1d.cc b/examples/boltzmann1d/boltzmann1d.cc index 67e4873..e81642b 100644 --- a/examples/boltzmann1d/boltzmann1d.cc +++ b/examples/boltzmann1d/boltzmann1d.cc @@ -161,7 +161,7 @@ int main(int argc, char **argv) { console = spdlog::stdout_color_st(ident); console->set_level(spdlog::level::from_str(log_level_option)); - console->info("Compiled with Kami/{}, log level {}", KAMI_VERSION_STRING, log_level_option); + console->info("Compiled with Kami/{}, log level {}", kami::version.to_string(), log_level_option); console->info("Starting Boltzmann Wealth Model with {} agents on a {}-unit grid for {} steps",agent_count, x_size, max_steps); rng = make_shared(initial_seed); diff --git a/examples/boltzmann2d/boltzmann2d.cc b/examples/boltzmann2d/boltzmann2d.cc index e9a72f9..195bb13 100644 --- a/examples/boltzmann2d/boltzmann2d.cc +++ b/examples/boltzmann2d/boltzmann2d.cc @@ -167,7 +167,7 @@ int main(int argc, char **argv) { console = spdlog::stdout_color_st(ident); console->set_level(spdlog::level::from_str(log_level_option)); - console->info("Compiled with Kami/{}, log level {}", KAMI_VERSION_STRING, log_level_option); + console->info("Compiled with Kami/{}, log level {}", kami::version.to_string(), log_level_option); console->info("Starting Boltzmann Wealth Model with {} agents on a {}x{}-unit grid for {} steps", agent_count, x_size, y_size, max_steps); BoltzmannWealthModel2D model(agent_count, x_size, y_size, initial_seed); diff --git a/include/kami/config.h.in b/include/kami/config.h.in index c1d324d..fe6aa21 100644 --- a/include/kami/config.h.in +++ b/include/kami/config.h.in @@ -36,29 +36,28 @@ #ifndef KAMI_CONFIG_H #define KAMI_CONFIG_H +#include + /** * The major version of the Kami library. */ -#define KAMI_VERSION_MAJOR @KAMI_VERSION_MAJOR @ +#define KAMI_VERSION_MAJOR @KAMI_VERSION_MAJOR@ /** * The minor version of the Kami library. */ -#define KAMI_VERSION_MINOR @KAMI_VERSION_MINOR @ +#define KAMI_VERSION_MINOR @KAMI_VERSION_MINOR@ /** * The patch level of the Kami library. */ -#define KAMI_VERSION_PATCH @KAMI_VERSION_PATCH @ +#define KAMI_VERSION_PATCH @KAMI_VERSION_PATCH@ -/** - * The version of the Kami library as a `char*` constant. - */ -#define KAMI_VERSION_STRING "@KAMI_VERSION_STRING@" +namespace kami { + + constexpr semver::version version{KAMI_VERSION_MAJOR, KAMI_VERSION_MINOR, KAMI_VERSION_PATCH}; + +} // namespace kami -/** - * The Kami library identifier as a `char *` constant. - */ -#define KAMI_VERSION_ID "Kami/@KAMI_VERSION_STRING@" #endif // KAMI_CONFIG_H diff --git a/test/unit-kami-agent.cc b/test/unit-kami-agent.cc index 47bfb5e..ff5c8eb 100644 --- a/test/unit-kami-agent.cc +++ b/test/unit-kami-agent.cc @@ -52,7 +52,7 @@ int main(int argc, char **argv) { CLI11_PARSE(app, argc, argv); console->set_level(spdlog::level::from_str(logLevelOption)); - console->info("Compiled with Kami/{}, log level {}", KAMI_VERSION_STRING, logLevelOption); + console->info("Compiled with Kami/{}, log level {}", kami::version.to_string(), logLevelOption); TestAgent test_agent; console->debug("Successfully created Agent with ID {}", test_agent.get_agent_id().to_string()); diff --git a/test/unit-kami-agentid.cc b/test/unit-kami-agentid.cc index 2c413b1..884ca71 100644 --- a/test/unit-kami-agentid.cc +++ b/test/unit-kami-agentid.cc @@ -48,7 +48,7 @@ int main(int argc, char **argv) { CLI11_PARSE(app, argc, argv); console->set_level(spdlog::level::from_str(logLevelOption)); - console->info("Compiled with Kami/{}, log level {}", KAMI_VERSION_STRING, logLevelOption); + console->info("Compiled with Kami/{}, log level {}", kami::version.to_string(), logLevelOption); AgentID testAgentID; console->debug("Successfully created AgentID with ID {}", testAgentID.to_string());