From 727fbe34954a6b7409a86b1a5262261ef3552035 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Tue, 24 Oct 2023 11:52:58 -0400 Subject: [PATCH 1/6] ENH: additions to nxrunner for detailed version information. Signed-off-by: Michael Jackson --- CMakeLists.txt | 24 ++- cmake/ComplexVersion.cpp.in | 189 ++++++++++++++++++ cmake/ComplexVersion.hpp | 50 +++++ cmake/Utility.cmake | 178 ++++++++++++++++- .../Filters/Algorithms/INLWriter.cpp | 4 +- src/nxrunner/src/nxrunner.cpp | 7 +- 6 files changed, 442 insertions(+), 10 deletions(-) create mode 100644 cmake/ComplexVersion.cpp.in create mode 100644 cmake/ComplexVersion.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 516ffcd551..1f54d653cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -721,11 +721,29 @@ list(APPEND COMPLEX_GENERATED_HEADERS ${COMPLEX_GENERATED_PYTHON_HEADER} ) -set(COMPLEX_GENERATED_VERSION_HEADER ${COMPLEX_GENERATED_HEADER_DIR}/ComplexVersion.h) -configure_file(${complex_SOURCE_DIR}/cmake/ComplexVersion.h.in ${COMPLEX_GENERATED_VERSION_HEADER}) +# set(COMPLEX_GENERATED_VERSION_HEADER ${COMPLEX_GENERATED_HEADER_DIR}/ComplexVersion.h) +# configure_file(${complex_SOURCE_DIR}/cmake/ComplexVersion.h.in ${COMPLEX_GENERATED_VERSION_HEADER}) + + +set(CMP_VERSION_HDR_TEMPLATE_FILE ${complex_SOURCE_DIR}/cmake/ComplexVersion.hpp) +set(CMP_VERSION_SRC_TEMPLATE_FILE ${complex_SOURCE_DIR}/cmake/ComplexVersion.cpp.in) +set(VERSION_GEN_HEADER_FILE_NAME "ComplexVersion.hpp") + +cmpBuildDateRevisionString(GENERATED_HEADER_FILE_PATH "generated/complex/ComplexVersion.hpp" + GENERATED_SOURCE_FILE_PATH "generated/complex/ComplexVersion.cpp" + NAMESPACE complex + PROJECT_NAME complex + EXPORT_MACRO "" + VERSION_MACRO_PATH "" + STRING_CLASS std::string + STRING_INCLUDE "#include " +) + + list(APPEND COMPLEX_GENERATED_HEADERS - ${COMPLEX_GENERATED_VERSION_HEADER} + ${COMPLEX_GENERATED_HEADER_DIR}/ComplexVersion.hpp + ${COMPLEX_GENERATED_HEADER_DIR}/ComplexVersion.cpp ) set(COMPLEX_ALL_HDRS diff --git a/cmake/ComplexVersion.cpp.in b/cmake/ComplexVersion.cpp.in new file mode 100644 index 0000000000..fa585ea769 --- /dev/null +++ b/cmake/ComplexVersion.cpp.in @@ -0,0 +1,189 @@ +/*-------------------------------------------------------------------------- + * This file is autogenerated from: + * @CMAKE_CURRENT_LIST_DIR@/DREAM3DVersion.cpp.in + * during the cmake configuration of your project. If you need to make changes, + * edit the original file NOT THIS FILE. + * --------------------------------------------------------------------------*/ + +#include "ComplexVersion.hpp" + +// ----------------------------------------------------------------------------- +@GVS_STRING_CLASS@ @VERSION_GEN_NAMESPACE@::Version::ApplicationName() +{ + return {"@PROJECT_PREFIX@"}; +} + +// ----------------------------------------------------------------------------- +@GVS_STRING_CLASS@ @VERSION_GEN_NAMESPACE@::Version::Complete() +{ + return {"@VERSION_GEN_VER_MAJOR@.@VERSION_GEN_VER_MINOR@.@VERSION_GEN_VER_PATCH@@VERSION_GEN_VER_SUFFIX@"}; +} + +// ----------------------------------------------------------------------------- +@GVS_STRING_CLASS@ @VERSION_GEN_NAMESPACE@::Version::Major() +{ + return {"@VERSION_GEN_VER_MAJOR@"}; +} + +// ----------------------------------------------------------------------------- +@GVS_STRING_CLASS@ @VERSION_GEN_NAMESPACE@::Version::Minor() +{ + return {"@VERSION_GEN_VER_MINOR@"}; +} + +// ----------------------------------------------------------------------------- +@GVS_STRING_CLASS@ @VERSION_GEN_NAMESPACE@::Version::Patch() +{ + return {"@VERSION_GEN_VER_PATCH@"}; +} + +// ----------------------------------------------------------------------------- +@GVS_STRING_CLASS@ @VERSION_GEN_NAMESPACE@::Version::Suffix() +{ + return {"@VERSION_GEN_VER_SUFFIX@"}; +} + +// ----------------------------------------------------------------------------- +@GVS_STRING_CLASS@ @VERSION_GEN_NAMESPACE@::Version::Package() +{ + return {"@VERSION_GEN_VER_MAJOR@.@VERSION_GEN_VER_MINOR@.@VERSION_GEN_VER_PATCH@@VERSION_GEN_VER_SUFFIX@"}; +} + +// ----------------------------------------------------------------------------- +@GVS_STRING_CLASS@ @VERSION_GEN_NAMESPACE@::Version::PackageComplete() +{ + return {"@PROJECT_PREFIX@ Version @VERSION_GEN_VER_MAJOR@.@VERSION_GEN_VER_MINOR@.@VERSION_GEN_VER_PATCH@@VERSION_GEN_VER_SUFFIX@"}; +} + +// ----------------------------------------------------------------------------- +@GVS_STRING_CLASS@ @VERSION_GEN_NAMESPACE@::Version::BuildDate() +{ + return {"@VERSION_BUILD_DATE@"}; +} + +// ----------------------------------------------------------------------------- +@GVS_STRING_CLASS@ @VERSION_GEN_NAMESPACE@::Version::GitHashShort() +{ + return {"@VERSION_GEN_GIT_HASH_SHORT@"}; +} + +// ----------------------------------------------------------------------------- +@GVS_STRING_CLASS@ @VERSION_GEN_NAMESPACE@::Version::GitHash() +{ + return {"@GVS_GIT_HASH@"}; +} + +// ----------------------------------------------------------------------------- +@VERSION_GEN_NAMESPACE@::Version::AppVersion::AppVersion() = default; + +// ----------------------------------------------------------------------------- +@VERSION_GEN_NAMESPACE@::Version::AppVersion::AppVersion(int majorNum, int minorNum, int patchNum) +{ + m_MajorNum = majorNum; + m_MinorNum = minorNum; + m_PatchNum = patchNum; +} + +// ----------------------------------------------------------------------------- +@VERSION_GEN_NAMESPACE@::Version::AppVersion::~AppVersion() = default; + +// ----------------------------------------------------------------------------- +@VERSION_GEN_NAMESPACE@::Version::AppVersion::AppVersion(const @VERSION_GEN_NAMESPACE@::Version::AppVersion& rhs) +{ + m_MajorNum = rhs.m_MajorNum; + m_MinorNum = rhs.m_MinorNum; + m_PatchNum = rhs.m_PatchNum; +} + +// ----------------------------------------------------------------------------- +@VERSION_GEN_NAMESPACE@::Version::AppVersion& @VERSION_GEN_NAMESPACE@::Version::AppVersion::operator=(const AppVersion& rhs) = default; + +// ----------------------------------------------------------------------------- +bool @VERSION_GEN_NAMESPACE@::Version::AppVersion::operator==(const @VERSION_GEN_NAMESPACE@::Version::AppVersion& rhs) +{ + return (m_MajorNum == rhs.m_MajorNum && m_MinorNum == rhs.m_MinorNum && m_PatchNum == rhs.m_PatchNum); +} + +// ----------------------------------------------------------------------------- +bool @VERSION_GEN_NAMESPACE@::Version::AppVersion::operator>(const @VERSION_GEN_NAMESPACE@::Version::AppVersion& rhs) +{ + if(m_MajorNum > rhs.m_MajorNum) + { + return true; + } + + if(m_MajorNum == rhs.m_MajorNum) + { + if(m_MinorNum > rhs.m_MinorNum) + { + return true; + } + + if(m_MinorNum == rhs.m_MinorNum) + { + return m_PatchNum > rhs.m_PatchNum; + } + return false; + } + return false; +} + +// ----------------------------------------------------------------------------- +bool @VERSION_GEN_NAMESPACE@::Version::AppVersion::operator<(const @VERSION_GEN_NAMESPACE@::Version::AppVersion& rhs) +{ + if(m_MajorNum < rhs.m_MajorNum) + { + return true; + } + + if(m_MajorNum == rhs.m_MajorNum) + { + if(m_MinorNum < rhs.m_MinorNum) + { + return true; + } + + if(m_MinorNum == rhs.m_MinorNum) + { + return m_PatchNum < rhs.m_PatchNum; + } + return false; + } + return false; +} + +// ----------------------------------------------------------------------------- +int @VERSION_GEN_NAMESPACE@::Version::AppVersion::getMajorNum() +{ + return m_MajorNum; +} + +// ----------------------------------------------------------------------------- +int @VERSION_GEN_NAMESPACE@::Version::AppVersion::getMinorNum() +{ + return m_MinorNum; +} + +// ----------------------------------------------------------------------------- +int @VERSION_GEN_NAMESPACE@::Version::AppVersion::getPatchNum() +{ + return m_PatchNum; +} + +// ----------------------------------------------------------------------------- +void @VERSION_GEN_NAMESPACE@::Version::AppVersion::setMajorNum(int major) +{ + m_MajorNum = major; +} + +// ----------------------------------------------------------------------------- +void @VERSION_GEN_NAMESPACE@::Version::AppVersion::setMinorNum(int minor) +{ + m_MinorNum = minor; +} + +// ----------------------------------------------------------------------------- +void @VERSION_GEN_NAMESPACE@::Version::AppVersion::setPatchNum(int patch) +{ + m_PatchNum = patch; +} diff --git a/cmake/ComplexVersion.hpp b/cmake/ComplexVersion.hpp new file mode 100644 index 0000000000..4ad25468ca --- /dev/null +++ b/cmake/ComplexVersion.hpp @@ -0,0 +1,50 @@ +#pragma once + +#include + +namespace complex::Version +{ + +std::string ApplicationName(); +std::string Complete(); +std::string Major(); +std::string Minor(); +std::string Patch(); +std::string Suffix(); +std::string Package(); +std::string PackageComplete(); +std::string BuildDate(); +std::string GitHashShort(); +std::string GitHash(); + +class AppVersion +{ +public: + AppVersion(); + AppVersion(int majorNum, int minorNum, int patchNum); + + AppVersion(const AppVersion&); + AppVersion(const AppVersion&&) = delete; + AppVersion& operator=(const AppVersion&); + AppVersion& operator=(AppVersion&&) = delete; + + bool operator==(const AppVersion&); + bool operator>(const AppVersion&); + bool operator<(const AppVersion&); + + virtual ~AppVersion(); + + int getMajorNum(); + int getMinorNum(); + int getPatchNum(); + + void setMajorNum(int major); + void setMinorNum(int minor); + void setPatchNum(int patch); + +private: + int m_MajorNum = -1; + int m_MinorNum = -1; + int m_PatchNum = -1; +}; +} // namespace DREAM3DNX::Version diff --git a/cmake/Utility.cmake b/cmake/Utility.cmake index ee070a91c0..71f5136233 100644 --- a/cmake/Utility.cmake +++ b/cmake/Utility.cmake @@ -283,4 +283,180 @@ function(create_pipeline_tests) endfunction() -#set_tests_properties(dependsTest12 PROPERTIES DEPENDS "baseTest1;baseTest2") +#------------------------------------------------------------------------------- +# This function generates a file ONLY if the MD5 between the "to be" generated file +# and the current file are different. This will help reduce recompiles based on +# the generation of files that are really the same. +#------------------------------------------------------------------------------- +function(cmpConfigureFileWithMD5Check) + set(options) + set(oneValueArgs CONFIGURED_TEMPLATE_PATH GENERATED_FILE_PATH ) + cmake_parse_arguments(GVS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) + + # message(STATUS " GVS_CONFIGURED_TEMPLATE_PATH: ${GVS_CONFIGURED_TEMPLATE_PATH}") + # message(STATUS " GVS_GENERATED_FILE_PATH: ${GVS_GENERATED_FILE_PATH}") + + # Only Generate a file if it is different than what is already there. + if(EXISTS ${GVS_GENERATED_FILE_PATH} ) + file(MD5 ${GVS_GENERATED_FILE_PATH} VERSION_HDR_MD5) + configure_file(${GVS_CONFIGURED_TEMPLATE_PATH} ${GVS_GENERATED_FILE_PATH}_tmp ) + + file(MD5 ${GVS_GENERATED_FILE_PATH}_tmp VERSION_GEN_HDR_MD5) + #message(STATUS " File Exists, doing MD5 Comparison") + + # Compare the MD5 checksums. If they are different then configure the file into the proper location + if(NOT "${VERSION_HDR_MD5}" STREQUAL "${VERSION_GEN_HDR_MD5}") + #message(STATUS " ${VERSION_GEN_HDR_MD5}") + #message(STATUS " ${VERSION_HDR_MD5}") + #message(STATUS " Files differ: Replacing with newly generated file") + configure_file(${GVS_CONFIGURED_TEMPLATE_PATH} ${GVS_GENERATED_FILE_PATH} ) + else() + #message(STATUS " NO Difference in Files") + endif() + file(REMOVE ${GVS_GENERATED_FILE_PATH}_tmp) + else() + # message(STATUS " File does NOT Exist, Generating one...") + configure_file(${GVS_CONFIGURED_TEMPLATE_PATH} ${GVS_GENERATED_FILE_PATH} ) + endif() + +endfunction() + + + +#------------------------------------------------------------------------------- +# We are going to use Git functionality to create a version number for our package +# The MAJOR.MINOR.PATCH is based off of YYYY.MM.DD +# The TWEAK is the git hash of project. +#------------------------------------------------------------------------------- +function(cmpBuildDateRevisionString) + set(options) + set(oneValueArgs GENERATED_HEADER_FILE_PATH GENERATED_SOURCE_FILE_PATH + NAMESPACE PROJECT_NAME EXPORT_MACRO VERSION_MACRO_PATH STRING_CLASS STRING_INCLUDE) + cmake_parse_arguments(GVS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) + + if(NOT DEFINED GVS_STRING_CLASS) + set(GVS_STRING_CLASS "QString") + endif() + + if(NOT DEFINED GVS_STRING_INCLUDE) + set(GVS_STRING_INCLUDE "") + endif() + + if(0) + message(STATUS "--------------------------------------------") + message(STATUS "GVS_NAMESPACE: ${GVS_NAMESPACE}") + message(STATUS "GVS_PROJECT_NAME: ${GVS_PROJECT_NAME}") + message(STATUS "GVS_GENERATED_HEADER_FILE_PATH: ${GVS_GENERATED_HEADER_FILE_PATH}") + message(STATUS "GVS_GENERATED_SOURCE_FILE_PATH: ${GVS_GENERATED_SOURCE_FILE_PATH}") + message(STATUS "GVS_PROJECT_VERSION_MAJOR: ${GVS_PROJECT_VERSION_MAJOR}") + message(STATUS "GVS_EXPORT_MACRO: ${GVS_EXPORT_MACRO}") + message(STATUS "${GVS_PROJECT_NAME}_BUILD_DATE: ${${GVS_PROJECT_NAME}_BUILD_DATE}") + message(STATUS "${GVS_PROJECT_NAME}_SOURCE_DIR: ${${GVS_PROJECT_NAME}_SOURCE_DIR}") + message(STATUS "--------------------------------------------") + endif() + + string(STRIP "${${GVS_PROJECT_NAME}_BUILD_DATE}" DVERS) + string(REPLACE "/" "-" DVERS "${DVERS}") + # Run 'git describe' to get our tag offset + # execute_process(COMMAND ${GIT_EXECUTABLE} describe --long + # OUTPUT_VARIABLE DVERS + # RESULT_VARIABLE did_run + # ERROR_VARIABLE git_error + # WORKING_DIRECTORY ${${GVS_PROJECT_NAME}_SOURCE_DIR} ) + + #message(STATUS "DVERS: ${DVERS}") + set(PROJECT_PREFIX "${GVS_PROJECT_NAME}") + set(VERSION_GEN_NAME "${GVS_PROJECT_NAME}") + set(VERSION_GEN_NAMESPACE "${GVS_NAMESPACE}") + string(TOLOWER "${VERSION_GEN_NAMESPACE}" VERSION_INCLUDE_GUARD) + set(VERSION_GEN_NAMESPACE_EXPORT "${GVS_EXPORT_MACRO}") + set(VERSION_GEN_VER_MAJOR ${${GVS_PROJECT_NAME}_VERSION_MAJOR}) + set(VERSION_GEN_VER_MINOR ${${GVS_PROJECT_NAME}_VERSION_MINOR}) + set(VERSION_GEN_VER_PATCH ${${GVS_PROJECT_NAME}_VERSION_PATCH}) + set(VERSION_GEN_VER_SUFFIX ${${GVS_PROJECT_NAME}_VERSION_SUFFIX}) + set(VERSION_GEN_GIT_HASH_SHORT "0") + + string(TIMESTAMP VERSION_BUILD_DATE "%Y/%m/%d") + + set(VERSION_GEN_HEADER_FILE_NAME ${GVS_GENERATED_HEADER_FILE_PATH}) + + #-- Make sure that actually worked and if not just generate some dummy values + if(NOT "${DVERS}" STREQUAL "") + string(STRIP ${DVERS} DVERS) + string(REPLACE "-" ";" VERSION_LIST ${DVERS}) + list(LENGTH VERSION_LIST VERSION_LIST_LENGTH) + + set(VERSION_GEN_VER_PATCH "0") + set(VERSION_GEN_GIT_HASH_SHORT "0") + + list(LENGTH VERSION_LIST LIST_LENGTH) + if(LIST_LENGTH GREATER 1) + list(GET VERSION_LIST 0 VERSION_GEN_VER_MAJOR) + list(GET VERSION_LIST 1 VERSION_GEN_VER_MINOR) + list(GET VERSION_LIST 2 VERSION_GEN_VER_PATCH) + endif() + + endif() + + find_package(Git) + # Run 'git rev-parse --short HEAD' to get our revision + execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD + OUTPUT_VARIABLE DVERS + RESULT_VARIABLE did_run + ERROR_VARIABLE git_error + WORKING_DIRECTORY ${${GVS_PROJECT_NAME}_SOURCE_DIR} ) + string(STRIP "${DVERS}" DVERS) + if(DVERS STREQUAL "") + message(STATUS "[${GVS_PROJECT_NAME}] 'git rev-parse --short HEAD' did not return anything valid") + set(VERSION_GEN_GIT_HASH_SHORT "000000000000") + else() + set(VERSION_GEN_GIT_HASH_SHORT "${DVERS}") + endif() + + set(${GVS_PROJECT_NAME}_VERSION_MAJOR "${VERSION_GEN_VER_MAJOR}" PARENT_SCOPE) + set(${GVS_PROJECT_NAME}_VERSION_MINOR "${VERSION_GEN_VER_MINOR}" PARENT_SCOPE) + set(${GVS_PROJECT_NAME}_VERSION_PATCH "${VERSION_GEN_VER_PATCH}" PARENT_SCOPE) + set(${GVS_PROJECT_NAME}_VERSION_TWEAK "${VERSION_GEN_GIT_HASH_SHORT}" PARENT_SCOPE) + + set(CMP_TOP_HEADER_INCLUDE_STATMENT "") + if(NOT "${CMP_TOP_HEADER_FILE}" STREQUAL "") + set(CMP_TOP_HEADER_INCLUDE_STATMENT "#include \"${CMP_TOP_HEADER_FILE}\"") + endif() + + execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --verify HEAD + OUTPUT_VARIABLE GVS_GIT_HASH + RESULT_VARIABLE did_run + ERROR_VARIABLE git_error + WORKING_DIRECTORY ${${GVS_PROJECT_NAME}_SOURCE_DIR} + ) + string(REPLACE "\n" "" GVS_GIT_HASH "${GVS_GIT_HASH}") + set_property(GLOBAL PROPERTY ${GVS_PROJECT_NAME}_GIT_HASH ${GVS_GIT_HASH}) + + execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --pretty='%cd' --date=format:%Y-%m-%d-%H:%M:%S + OUTPUT_VARIABLE GVS_GIT_COMMIT_DATE + RESULT_VARIABLE did_run + ERROR_VARIABLE git_error + WORKING_DIRECTORY ${${GVS_PROJECT_NAME}_SOURCE_DIR} + ) + string(REPLACE "\n" "" GVS_GIT_COMMIT_DATE "${GVS_GIT_COMMIT_DATE}") + set_property(GLOBAL PROPERTY ${GVS_PROJECT_NAME}_GIT_COMMIT_DATE ${GVS_GIT_COMMIT_DATE}) + + if(NOT "${GVS_GENERATED_HEADER_FILE_PATH}" STREQUAL "") + # message(STATUS "Generating: ${${GVS_PROJECT_NAME}_BINARY_DIR}/${GVS_GENERATED_HEADER_FILE_PATH}") + cmpConfigureFileWithMD5Check( GENERATED_FILE_PATH ${${GVS_PROJECT_NAME}_BINARY_DIR}/${GVS_GENERATED_HEADER_FILE_PATH} + CONFIGURED_TEMPLATE_PATH ${CMP_VERSION_HDR_TEMPLATE_FILE} ) + endif() + + if(NOT "${GVS_GENERATED_SOURCE_FILE_PATH}" STREQUAL "") + # message(STATUS "Generating: ${${GVS_PROJECT_NAME}_BINARY_DIR}/${GVS_GENERATED_SOURCE_FILE_PATH}") + cmpConfigureFileWithMD5Check( GENERATED_FILE_PATH ${${GVS_PROJECT_NAME}_BINARY_DIR}/${GVS_GENERATED_SOURCE_FILE_PATH} + CONFIGURED_TEMPLATE_PATH ${CMP_VERSION_SRC_TEMPLATE_FILE} ) + endif() + + if(NOT "${GVS_VERSION_MACRO_PATH}" STREQUAL "") + # message(STATUS "Generating: ${${GVS_PROJECT_NAME}_BINARY_DIR}/${GVS_VERSION_MACRO_PATH}") + cmpConfigureFileWithMD5Check( GENERATED_FILE_PATH ${${GVS_PROJECT_NAME}_BINARY_DIR}/${GVS_VERSION_MACRO_PATH} + CONFIGURED_TEMPLATE_PATH ${CMP_CONFIGURED_FILES_SOURCE_DIR}/cmpVersionMacro.h.in ) + endif() + +endfunction() diff --git a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/INLWriter.cpp b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/INLWriter.cpp index 74de2932e7..28e754240b 100644 --- a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/INLWriter.cpp +++ b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/INLWriter.cpp @@ -1,6 +1,6 @@ #include "INLWriter.hpp" -#include "complex/ComplexVersion.h" +#include "complex/ComplexVersion.hpp" #include "complex/DataStructure/DataArray.hpp" #include "complex/DataStructure/DataPath.hpp" #include "complex/DataStructure/Geometry/ImageGeom.hpp" @@ -105,7 +105,7 @@ Result<> INLWriter::operator()() FloatVec3 origin = imageGeom.getOrigin(); // Write the header, Each line starts with a "#" symbol - fout << "# File written from " << COMPLEX_PACKAGE_COMPLETE << "\n"; + fout << "# File written from " << complex::Version::PackageComplete() << "\n"; fout << "# X_STEP: " << std::fixed << res[0] << "\n"; fout << "# Y_STEP: " << std::fixed << res[1] << "\n"; fout << "# Z_STEP: " << std::fixed << res[2] << "\n"; diff --git a/src/nxrunner/src/nxrunner.cpp b/src/nxrunner/src/nxrunner.cpp index 712858f523..eee59821ca 100644 --- a/src/nxrunner/src/nxrunner.cpp +++ b/src/nxrunner/src/nxrunner.cpp @@ -1,12 +1,12 @@ #include "CliObserver.hpp" #include "complex/Common/Result.hpp" +#include "complex/ComplexPython.hpp" +#include "complex/ComplexVersion.hpp" #include "complex/Core/Application.hpp" #include "complex/Pipeline/Pipeline.hpp" #include "complex/Utilities/StringUtilities.hpp" -#include "complex/ComplexPython.hpp" - #include #include @@ -402,8 +402,7 @@ std::vector GetPythonPluginList() int main(int argc, char* argv[]) { - - cliOut << "nxrunner version 1.0.0\n"; + cliOut << fmt::format("nxrunner: Version {} Build Date:{}\n\n", complex::Version::Package(), complex::Version::BuildDate()); // cliOut.endline(); // cliOut << "ARGUMENT LISTING START\n"; // for(int argIndex = 0; argIndex < argc; argIndex++) From 8c3ca6b3af3d7f7f3c3ccbc643facb0f89985759 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Tue, 24 Oct 2023 14:33:55 -0400 Subject: [PATCH 2/6] Fix QString usages. Signed-off-by: Michael Jackson --- cmake/Utility.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/Utility.cmake b/cmake/Utility.cmake index 71f5136233..e3eeb42f2c 100644 --- a/cmake/Utility.cmake +++ b/cmake/Utility.cmake @@ -335,11 +335,11 @@ function(cmpBuildDateRevisionString) cmake_parse_arguments(GVS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) if(NOT DEFINED GVS_STRING_CLASS) - set(GVS_STRING_CLASS "QString") + set(GVS_STRING_CLASS "std::string") endif() if(NOT DEFINED GVS_STRING_INCLUDE) - set(GVS_STRING_INCLUDE "") + set(GVS_STRING_INCLUDE "") endif() if(0) From 49d9d7aa1384c26bd616e4ebace405bf3e5e44a6 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Tue, 24 Oct 2023 17:27:02 -0400 Subject: [PATCH 3/6] Update cmake/ComplexVersion.hpp Co-authored-by: Nathan Young --- cmake/ComplexVersion.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/ComplexVersion.hpp b/cmake/ComplexVersion.hpp index 4ad25468ca..f19bab37e8 100644 --- a/cmake/ComplexVersion.hpp +++ b/cmake/ComplexVersion.hpp @@ -47,4 +47,4 @@ class AppVersion int m_MinorNum = -1; int m_PatchNum = -1; }; -} // namespace DREAM3DNX::Version +} // namespace complex::Version From 0a58f17d3ec833090208d19516806a4185498144 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Tue, 24 Oct 2023 17:31:16 -0400 Subject: [PATCH 4/6] Address Code Review Feedback Signed-off-by: Michael Jackson --- cmake/ComplexVersion.cpp.in | 2 +- cmake/ComplexVersion.h.in | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) delete mode 100644 cmake/ComplexVersion.h.in diff --git a/cmake/ComplexVersion.cpp.in b/cmake/ComplexVersion.cpp.in index fa585ea769..868f394172 100644 --- a/cmake/ComplexVersion.cpp.in +++ b/cmake/ComplexVersion.cpp.in @@ -1,6 +1,6 @@ /*-------------------------------------------------------------------------- * This file is autogenerated from: - * @CMAKE_CURRENT_LIST_DIR@/DREAM3DVersion.cpp.in + * @CMAKE_CURRENT_LIST_DIR@/ComplexVersion.cpp.in * during the cmake configuration of your project. If you need to make changes, * edit the original file NOT THIS FILE. * --------------------------------------------------------------------------*/ diff --git a/cmake/ComplexVersion.h.in b/cmake/ComplexVersion.h.in deleted file mode 100644 index 31ad1f83b6..0000000000 --- a/cmake/ComplexVersion.h.in +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -// Since we are only using this to print versions in the files a lot of functionality from the main applications version is not necessary -#define COMPLEX_PACKAGE_COMPLETE "Complex Version @complex_VERSION_MAJOR@.@complex_VERSION_MINOR@.@complex_VERSION_PATCH@" -#define COMPLEX_VERSION_COMPLETE "@complex_VERSION_MAJOR@.@complex_VERSION_MINOR@.@complex_VERSION_PATCH@" -#define COMPLEX_VERSION_MAJOR "@complex_VERSION_MAJOR@" -#define COMPLEX_VERSION_MINOR "@complex_VERSION_MINOR@" -#define COMPLEX_VERSION_PATCH "@complex_VERSION_PATCH@" From 8e272200aa8a4ba50e28ed6f66ffc9570415264c Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Wed, 25 Oct 2023 14:23:25 -0400 Subject: [PATCH 5/6] Fix failing unit test Signed-off-by: Michael Jackson --- src/Plugins/ComplexCore/test/ExecuteProcessTest.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Plugins/ComplexCore/test/ExecuteProcessTest.cpp b/src/Plugins/ComplexCore/test/ExecuteProcessTest.cpp index d42014568e..7802b8f885 100644 --- a/src/Plugins/ComplexCore/test/ExecuteProcessTest.cpp +++ b/src/Plugins/ComplexCore/test/ExecuteProcessTest.cpp @@ -1,5 +1,6 @@ #include +#include "complex/ComplexVersion.hpp" #include "complex/Parameters/BoolParameter.hpp" #include "complex/Parameters/FileSystemPathParameter.hpp" #include "complex/Parameters/NumberParameter.hpp" @@ -45,10 +46,14 @@ TEST_CASE("ComplexCore::ExecuteProcessFilter: Valid filter execution") std::ifstream processOutputFile(processOutput); REQUIRE(processOutputFile.is_open()); + std::stringstream buffer; + buffer << processOutputFile.rdbuf(); + std::string firstLine; - std::getline(processOutputFile, firstLine); - firstLine = StringUtilities::rtrim(firstLine); - REQUIRE(firstLine == "nxrunner version 1.0.0"); + std::vector outputLines = complex::StringUtilities::split(buffer.str(), '\n'); + firstLine = StringUtilities::trimmed(outputLines[0]); + const std::string correctOutput = fmt::format("nxrunner: Version {} Build Date:{}", complex::Version::Package(), complex::Version::BuildDate()); + REQUIRE(firstLine == correctOutput); } TEST_CASE("ComplexCore::ExecuteProcessFilter: InValid filter execution") From 11334d0e22a51c774ccf01e8ae668bb38a009313 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Wed, 25 Oct 2023 16:16:44 -0400 Subject: [PATCH 6/6] Export out the ComplexVersion namespace symbols Signed-off-by: Michael Jackson --- cmake/ComplexVersion.hpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/cmake/ComplexVersion.hpp b/cmake/ComplexVersion.hpp index f19bab37e8..4ec8d54e7f 100644 --- a/cmake/ComplexVersion.hpp +++ b/cmake/ComplexVersion.hpp @@ -1,23 +1,25 @@ #pragma once +#include "complex/complex_export.hpp" + #include namespace complex::Version { -std::string ApplicationName(); -std::string Complete(); -std::string Major(); -std::string Minor(); -std::string Patch(); -std::string Suffix(); -std::string Package(); -std::string PackageComplete(); -std::string BuildDate(); -std::string GitHashShort(); -std::string GitHash(); - -class AppVersion +COMPLEX_EXPORT std::string ApplicationName(); +COMPLEX_EXPORT std::string Complete(); +COMPLEX_EXPORT std::string Major(); +COMPLEX_EXPORT std::string Minor(); +COMPLEX_EXPORT std::string Patch(); +COMPLEX_EXPORT std::string Suffix(); +COMPLEX_EXPORT std::string Package(); +COMPLEX_EXPORT std::string PackageComplete(); +COMPLEX_EXPORT std::string BuildDate(); +COMPLEX_EXPORT std::string GitHashShort(); +COMPLEX_EXPORT std::string GitHash(); + +class COMPLEX_EXPORT AppVersion { public: AppVersion();