Skip to content

Commit

Permalink
Improved version number system to show git commit
Browse files Browse the repository at this point in the history
  • Loading branch information
cschreib committed Mar 20, 2019
1 parent 7ba7ae0 commit ecf4f02
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
15 changes: 15 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@ set(NO_WCSLIB ON)

find_package(vif REQUIRED)

# Figure out git hash, if any
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
RESULT_VARIABLE GIT_COMMAND_SUCCESS
OUTPUT_STRIP_TRAILING_WHITESPACE
)

if (GIT_COMMAND_SUCCESS EQUAL 0)
add_definitions(-DFASTPP_GIT_HASH="${GIT_COMMIT_HASH}")
else()
add_definitions(-DFASTPP_GIT_HASH="")
endif()

# Setup share directory
add_definitions(-DFASTPP_SHARE_DIR="${FASTPP_SHARE_DIR}")

Expand Down
6 changes: 5 additions & 1 deletion src/fast++-read_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,11 @@ bool read_params(options_t& opts, input_state_t& state, const std::string& filen
}

if (opts.verbose) {
note("this is FAST++ version '", fastpp_version, "'");
if (std::string(fastpp_git_hash).empty()) {
note("this is FAST++ version '", fastpp_version, "'");
} else {
note("this is FAST++ version '", fastpp_version, "-", fastpp_git_hash, "')");
}
}

// Create output directory, if it doesn't exist
Expand Down
7 changes: 6 additions & 1 deletion src/fast++.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#include "fast++.hpp"
#include <vif/core/main.hpp>

const char* fastpp_version = "1.3-git";
#ifndef FASTPP_GIT_HASH
#define FASTPP_GIT_HASH ""
#endif

const char* fastpp_version = "1.2.1";
const char* fastpp_git_hash = FASTPP_GIT_HASH;

const constexpr uint_t grid_id::z;
const constexpr uint_t grid_id::av;
Expand Down
1 change: 1 addition & 0 deletions src/fast++.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ using namespace vif;
using namespace vif::astro;

extern const char* fastpp_version;
extern const char* fastpp_git_hash;

// Program structures
// ------------------
Expand Down

0 comments on commit ecf4f02

Please sign in to comment.