Skip to content

Commit

Permalink
print the current git revision
Browse files Browse the repository at this point in the history
  • Loading branch information
guicho271828 committed Jan 12, 2025
1 parent 5198d3c commit 4f57284
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ __pycache__/
/misc/autodoc/downward-xmlrpc.secret
*~
#*
src/search/git_revision.h
9 changes: 9 additions & 0 deletions src/search/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ set_up_options()
project(downward LANGUAGES CXX)
add_executable(downward planner.cc)

# write git SHA1 hash into a header file
execute_process(
COMMAND git log -1 "--format=format:\"%H\"%n" HEAD
OUTPUT_VARIABLE GIT_REVISION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
configure_file(git_revision.h.in git_revision.h)
target_include_directories(downward PUBLIC "${PROJECT_BINARY_DIR}")

# On Windows we have to copy all DLLs next to the generated binary.
if (WIN32)
copy_dlls_to_binary_dir_after_build(downward)
Expand Down
1 change: 1 addition & 0 deletions src/search/git_revision.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#define GIT_REVISION @GIT_REVISION@
3 changes: 3 additions & 0 deletions src/search/planner.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "git_revision.h"
#include "command_line.h"
#include "search_algorithm.h"

Expand All @@ -16,6 +17,8 @@ int main(int argc, const char **argv) {
try {
utils::register_event_handlers();

utils::g_log << "Fast Downward build " << GIT_REVISION << endl;

if (argc < 2) {
utils::g_log << usage(argv[0]) << endl;
utils::exit_with(ExitCode::SEARCH_INPUT_ERROR);
Expand Down

0 comments on commit 4f57284

Please sign in to comment.