mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-13 06:16:55 -04:00
feat: include latest commit date in tool header
This commit is contained in:
parent
616841199b
commit
9088a53669
@ -30,6 +30,11 @@ if("${NIXPKGS_DWARFS_VERSION_OVERRIDE}" STREQUAL "")
|
||||
COMMAND git -C "${CMAKE_CURRENT_SOURCE_DIR}" log -1 --format=%h --abbrev=10
|
||||
OUTPUT_VARIABLE PRJ_GIT_REV
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
|
||||
|
||||
execute_process(
|
||||
COMMAND git -C "${CMAKE_CURRENT_SOURCE_DIR}" log -1 --format=%cs
|
||||
OUTPUT_VARIABLE PRJ_GIT_DATE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
|
||||
endif()
|
||||
|
||||
get_filename_component(GIT_TOPLEVEL "${GIT_TOPLEVEL_RAW}" REALPATH)
|
||||
@ -38,6 +43,7 @@ get_filename_component(REAL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" REALPATH)
|
||||
message(STATUS "REAL_SOURCE_DIR: ${REAL_SOURCE_DIR} (${CMAKE_CURRENT_SOURCE_DIR})")
|
||||
message(STATUS "GIT_TOPLEVEL: ${GIT_TOPLEVEL} (${GIT_TOPLEVEL_RAW})")
|
||||
message(STATUS "PRJ_GIT_REV: ${PRJ_GIT_REV}")
|
||||
message(STATUS "PRJ_GIT_DATE: ${PRJ_GIT_DATE}")
|
||||
|
||||
if(((NOT "${REAL_SOURCE_DIR}" STREQUAL "${GIT_TOPLEVEL}")
|
||||
OR ("${PRJ_GIT_REV}" STREQUAL ""))
|
||||
@ -84,6 +90,7 @@ else()
|
||||
endif()
|
||||
|
||||
string(STRIP "${PRJ_GIT_REV}" PRJ_GIT_REV)
|
||||
string(STRIP "${PRJ_GIT_DATE}" PRJ_GIT_DATE)
|
||||
string(STRIP "${PRJ_GIT_DESC}" PRJ_GIT_DESC)
|
||||
string(STRIP "${PRJ_GIT_BRANCH}" PRJ_GIT_BRANCH)
|
||||
string(SUBSTRING "${PRJ_GIT_DESC}" 1 -1 PRJ_VERSION_FULL)
|
||||
@ -103,10 +110,17 @@ else()
|
||||
set(PRJ_GIT_ID "${PRJ_GIT_ID} on branch ${PRJ_GIT_BRANCH}")
|
||||
endif()
|
||||
|
||||
if(PRJ_GIT_DATE)
|
||||
set(PRJ_GIT_DATE_VALUE "\"${PRJ_GIT_DATE}\"")
|
||||
else()
|
||||
set(PRJ_GIT_DATE_VALUE "nullptr")
|
||||
endif()
|
||||
|
||||
set(PKG_VERSION
|
||||
"# autogenerated code, do not modify
|
||||
|
||||
set(PRJ_GIT_REV \"${PRJ_GIT_REV}\")
|
||||
set(PRJ_GIT_DATE \"${PRJ_GIT_DATE}\")
|
||||
set(PRJ_GIT_DESC \"${PRJ_GIT_DESC}\")
|
||||
set(PRJ_GIT_BRANCH \"${PRJ_GIT_BRANCH}\")
|
||||
set(PRJ_GIT_ID \"${PRJ_GIT_ID}\")
|
||||
@ -126,6 +140,7 @@ set(PRJ_VERSION_PATCH \"${PRJ_VERSION_PATCH}\")
|
||||
namespace dwarfs {
|
||||
|
||||
char const* PRJ_GIT_REV = \"${PRJ_GIT_REV}\";
|
||||
char const* PRJ_GIT_DATE = ${PRJ_GIT_DATE_VALUE};
|
||||
char const* PRJ_GIT_DESC = \"${PRJ_GIT_DESC}\";
|
||||
char const* PRJ_GIT_BRANCH = \"${PRJ_GIT_BRANCH}\";
|
||||
char const* PRJ_GIT_ID = \"${PRJ_GIT_ID}\";
|
||||
@ -145,6 +160,7 @@ char const* PRJ_GIT_ID = \"${PRJ_GIT_ID}\";
|
||||
namespace dwarfs {
|
||||
|
||||
extern char const* PRJ_GIT_REV;
|
||||
extern char const* PRJ_GIT_DATE;
|
||||
extern char const* PRJ_GIT_DESC;
|
||||
extern char const* PRJ_GIT_BRANCH;
|
||||
extern char const* PRJ_GIT_ID;
|
||||
|
@ -29,6 +29,10 @@ namespace dwarfs {
|
||||
|
||||
std::string
|
||||
tool_header(std::string_view tool_name, std::string_view extra_info) {
|
||||
std::string date;
|
||||
if (PRJ_GIT_DATE) {
|
||||
date = fmt::format(" [{}]", PRJ_GIT_DATE);
|
||||
}
|
||||
return fmt::format(
|
||||
// clang-format off
|
||||
R"( ___ ___ ___)""\n"
|
||||
@ -36,8 +40,8 @@ tool_header(std::string_view tool_name, std::string_view extra_info) {
|
||||
R"( | |) \ V V / _` | '_| _|\__ \ Advanced Read-only File System)""\n"
|
||||
R"( |___/ \_/\_/\__,_|_| |_| |___/ by Marcus Holland-Moritz)""\n\n"
|
||||
// clang-format on
|
||||
"{} ({}{})\nbuilt on {}\n\n",
|
||||
tool_name, PRJ_GIT_ID, extra_info, PRJ_BUILD_ID);
|
||||
"{} ({}{}{})\nbuilt for {}\n\n",
|
||||
tool_name, PRJ_GIT_ID, date, extra_info, PRJ_BUILD_ID);
|
||||
}
|
||||
|
||||
void add_common_options(boost::program_options::options_description& opts,
|
||||
|
Loading…
x
Reference in New Issue
Block a user