From 399f4a33a134f754ba5444398139c967c72ddce6 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Fri, 25 May 2018 13:33:47 -0600 Subject: [PATCH] CMake: Check Git commit SHA1 This is for PandaSystem::get_git_commit() --- dtool/PandaVersion.cmake | 10 ++++++++++ dtool/src/dtoolbase/pandaVersion.h.in | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/dtool/PandaVersion.cmake b/dtool/PandaVersion.cmake index 88a21cc286..a503f150e0 100644 --- a/dtool/PandaVersion.cmake +++ b/dtool/PandaVersion.cmake @@ -73,6 +73,16 @@ set(PANDA_VERSION_SYMBOL panda_version_${PROJECT_VERSION_MAJOR}_${PROJECT_VERSIO # for each component. math(EXPR PANDA_NUMERIC_VERSION "${PROJECT_VERSION_MAJOR}*1000000 + ${PROJECT_VERSION_MINOR}*1000 + ${PROJECT_VERSION_PATCH}") +# The Panda Git SHA1 refspec, for PandaSystem::get_git_commit() +find_package(Git QUIET) +if(GIT_EXECUTABLE) + execute_process( + COMMAND "${GIT_EXECUTABLE}" rev-parse HEAD + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + OUTPUT_VARIABLE PANDA_GIT_COMMIT_STR + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) +endif() + # Separate the plugin version into its three components. string(REPLACE "." ";" P3D_PLUGIN_VERSION_LIST "${P3D_PLUGIN_VERSION}") list(GET P3D_PLUGIN_VERSION_LIST 0 P3D_PLUGIN_MAJOR_VERSION) diff --git a/dtool/src/dtoolbase/pandaVersion.h.in b/dtool/src/dtoolbase/pandaVersion.h.in index c544ae7fdf..3e93349dca 100644 --- a/dtool/src/dtoolbase/pandaVersion.h.in +++ b/dtool/src/dtoolbase/pandaVersion.h.in @@ -49,6 +49,10 @@ out from CVS by the builder). */ #define PANDA_VERSION_STR "@PANDA_VERSION_STR@" +/* This is the Git commit we built Panda from, or an empty string if this isn't + known. */ +#define PANDA_GIT_COMMIT_STR "@PANDA_GIT_COMMIT_STR@" + /* This is the version of the Panda3D ABI expressed as a string. This usually means the major and minor version. It should be the same for Panda3D versions that are supposed to be backward