Display the currently built commit sha when debugging the game (#1266)

* generate a string constant with the currently built commit sha

* draw the commit sha on the top left
This commit is contained in:
Tyler Wilding
2022-03-31 19:29:48 -04:00
committed by GitHub
parent e74bd3b32b
commit 67b4afc506
6 changed files with 44 additions and 3 deletions
+4 -1
View File
@@ -39,4 +39,7 @@ imgui.ini
node_modules/
# texture replacements
texture_replacements/*
texture_replacements/*
# generated cmake files
svnrev.h
+21
View File
@@ -124,6 +124,27 @@ set(RUNTIME_SOURCE
system/vm/dmac.cpp
system/vm/vm.cpp)
find_package(Git)
function(write_svnrev_h)
set(GIT_SHORT_SHA "")
if (GIT_FOUND AND EXISTS ${CMAKE_SOURCE_DIR}/.git)
EXECUTE_PROCESS(WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
OUTPUT_VARIABLE GIT_SHORT_SHA
OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
set(GIT_SHORT_SHA "unk. rev.")
endif()
if(NOT GIT_SHORT_SHA)
set(GIT_SHORT_SHA "unk. rev.")
else()
string(SUBSTRING ${GIT_SHORT_SHA} 0 6 GIT_SHORT_SHA)
endif()
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/kernel/svnrev.h "#define GIT_SHORT_SHA \"rev. ${GIT_SHORT_SHA}\"\n")
endfunction()
write_svnrev_h()
# we build the runtime as a static library.
add_library(runtime STATIC ${RUNTIME_SOURCE} "../third-party/glad/src/glad.c")
+4
View File
@@ -40,6 +40,9 @@
#include "game/sce/libscf.h"
#include "common/util/Assert.h"
#include "game/discord.h"
#include "svnrev.h"
using namespace ee;
/*!
@@ -884,6 +887,7 @@ void InitMachine_PCPort() {
// TODO - we will eventually need a better way to know what game we are playing
auto settings_path = file_util::get_user_settings_dir();
intern_from_c("*pc-settings-folder*")->value = make_string_from_c(settings_path.string().c_str());
intern_from_c("*pc-settings-built-sha*")->value = make_string_from_c(GIT_SHORT_SHA);
}
void vif_interrupt_callback() {
+3
View File
@@ -665,6 +665,9 @@
(*draw-hook*)
(add-ee-profile-frame 'draw :g #x80)
(#when PC_PORT
(draw-build-revision))
(*menu-hook*)
(add-ee-profile-frame 'draw :g #x40)
+1
View File
@@ -341,6 +341,7 @@
;; Constants generated within the C++ runtime
(define-extern *pc-user-dir-base-path* string)
(define-extern *pc-settings-folder* string)
(define-extern *pc-settings-built-sha* string)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; vm functions
+11 -2
View File
@@ -898,10 +898,19 @@
(define *entity-debug-inspect* (new 'debug 'entity-debug-inspect))
)
) ;; when debug_segment
(defun-debug draw-build-revision ()
(with-dma-buffer-add-bucket ((buf (-> (current-frame) debug-buf))
(bucket-id debug-draw1))
(draw-string-xy *pc-settings-built-sha*
buf
0
(* 10 (-> *video-parms* relative-y-scale))
(font-color flat-yellow)
(font-flags kerning))))
)
) ;; when PC_PORT