Skip to content

Commit

Permalink
Rename Version to <major>.<minor>.<patch>[<suffix>]
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosbento committed Feb 27, 2025
1 parent 71541b3 commit 2e7b4af
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 49 deletions.
50 changes: 21 additions & 29 deletions libs/core/src/ecflow/core/Version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,24 @@

namespace ecf {

std::string Version::major() {
return ECFLOW_VERSION_MAJOR;
}

std::string Version::minor() {
return ECFLOW_VERSION_MINOR;
}

std::string Version::patch() {
return ECFLOW_VERSION_PATCH;
}

std::string Version::suffix() {
return ECFLOW_VERSION_SUFFIX;
};

std::string Version::description() {
std::stringstream ss;

ss << "Ecflow ";
#ifdef DEBUG
ss << "(debug) ";
Expand All @@ -38,41 +53,18 @@ std::string Version::description() {
return ss.str();
}

std::string Version::version() {
std::string ret = "ecflow_";
ret += ecf::convert_to<std::string>(ECFLOW_RELEASE);
ret += "_";
ret += ecf::convert_to<std::string>(ECFLOW_MAJOR);
ret += "_";
ret += ecf::convert_to<std::string>(ECFLOW_MINOR);
return ret;
}

std::string Version::raw() {
std::string ret = ecf::convert_to<std::string>(ECFLOW_RELEASE);
std::string Version::base() {
std::string ret = major();
ret += ".";
ret += ecf::convert_to<std::string>(ECFLOW_MAJOR);
ret += minor();
ret += ".";
ret += ecf::convert_to<std::string>(ECFLOW_MINOR);
ret += patch();
return ret;
}

std::string Version::full() {
return Version::raw() + Version::suffix();
}

std::string Version::major() {
return ecf::convert_to<std::string>(ECFLOW_RELEASE);
return Version::base() + Version::suffix();
}
std::string Version::minor() {
return ecf::convert_to<std::string>(ECFLOW_MAJOR);
}
std::string Version::patch() {
return ecf::convert_to<std::string>(ECFLOW_MINOR);
}
std::string Version::suffix() {
return ecf::convert_to<std::string>(ECFLOW_SUFFIX);
};

std::string Version::boost() {
std::stringstream ss;
Expand Down
21 changes: 8 additions & 13 deletions libs/core/src/ecflow/core/Version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ class Version {
Version(const Version&) = delete;
const Version& operator=(const Version&) = delete;

static std::string major();
static std::string minor();
static std::string patch();
static std::string suffix();

///
/// Creates a string with a descriptive version information,
/// including the version of ecFlow and relevant dependencies.
Expand All @@ -41,25 +46,15 @@ class Version {
static std::string description();

///
/// Creates the ecFlow version, following the template: `ecflow_<release>_<major>_<minor>`
/// Creates the ecFlow version, following the template: `<major>.<minor>.<patch>`
///
static std::string version();
static std::string base();

///
/// Creates the ecFlow version, following the template: `<release>.<major>.<minor>`
///
static std::string raw();

///
/// Creates the ecFlow version, following the template: `<release>.<major>.<minor>[<suffix>]`
/// Creates the ecFlow version, following the template: `<major>.<minor>.<patch>[<suffix>]`
///
static std::string full();

static std::string major();
static std::string minor();
static std::string patch();
static std::string suffix();

private:
/// Create a string containing the version of the Boost library
static std::string boost();
Expand Down
10 changes: 5 additions & 5 deletions libs/core/src/ecflow/core/ecflow_version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
#define ecflow_core_ecflow_version_config_H

// clang-format off
#define ECFLOW_VERSION "@ecflow_VERSION@"
#define ECFLOW_RELEASE "@ecflow_VERSION_MAJOR@"
#define ECFLOW_MAJOR "@ecflow_VERSION_MINOR@"
#define ECFLOW_MINOR "@ecflow_VERSION_PATCH@"
#define ECFLOW_SUFFIX "@ecflow_VERSION_SUFFIX@"
#define ECFLOW_VERSION "@ecflow_VERSION@"
#define ECFLOW_VERSION_MAJOR "@ecflow_VERSION_MAJOR@"
#define ECFLOW_VERSION_MINOR "@ecflow_VERSION_MINOR@"
#define ECFLOW_VERSION_PATCH "@ecflow_VERSION_PATCH@"
#define ECFLOW_VERSION_SUFFIX "@ecflow_VERSION_SUFFIX@"

// available but not used
// PROJECT_VERSION=@PROJECT_VERSION@
Expand Down
4 changes: 2 additions & 2 deletions libs/core/test/TestVersion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ BOOST_AUTO_TEST_CASE(test_version) {
BOOST_AUTO_TEST_CASE(test_version_raw_components) {
ECF_NAME_THIS_TEST();

auto actual = Version::raw();
auto actual = Version::base();
auto expected = Version::major() + "." + Version::minor() + "." + Version::patch();
BOOST_CHECK_EQUAL(actual, expected);
}
Expand All @@ -89,7 +89,7 @@ BOOST_AUTO_TEST_CASE(test_version_against_cmake) {
auto actual_version = find_cmake_version(lines);
BOOST_CHECK_MESSAGE(!actual_version.empty(), "Unable to find CMake version in file " << version_cmake_file);

auto expected_version = Version::raw();
auto expected_version = Version::base();
BOOST_CHECK_EQUAL(actual_version, expected_version);
}

Expand Down

0 comments on commit 2e7b4af

Please sign in to comment.