mirror of https://review.coreboot.org/STM.git
Print Git Hash at begining of STM startup
Printing the Git hash provides information about the patchlevel of the STM. My thanks to jonathanhamberg for creating and sharing the cmake script that made this possible. Signed-off-by: Eugene Myers <edmyers@cyberpackventures.com>
This commit is contained in:
parent
e1538fd996
commit
55106defc3
|
@ -3,6 +3,9 @@ cmake_minimum_required(VERSION 3.13)
|
|||
|
||||
project(stm C ASM)
|
||||
|
||||
include("${PROJECT_SOURCE_DIR}/cmake/CheckGit.cmake")
|
||||
CheckGitSetup()
|
||||
|
||||
if("${BIOS}" STREQUAL "coreboot")
|
||||
add_definitions( -DCOREBOOT32 )
|
||||
message("Building for Coreboot")
|
||||
|
@ -52,6 +55,7 @@ include_directories("${PROJECT_SOURCE_DIR}/StmPkg/Core"
|
|||
"${PROJECT_SOURCE_DIR}/StmPkg/Include"
|
||||
"${PROJECT_SOURCE_DIR}/StmPkg/Include/x64"
|
||||
"${PROJECT_SOURCE_DIR}/StmPkg/Core/Runtime"
|
||||
"${PROJECT_SOURCE_DIR}/cmake"
|
||||
)
|
||||
|
||||
add_subdirectory(StmPkg/EdkII/MdePkg/Library/BaseLib)
|
||||
|
|
|
@ -16,15 +16,8 @@ target_include_directories(StmInit PUBLIC
|
|||
)
|
||||
|
||||
target_link_libraries(StmInit PUBLIC
|
||||
#BaseLib
|
||||
#BaseMemoryLib
|
||||
#IoLib
|
||||
#PciLib
|
||||
SynchronizationLib
|
||||
#DebugLib
|
||||
#StmLib
|
||||
#PcdLib
|
||||
#StmPlatformLib
|
||||
StmRuntime
|
||||
Resource
|
||||
git_version
|
||||
)
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
#include "StmInit.h"
|
||||
#include "PeStm.h"
|
||||
#include <Library/PcdLib.h>
|
||||
#include <string.h>
|
||||
#include <string.h>
|
||||
#include "git_version.h"
|
||||
|
||||
extern PE_SMI_CONTROL PeSmiControl;
|
||||
|
||||
|
@ -676,6 +677,8 @@ BspInit (
|
|||
|
||||
DEBUG ((EFI_D_INFO, " ********************** STM/PE *********************\n"));
|
||||
DEBUG ((EFI_D_INFO, "!!!STM build time - %a %a!!!\n", (CHAR8 *)__DATE__, (CHAR8 *)__TIME__));
|
||||
DEBUG ((EFI_D_INFO, "!!!STM Git Hash - %c%c%c%c%c%c%c%c !!!\n", kGitHash[0], kGitHash[1], kGitHash[2],
|
||||
kGitHash[3], kGitHash[4], kGitHash[5], kGitHash[6], kGitHash[7]));
|
||||
DEBUG ((EFI_D_INFO, "!!!STM Relocation DONE!!!\n"));
|
||||
DEBUG ((EFI_D_INFO, "!!!Enter StmInit (BSP)!!! - %d (%x)\n", (UINTN)0, (UINTN)ReadUnaligned32 ((UINT32 *)&Register->Rax)));
|
||||
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
set(CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||
if (NOT DEFINED pre_configure_dir)
|
||||
set(pre_configure_dir ${CMAKE_CURRENT_LIST_DIR})
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED post_configure_dir)
|
||||
set(post_configure_dir ${CMAKE_BINARY_DIR}/generated)
|
||||
endif ()
|
||||
|
||||
set(pre_configure_file ${pre_configure_dir}/git_version.c.in)
|
||||
set(post_configure_file ${post_configure_dir}/git_version.c)
|
||||
|
||||
function(CheckGitWrite git_hash)
|
||||
file(WRITE ${CMAKE_BINARY_DIR}/git-state.txt ${git_hash})
|
||||
endfunction()
|
||||
|
||||
function(CheckGitRead git_hash)
|
||||
if (EXISTS ${CMAKE_BINARY_DIR}/git-state.txt)
|
||||
file(STRINGS ${CMAKE_BINARY_DIR}/git-state.txt CONTENT)
|
||||
LIST(GET CONTENT 0 var)
|
||||
|
||||
set(${git_hash} ${var} PARENT_SCOPE)
|
||||
endif ()
|
||||
endfunction()
|
||||
|
||||
function(CheckGitVersion)
|
||||
# Get the latest abbreviated commit hash of the working branch
|
||||
execute_process(
|
||||
COMMAND git log -1 --format=%h
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
||||
OUTPUT_VARIABLE GIT_HASH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
CheckGitRead(GIT_HASH_CACHE)
|
||||
if (NOT EXISTS ${post_configure_dir})
|
||||
file(MAKE_DIRECTORY ${post_configure_dir})
|
||||
endif ()
|
||||
|
||||
if (NOT EXISTS ${post_configure_dir}/git_version.h)
|
||||
file(COPY ${pre_configure_dir}/git_version.h DESTINATION ${post_configure_dir})
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED GIT_HASH_CACHE)
|
||||
set(GIT_HASH_CACHE "INVALID")
|
||||
endif ()
|
||||
|
||||
# Only update the git_version.c if the hash has changed. This will
|
||||
# prevent us from rebuilding the project more than we need to.
|
||||
if (NOT ${GIT_HASH} STREQUAL ${GIT_HASH_CACHE} OR NOT EXISTS ${post_configure_file})
|
||||
# Set che GIT_HASH_CACHE variable the next build won't have
|
||||
# to regenerate the source file.
|
||||
CheckGitWrite(${GIT_HASH})
|
||||
|
||||
configure_file(${pre_configure_file} ${post_configure_file} @ONLY)
|
||||
endif ()
|
||||
|
||||
endfunction()
|
||||
|
||||
function(CheckGitSetup)
|
||||
|
||||
add_custom_target(AlwaysCheckGit COMMAND ${CMAKE_COMMAND}
|
||||
-DRUN_CHECK_GIT_VERSION=1
|
||||
-Dpre_configure_dir=${pre_configure_dir}
|
||||
-Dpost_configure_file=${post_configure_dir}
|
||||
-DGIT_HASH_CACHE=${GIT_HASH_CACHE}
|
||||
-P ${CURRENT_LIST_DIR}/CheckGit.cmake
|
||||
BYPRODUCTS ${post_configure_file}
|
||||
)
|
||||
|
||||
add_library(git_version ${CMAKE_BINARY_DIR}/generated/git_version.c)
|
||||
target_include_directories(git_version PUBLIC ${CMAKE_BINARY_DIR}/generated)
|
||||
add_dependencies(git_version AlwaysCheckGit)
|
||||
|
||||
CheckGitVersion()
|
||||
endfunction()
|
||||
|
||||
# This is used to run this function from an external cmake process.
|
||||
if (RUN_CHECK_GIT_VERSION)
|
||||
CheckGitVersion()
|
||||
endif ()
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
#include "git_version.h"
|
||||
const char *kGitHash = "@GIT_HASH@";
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef GIT_VERSION_H
|
||||
#define GIT_VERSION_H
|
||||
|
||||
extern const char *kGitHash;
|
||||
|
||||
#endif // GIT_VERSION_H
|
Loading…
Reference in New Issue