Skip to content

Commit ecf4f02

Browse files
committed
Improved version number system to show git commit
1 parent 7ba7ae0 commit ecf4f02

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

src/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,21 @@ set(NO_WCSLIB ON)
1414

1515
find_package(vif REQUIRED)
1616

17+
# Figure out git hash, if any
18+
execute_process(
19+
COMMAND git log -1 --format=%h
20+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
21+
OUTPUT_VARIABLE GIT_COMMIT_HASH
22+
RESULT_VARIABLE GIT_COMMAND_SUCCESS
23+
OUTPUT_STRIP_TRAILING_WHITESPACE
24+
)
25+
26+
if (GIT_COMMAND_SUCCESS EQUAL 0)
27+
add_definitions(-DFASTPP_GIT_HASH="${GIT_COMMIT_HASH}")
28+
else()
29+
add_definitions(-DFASTPP_GIT_HASH="")
30+
endif()
31+
1732
# Setup share directory
1833
add_definitions(-DFASTPP_SHARE_DIR="${FASTPP_SHARE_DIR}")
1934

src/fast++-read_input.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,11 @@ bool read_params(options_t& opts, input_state_t& state, const std::string& filen
239239
}
240240

241241
if (opts.verbose) {
242-
note("this is FAST++ version '", fastpp_version, "'");
242+
if (std::string(fastpp_git_hash).empty()) {
243+
note("this is FAST++ version '", fastpp_version, "'");
244+
} else {
245+
note("this is FAST++ version '", fastpp_version, "-", fastpp_git_hash, "')");
246+
}
243247
}
244248

245249
// Create output directory, if it doesn't exist

src/fast++.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
#include "fast++.hpp"
22
#include <vif/core/main.hpp>
33

4-
const char* fastpp_version = "1.3-git";
4+
#ifndef FASTPP_GIT_HASH
5+
#define FASTPP_GIT_HASH ""
6+
#endif
7+
8+
const char* fastpp_version = "1.2.1";
9+
const char* fastpp_git_hash = FASTPP_GIT_HASH;
510

611
const constexpr uint_t grid_id::z;
712
const constexpr uint_t grid_id::av;

src/fast++.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ using namespace vif;
1919
using namespace vif::astro;
2020

2121
extern const char* fastpp_version;
22+
extern const char* fastpp_git_hash;
2223

2324
// Program structures
2425
// ------------------

0 commit comments

Comments
 (0)