mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Print Git Hash on --version
This commit is contained in:
@@ -101,6 +101,19 @@ if(C3_USE_TB AND GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
||||||
|
# Get git hash
|
||||||
|
execute_process(COMMAND git rev-parse HEAD
|
||||||
|
OUTPUT_VARIABLE GIT_HASH
|
||||||
|
RESULT_VARIABLE GIT_REVPARSE_RESULT
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
if(GIT_REVPARSE_RESULT EQUAL "0")
|
||||||
|
add_compile_definitions(GIT_HASH="${GIT_HASH}")
|
||||||
|
else()
|
||||||
|
message(WARNING "Cannot to get Git Hash: git rev-parse failed with ${GIT_REVPARSE_RESULT}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
|
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
|
||||||
if (C3_LLVM_VERSION STREQUAL "auto")
|
if (C3_LLVM_VERSION STREQUAL "auto")
|
||||||
set(C3_LLVM_VERSION "18")
|
set(C3_LLVM_VERSION "18")
|
||||||
|
|||||||
@@ -482,6 +482,9 @@ static void print_version(void)
|
|||||||
PRINTF("C3 Compiler Version: %s", COMPILER_VERSION);
|
PRINTF("C3 Compiler Version: %s", COMPILER_VERSION);
|
||||||
#endif
|
#endif
|
||||||
PRINTF("Installed directory: %s", find_executable_path());
|
PRINTF("Installed directory: %s", find_executable_path());
|
||||||
|
#ifdef GIT_HASH
|
||||||
|
PRINTF("Git Hash: %s", GIT_HASH);
|
||||||
|
#endif
|
||||||
PRINTF("LLVM version: %s", llvm_version);
|
PRINTF("LLVM version: %s", llvm_version);
|
||||||
PRINTF("LLVM default target: %s", llvm_target);
|
PRINTF("LLVM default target: %s", llvm_target);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user