Skip to content
Snippets Groups Projects
Commit 5bebf939 authored by Sergey Yakubov's avatar Sergey Yakubov
Browse files

started versioning for c++ code

parent e6b0851b
No related branches found
No related tags found
No related merge requests found
Showing
with 75 additions and 1 deletion
...@@ -132,3 +132,7 @@ asapo_tools/pkg ...@@ -132,3 +132,7 @@ asapo_tools/pkg
# #
*.rpm *.rpm
#version files
common/cpp/include/common/version.h
common/go/src/asapo_common/version/version_lib.go
\ No newline at end of file
...@@ -10,6 +10,7 @@ ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "GNU") ...@@ -10,6 +10,7 @@ ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "GNU")
SET(BUILD_SHARED_LIBS OFF) SET(BUILD_SHARED_LIBS OFF)
ENDIF(WIN32) ENDIF(WIN32)
#TODO: Better way then GLOBAL PROPERTY #TODO: Better way then GLOBAL PROPERTY
IF(WIN32) IF(WIN32)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
...@@ -88,3 +89,4 @@ if(BUILD_DOCS) ...@@ -88,3 +89,4 @@ if(BUILD_DOCS)
include(doxygen) include(doxygen)
endif() endif()
include(prepare_version)
\ No newline at end of file
execute_process(COMMAND git describe --tags --dirty OUTPUT_VARIABLE VERSION)
string(STRIP ${VERSION} VERSION)
string(TIMESTAMP TIMESTAMP "%H:%M:%S %d.%m.%Y UTC" UTC)
configure_file(${PROJECT_SOURCE_DIR}/common/cpp/include/common/version.h.in ${PROJECT_SOURCE_DIR}/common/cpp/include/common/version.h @ONLY)
configure_file(${PROJECT_SOURCE_DIR}/common/go/src/asapo_common/version/version_lib.go.in ${PROJECT_SOURCE_DIR}/common/go/src/asapo_common/version/version_lib.go @ONLY)
...@@ -16,7 +16,8 @@ if(BUILD_MONGODB_CLIENTLIB) ...@@ -16,7 +16,8 @@ if(BUILD_MONGODB_CLIENTLIB)
endif() endif()
install(DIRECTORY ${ASAPO_CXX_COMMON_INCLUDE_DIR}/common install(DIRECTORY ${ASAPO_CXX_COMMON_INCLUDE_DIR}/common
DESTINATION ${CMAKE_INSTALL_PREFIX}/include ) DESTINATION ${CMAKE_INSTALL_PREFIX}/include
PATTERN "*.h.in" EXCLUDE)
install(DIRECTORY ${ASAPO_CXX_COMMON_INCLUDE_DIR}/logger install(DIRECTORY ${ASAPO_CXX_COMMON_INCLUDE_DIR}/logger
DESTINATION ${CMAKE_INSTALL_PREFIX}/include ) DESTINATION ${CMAKE_INSTALL_PREFIX}/include )
#ifndef ASAPO_VERSION_H
#define ASAPO_VERSION_H
#include <iostream>
namespace asapo {
const char kVersion[] = "@VERSION@";
inline void PrintVersion(std::string prefix) {
std::cout << prefix << ", version " << kVersion << std::endl;
}
}
#endif //ASAPO_VERSION_H
package version
import (
"flag"
"fmt"
"io"
"os"
)
var version
func ShowVersion(w io.Writer, name string) bool {
flags := flag.NewFlagSet("version", flag.ExitOnError)
flag.Bool("version", false, "Print version information") // to have it in main help
flVersion := flags.Bool("version", false, "Print version information")
flags.Bool("help", false, "Print usage") // define help flag but ignore it
flags.Parse(os.Args[1:])
if *flVersion {
fmt.Fprintf(w, "%s version %s\n", name, version)
return true
}
return false
}
package version
// Default build-time variable for library-import.
// This file is overridden on build with build-time informations.
func init(){
version = "@VERSION@"
}
...@@ -35,6 +35,7 @@ void PrintCommandArguments(const Args& args) { ...@@ -35,6 +35,7 @@ void PrintCommandArguments(const Args& args) {
void ProcessCommandArguments(int argc, char* argv[], Args* args) { void ProcessCommandArguments(int argc, char* argv[], Args* args) {
asapo::PrintVersion("Dummy Data Producer");
if (argc != 8) { if (argc != 8) {
std::cout << std::cout <<
"Usage: " << argv[0] << "Usage: " << argv[0] <<
......
...@@ -79,6 +79,7 @@ int ReadAllData(const Params& params, uint64_t* duration_ms) { ...@@ -79,6 +79,7 @@ int ReadAllData(const Params& params, uint64_t* duration_ms) {
} }
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
asapo::PrintVersion("GetNext Broker Example");
if (argc != 6) { if (argc != 6) {
std::cout << "Usage: " + std::string{argv[0]} +" <server> <run_name> <nthreads> <token> <timeout ms>" << std::endl; std::cout << "Usage: " + std::string{argv[0]} +" <server> <run_name> <nthreads> <token> <timeout ms>" << std::endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "asapo_worker.h" #include "asapo_worker.h"
using std::chrono::high_resolution_clock; using std::chrono::high_resolution_clock;
using asapo::Error; using asapo::Error;
...@@ -83,6 +84,8 @@ void PrintStatistics(const Statistics& statistics) { ...@@ -83,6 +84,8 @@ void PrintStatistics(const Statistics& statistics) {
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
asapo::PrintVersion("Process Folder Broker Example");
std::string folder = ProcessCommandArguments(argc, argv); std::string folder = ProcessCommandArguments(argc, argv);
auto broker = CreateBroker(folder); auto broker = CreateBroker(folder);
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
#define ASAPO_ASAPO_PRODUCER_H #define ASAPO_ASAPO_PRODUCER_H
#include "common/io_error.h" #include "common/io_error.h"
#include "common/version.h"
#include "producer/producer.h" #include "producer/producer.h"
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "preprocessor/definitions.h" #include "preprocessor/definitions.h"
#include "io/io_factory.h" #include "io/io_factory.h"
#include "common/version.h"
using asapo::Producer; using asapo::Producer;
using asapo::EventMonConfigFactory; using asapo::EventMonConfigFactory;
...@@ -73,6 +74,8 @@ void SignalHandler(int signal) { ...@@ -73,6 +74,8 @@ void SignalHandler(int signal) {
int main (int argc, char* argv[]) { int main (int argc, char* argv[]) {
asapo::PrintVersion("ASAPO Event Monitor");
auto err = ReadConfigFile(argc, argv); auto err = ReadConfigFile(argc, argv);
if (err) { if (err) {
std::cerr << "cannot read config file: " << err->Explain() << std::endl; std::cerr << "cannot read config file: " << err->Explain() << std::endl;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "receiver_config.h" #include "receiver_config.h"
#include "receiver_logger.h" #include "receiver_logger.h"
#include "common/version.h"
asapo::Error ReadConfigFile(int argc, char* argv[]) { asapo::Error ReadConfigFile(int argc, char* argv[]) {
if (argc != 2) { if (argc != 2) {
...@@ -16,6 +17,7 @@ asapo::Error ReadConfigFile(int argc, char* argv[]) { ...@@ -16,6 +17,7 @@ asapo::Error ReadConfigFile(int argc, char* argv[]) {
} }
int main (int argc, char* argv[]) { int main (int argc, char* argv[]) {
asapo::PrintVersion("ASAPO Receiver");
auto err = ReadConfigFile(argc, argv); auto err = ReadConfigFile(argc, argv);
const auto& logger = asapo::GetDefaultReceiverLogger(); const auto& logger = asapo::GetDefaultReceiverLogger();
......
...@@ -2,5 +2,6 @@ ...@@ -2,5 +2,6 @@
#define ASAPO_ASAPO_WORKER_H #define ASAPO_ASAPO_WORKER_H
#include "worker/data_broker.h" #include "worker/data_broker.h"
#include "common/version.h"
#endif //ASAPO_ASAPO_WORKER_H #endif //ASAPO_ASAPO_WORKER_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment