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
#
*.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")
SET(BUILD_SHARED_LIBS OFF)
ENDIF(WIN32)
#TODO: Better way then GLOBAL PROPERTY
IF(WIN32)
find_package(Threads REQUIRED)
......@@ -88,3 +89,4 @@ if(BUILD_DOCS)
include(doxygen)
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)
endif()
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
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) {
void ProcessCommandArguments(int argc, char* argv[], Args* args) {
asapo::PrintVersion("Dummy Data Producer");
if (argc != 8) {
std::cout <<
"Usage: " << argv[0] <<
......
......@@ -79,6 +79,7 @@ int ReadAllData(const Params& params, uint64_t* duration_ms) {
}
int main(int argc, char* argv[]) {
asapo::PrintVersion("GetNext Broker Example");
if (argc != 6) {
std::cout << "Usage: " + std::string{argv[0]} +" <server> <run_name> <nthreads> <token> <timeout ms>" << std::endl;
exit(EXIT_FAILURE);
......
......@@ -8,6 +8,7 @@
#include "asapo_worker.h"
using std::chrono::high_resolution_clock;
using asapo::Error;
......@@ -83,6 +84,8 @@ void PrintStatistics(const Statistics& statistics) {
int main(int argc, char* argv[]) {
asapo::PrintVersion("Process Folder Broker Example");
std::string folder = ProcessCommandArguments(argc, argv);
auto broker = CreateBroker(folder);
......
......@@ -2,6 +2,8 @@
#define ASAPO_ASAPO_PRODUCER_H
#include "common/io_error.h"
#include "common/version.h"
#include "producer/producer.h"
......
......@@ -15,6 +15,7 @@
#include "preprocessor/definitions.h"
#include "io/io_factory.h"
#include "common/version.h"
using asapo::Producer;
using asapo::EventMonConfigFactory;
......@@ -73,6 +74,8 @@ void SignalHandler(int signal) {
int main (int argc, char* argv[]) {
asapo::PrintVersion("ASAPO Event Monitor");
auto err = ReadConfigFile(argc, argv);
if (err) {
std::cerr << "cannot read config file: " << err->Explain() << std::endl;
......
......@@ -5,6 +5,7 @@
#include "receiver_config.h"
#include "receiver_logger.h"
#include "common/version.h"
asapo::Error ReadConfigFile(int argc, char* argv[]) {
if (argc != 2) {
......@@ -16,6 +17,7 @@ asapo::Error ReadConfigFile(int argc, char* argv[]) {
}
int main (int argc, char* argv[]) {
asapo::PrintVersion("ASAPO Receiver");
auto err = ReadConfigFile(argc, argv);
const auto& logger = asapo::GetDefaultReceiverLogger();
......
......@@ -2,5 +2,6 @@
#define ASAPO_ASAPO_WORKER_H
#include "worker/data_broker.h"
#include "common/version.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