Skip to content

Commit

Permalink
Enable project version with suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosbento authored Mar 3, 2025
2 parents b6e4438 + 2e7b4af commit 2458b32
Show file tree
Hide file tree
Showing 23 changed files with 185 additions and 165 deletions.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,14 @@ include( ecbuild_system NO_POLICY_SCOPE )
ecbuild_requires_macro_version( 1.6 )
ecbuild_declare_project()

ecbuild_info( "CMAKE_MODULE_PATH : ${CMAKE_MODULE_PATH}")
#
# Set the version suffix (for alpha/beta/rc releases)
#

set(ecflow_VERSION_SUFFIX "")
set(ecflow_VERSION "${ecflow_VERSION}${ecflow_VERSION_SUFFIX}")

ecbuild_info( "CMAKE_MODULE_PATH : ${CMAKE_MODULE_PATH}" )
ecbuild_info( "CMAKE_INSTALL_PREFIX : ${CMAKE_INSTALL_PREFIX}" )
ecbuild_info( "ecflow_BINARY_DIR : ${ecflow_BINARY_DIR}" )
ecbuild_info( "ecflow_SOURCE_DIR : ${ecflow_SOURCE_DIR}" )
Expand Down
2 changes: 1 addition & 1 deletion Viewer/ecflowUI/src/AboutDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent) {
setupUi(this);

QString title = "EcflowUI";
QString ecfVersionTxt = QString::fromStdString(ecf::Version::raw());
QString ecfVersionTxt = QString::fromStdString(ecf::Version::full());
QString desc = QString::fromStdString(ecf::Version::description());
QString descTxt = "<b>ecflow version:</b> " + ecfVersionTxt;

Expand Down
2 changes: 1 addition & 1 deletion Viewer/ecflowUI/src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ void MainWindowTitleHandler::update() {
Q_ASSERT(win_);

char* userTitle = getenv("ECFLOWUI_TITLE");
std::string mainTitle = (userTitle != nullptr) ? std::string(userTitle) + " (" + ecf::Version::raw() + ")"
std::string mainTitle = (userTitle != nullptr) ? std::string(userTitle) + " (" + ecf::Version::full() + ")"
: VConfig::instance()->appLongName();
QString title = QString::fromStdString(mainTitle);

Expand Down
2 changes: 1 addition & 1 deletion Viewer/ecflowUI/src/VConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ VConfig* VConfig::instance_ = nullptr;
// #define _UI_CONFIG_LOAD_DEBUG

VConfig::VConfig() {
appLongName_ = appName_ + " (" + ecf::Version::raw() + ")";
appLongName_ = appName_ + " (" + ecf::Version::full() + ")";

// detect if the ui is to run via proxichains
if (char* variable = getenv("ECFLOWUI_USE_PROXYCHAINS"); variable) {
Expand Down
2 changes: 1 addition & 1 deletion Viewer/ecflowUI/src/ViewerMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
int main(int argc, char** argv) {
if (argc == 2) {
if (strcmp(argv[1], "--version") == 0) {
std::cout << ecf::Version::raw() << std::endl;
std::cout << ecf::Version::full() << std::endl;
return 0;
}
}
Expand Down
4 changes: 2 additions & 2 deletions libs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -545,11 +545,11 @@ set(srcs

ecbuild_add_library(
TARGET
ecflow_all
ecflow_all
NOINSTALL
TYPE STATIC
SOURCES
${srcs}
${srcs}
PUBLIC_INCLUDES
attribute/src
base/src
Expand Down
2 changes: 1 addition & 1 deletion libs/base/src/ecflow/base/cts/user/ServerVersionCmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const char* ServerVersionCmd::theArg() const {

STC_Cmd_ptr ServerVersionCmd::doHandleRequest(AbstractServer* as) const {
as->update_stats().server_version_++;
return PreAllocatedReply::string_cmd(Version::raw());
return PreAllocatedReply::string_cmd(Version::full());
}

static const char* arg_desc() {
Expand Down
22 changes: 14 additions & 8 deletions libs/client/test/TestServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,23 @@ BOOST_AUTO_TEST_CASE(test_server_version) {

ClientInvoker theClient(invokeServer.host(), invokeServer.port());
BOOST_REQUIRE_MESSAGE(theClient.server_version() == 0, "server version\n" << theClient.errorMsg());

auto client_version = theClient.get_string();
auto server_version = Version::full();

// Important:
// The test only requires a specific server version when both client and server are local.
// When contacting a remote server, only a warning is issued if the versions do not match.

if (ClientEnvironment::hostSpecified().empty()) {
// This check only valid if server was invoked locally. Ignore for remote servers
BOOST_REQUIRE_MESSAGE(theClient.get_string() == Version::raw(),
"Expected client version(" << Version::raw() << ") to match server version("
<< theClient.get_string() << ")");
BOOST_REQUIRE_MESSAGE(client_version == server_version,
"Client version (" << client_version << ") does not match server version ("
<< server_version << ")");
}
else {
// remote server, version may be different
BOOST_WARN_MESSAGE(theClient.get_string() == Version::raw(),
"Client version(" << Version::raw() << ") does not match server version("
<< theClient.get_string() << ")");
BOOST_WARN_MESSAGE(client_version == server_version,
"Client version (" << client_version << ") does not match server version (" << server_version
<< ")");
}
}

Expand Down
106 changes: 44 additions & 62 deletions libs/core/src/ecflow/core/Version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,80 +20,52 @@

namespace ecf {

// ********************************************************************
// IMPORTANT:
// The version number is extracted externally.
// see libs/core/doc/extracting_version_number.ddoc
//
// See libs/core/src/ecflow_version.h
// This file is generated when cmake is run, i.e.
// `sh -x $WK/cmake.sh debug`
//
// When changing the version change remember to:
// - re-login into remote system to update ECFLOW_INSTALL_DIR & ECFLOW_PYTHON_INSTALL_DIR
// required for interactive install
//
// To Install a new version on all the different platforms:
// . build_scripts/nightly/quick_install_.sh
// This is because the definition hold's the last version.
// Hence, we must rerun to update the version.
//
// ************************************************************************************
// Use <minor_number>rc<number> for release candidates, Once release we revert back:
// 0rc1 -> 0
// 10rc3 -> 10
// ************************************************************************************
//
// **Please update file history.ddoc with the changed made for each release ***
// ********************************************************************
#ifdef DEBUG
const std::string Version::TAG = " (debug)"; // Old tag: beta(debug)
#else
const std::string Version::TAG = ""; // Old tag: beta
#endif
std::string Version::major() {
return ECFLOW_VERSION_MAJOR;
}

// See: http://www.cmake.org/cmake/help/cmake_tutorial.html
// For defining version numbers. This is done is a separate file
// that is then included
std::string Version::description() {
std::stringstream ss;
ss << "Ecflow" << Version::TAG << " version(" << ECFLOW_RELEASE << "." << ECFLOW_MAJOR << "." << ECFLOW_MINOR;
std::string Version::minor() {
return ECFLOW_VERSION_MINOR;
}

ss << ") boost(" << Version::boost() << ")";
std::string the_comp = compiler();
if (!the_comp.empty())
ss << " compiler(" << the_comp << ")";
std::string Version::patch() {
return ECFLOW_VERSION_PATCH;
}

ss << " protocol(JSON cereal " << CEREAL_VERSION_MAJOR << "." << CEREAL_VERSION_MINOR << "." << CEREAL_VERSION_PATCH
<< ")";
std::string Version::suffix() {
return ECFLOW_VERSION_SUFFIX;
};

std::string Version::description() {
std::stringstream ss;
ss << "Ecflow ";
#ifdef DEBUG
ss << "(debug) ";
#endif
ss << "version(" << Version::full() << ") ";
ss << "boost(" << Version::boost() << ") ";
ss << "compiler(" << Version::compiler() << ") ";
ss << "protocol(JSON cereal " << Version::cereal() << ") ";
#ifdef ECF_OPENSSL
ss << " openssl(enabled)";
ss << "openssl(enabled) ";
#endif

ss << " Compiled on " << __DATE__ << " " << __TIME__;
ss << "Compiled on " << __DATE__ << " " << __TIME__;
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::base() + Version::suffix();
}

std::string Version::boost() {
std::stringstream ss;
ss << BOOST_VERSION / 100000 << "." // major version
Expand All @@ -102,6 +74,14 @@ std::string Version::boost() {
return ss.str();
}

std::string Version::cereal() {
std::stringstream ss;
ss << CEREAL_VERSION_MAJOR // major version
<< "." << CEREAL_VERSION_MINOR // minor version
<< "." << CEREAL_VERSION_PATCH; // patch level
return ss.str();
}

std::string Version::compiler() {
std::stringstream ss;
#if defined(_AIX)
Expand All @@ -112,7 +92,7 @@ std::string Version::compiler() {
#if defined(__clang__)
// To find the list of defines for clang use:
// echo | /usr/local/apps/clang/current/bin/clang++ -dM -E -
ss << "clang " << __clang_major__ << "." << __clang_minor__;
ss << "clang " << __clang_major__ << "." << __clang_minor__ << "." << __clang_patchlevel__;
#elif defined(__INTEL_COMPILER)
ss << "intel " << __INTEL_COMPILER;
#elif defined(_CRAYC)
Expand All @@ -121,7 +101,9 @@ std::string Version::compiler() {
ss << "gcc " << __GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__;
#endif
#endif
return ss.str();
auto version = ss.str();

return version.empty() ? "unknown" : version;
}

} // namespace ecf
54 changes: 33 additions & 21 deletions libs/core/src/ecflow/core/Version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,18 @@
#ifndef ecflow_core_Version_HPP
#define ecflow_core_Version_HPP

///
/// \brief Holds the version of ECFlow. Checked against definition file.
/// For each major release the major number should be incremented.
///
/// If the parsing comes across a construct it does not recognize, then
/// an exception is thrown. i.e if a construct added in release 2.0 of ECF
/// is read in by version 1.0 of ECF. The exception should indicate the
/// current release
///

#include <string>

namespace ecf {

///
/// \brief Provides information regarding the version of ecFlow.
///
/// The ecFlow version format is of the form `<major>.<minor>.<patch>[<suffix>]`,
/// following the semantic versioning scheme.
///
/// The version is defined in the CMakeLists.txt file.
///
class Version {
public:
// Disable default construction
Expand All @@ -33,24 +31,38 @@ class Version {
Version(const Version&) = delete;
const Version& operator=(const Version&) = delete;

/// Outputs a string of the form:
/// ECF <tag> version release_.major_.minor_
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.
///
/// This provides user facing version information
/// (shown by ecflow_client --help, and in the server info panel on ecflow_ui).
///
static std::string description();

/// Outputs string of form: ecflow_<release>_<major>_<minor>
/// This could be used by install
static std::string version();
///
/// Creates the ecFlow version, following the template: `<major>.<minor>.<patch>`
///
static std::string base();

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

private:
static const std::string TAG; // alpha, beta, release

/// return version of the boost library
/// Create a string containing the version of the Boost library
static std::string boost();

// Return the version of the compiler. Can return empty string
/// Create a string containing the version of the Cereal library
static std::string cereal();

/// Create a string containing the version of the Compiler used to build ecFlow
static std::string compiler();
};

Expand Down
9 changes: 5 additions & 4 deletions libs/core/src/ecflow/core/ecflow_version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +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_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
Loading

0 comments on commit 2458b32

Please sign in to comment.