From 2aba92bdce4bbb7031aa7e46bda0655f55102e4a Mon Sep 17 00:00:00 2001 From: Chen Gong Date: Wed, 21 Aug 2024 14:02:50 +0800 Subject: [PATCH] Add the function of outputting rdci version information Change-Id: Iabeec48ba2e109ead7fb6fb07454ebcdc74a11e6 Signed-off-by: Chen Gong [ROCm/rdc commit: 6591563d533537f8ea26f276cf2cf22ac4a15682] --- projects/rdc/rdci/src/rdci.cc | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/projects/rdc/rdci/src/rdci.cc b/projects/rdc/rdci/src/rdci.cc index 5da66a68b1..bdffe096f5 100644 --- a/projects/rdc/rdci/src/rdci.cc +++ b/projects/rdc/rdci/src/rdci.cc @@ -22,6 +22,7 @@ THE SOFTWARE. #include #include +#include #include "RdciDiagSubSystem.h" #include "RdciDiscoverySubSystem.h" @@ -33,16 +34,39 @@ THE SOFTWARE. #include "rdc_lib/RdcException.h" #include "rdc_lib/rdc_common.h" +#define RDC_CLIENT_VERSION_MAJOR 1 +#define RDC_CLIENT_VERSION_MINOR 0 +#define RDC_CLIENT_VERSION_RELEASE 0 + +#define RDC_CLIENT_VERSION_CREATE_STRING(MAJOR, MINOR, RELEASE) (#MAJOR "." #MINOR "." #RELEASE) +#define RDC_CLIENT_VERSION_EXPAND_PARTS(MAJOR_STR, MINOR_STR, RELEASE_STR) RDC_CLIENT_VERSION_CREATE_STRING(MAJOR_STR, MINOR_STR, RELEASE_STR) +#define RDC_CLIENT_VERSION_STRING RDC_CLIENT_VERSION_EXPAND_PARTS(RDC_CLIENT_VERSION_MAJOR, RDC_CLIENT_VERSION_MINOR, RDC_CLIENT_VERSION_RELEASE) + +#define Q(x) #x +#define QUOTE(x) Q(x) + int main(int argc, char** argv) { const std::string usage_help = - "Usage:\trdci \nsubsystem: discovery, dmon, group, " - "fieldgroup, stats, diag\n"; + "Usage:\trdci |\n" + "subsystem: \n" + " discovery, dmon, group, fieldgroup, stats, diag\n" + "options: \n" + " -v(--version) : Print client version information only\n"; if (argc <= 1) { std::cout << usage_help; exit(0); } + if (strcmp(argv[1], "-v") == 0 || strcmp(argv[1], "--version") == 0) { +#ifdef CURRENT_GIT_HASH + std::cout << "RDCI : " << RDC_CLIENT_VERSION_STRING << "+" << QUOTE(CURRENT_GIT_HASH) << std::endl; +#else + std::cout << "RDCI : " << RDC_CLIENT_VERSION_STRING << std::endl; +#endif + exit(0); + } + amd::rdc::RdciSubSystemPtr subsystem; try { std::string subsystem_name = argv[1];