From 8a117f8b42ab1e628571d84400a0e4c147dbec56 Mon Sep 17 00:00:00 2001 From: Brian <49288125+br337@users.noreply.github.com> Date: Wed, 20 Nov 2024 19:54:49 +0100 Subject: [PATCH] feat: add version parameter to xml2cpp codegen tool (#463) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added -v, --version xml2cpp command line tool options * Update tools/xml2cpp-codegen/xml2cpp.cpp Co-authored-by: Stanislav Angelovič * Updated tools/CMakeLists.txt --------- Co-authored-by: Stanislav Angelovič --- tools/CMakeLists.txt | 1 + tools/xml2cpp-codegen/xml2cpp.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index c025e36..79ba188 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -44,6 +44,7 @@ set(CMAKE_CXX_STANDARD 14) add_executable(sdbus-c++-xml2cpp ${SDBUSCPP_XML2CPP_SRCS}) target_link_libraries (sdbus-c++-xml2cpp ${EXPAT_LIBRARIES}) target_include_directories(sdbus-c++-xml2cpp PRIVATE ${EXPAT_INCLUDE_DIRS}) +target_compile_definitions(sdbus-c++-xml2cpp PRIVATE SDBUS_XML2CPP_VERSION="${CMAKE_PROJECT_VERSION}") #---------------------------------- # CMAKE CONFIG & PACKAGE CONFIG diff --git a/tools/xml2cpp-codegen/xml2cpp.cpp b/tools/xml2cpp-codegen/xml2cpp.cpp index 5a8bdfc..ba9e45f 100644 --- a/tools/xml2cpp-codegen/xml2cpp.cpp +++ b/tools/xml2cpp-codegen/xml2cpp.cpp @@ -51,6 +51,7 @@ void usage(std::ostream& output, const char* programName) " --adaptor=FILE Generate header file FILE with stub class (server)" << endl << " -h, --help " << endl << " --verbose Explain what is being done" << endl << + " -v, --version Prints out sdbus-c++ version used by the tool" << endl << endl << "The stub generator takes an XML file describing DBus interface and creates" << endl << "C++ header files to be used by C++ code wanting to cumminicate through that" << endl << @@ -104,6 +105,11 @@ int main(int argc, char **argv) usage(std::cout, programName); return 0; } + else if (!strcmp(*argv, "--version") || !strcmp(*argv, "-v")) + { + std::cout << "Version: " << SDBUS_XML2CPP_VERSION << std::endl; + return 0; + } else if (!strcmp(*argv, "--verbose")) { verbose = true;