提交 3949d425 编写于 作者: M Megvii Engine Team

feat(core): always show MegEngine version and git commit id

GitOrigin-RevId: 4daa5be6d6b536953c00722c6a4f14a42f3769fd
上级 90cedd3c
...@@ -1211,6 +1211,12 @@ set(MGE_VERSION_SCRIPT ...@@ -1211,6 +1211,12 @@ set(MGE_VERSION_SCRIPT
${PROJECT_SOURCE_DIR}/src/version.ld ${PROJECT_SOURCE_DIR}/src/version.ld
CACHE INTERNAL "Path to linker version script") CACHE INTERNAL "Path to linker version script")
execute_process(
COMMAND git log -1 --format=%H
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
OUTPUT_VARIABLE GIT_FULL_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE)
# Write out megbrain_build_config.h It defines macros needed by both megbrain and dnn # Write out megbrain_build_config.h It defines macros needed by both megbrain and dnn
configure_file(src/megbrain_build_config.h.in configure_file(src/megbrain_build_config.h.in
${CMAKE_CURRENT_BINARY_DIR}/genfiles/megbrain_build_config.h) ${CMAKE_CURRENT_BINARY_DIR}/genfiles/megbrain_build_config.h)
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "megbrain_build_config.h" #include "megbrain_build_config.h"
#include "megdnn/oprs/base.h" #include "megdnn/oprs/base.h"
#if MGB_ENABLE_GETENV #if MGB_ENABLE_GETENV
#define MGB_GETENV ::std::getenv #define MGB_GETENV ::std::getenv
#else #else
......
...@@ -10,9 +10,21 @@ ...@@ -10,9 +10,21 @@
*/ */
#include "megbrain/version.h" #include "megbrain/version.h"
#include "megbrain/common.h"
using namespace mgb; using namespace mgb;
//! some sdk do not call mgb::get_version explicitly, so we force show version for
//! debug, mgb_log level is info, sdk may config a higher, need export
//! RUNTIME_OVERRIDE_LOG_LEVEL=0 to force change log level to show version
#ifndef __IN_TEE_ENV__
static __attribute__((constructor)) void show_version() {
auto v = get_version();
mgb_log("init Engine with version: %d.%d.%d(%d) at git commitid: %s", v.major,
v.minor, v.patch, v.is_dev, GIT_FULL_HASH);
}
#endif
Version mgb::get_version() { Version mgb::get_version() {
#ifdef MGB_MAJOR #ifdef MGB_MAJOR
return {MGB_MAJOR, MGB_MINOR, MGB_PATCH, MGB_IS_DEV}; return {MGB_MAJOR, MGB_MINOR, MGB_PATCH, MGB_IS_DEV};
......
...@@ -267,4 +267,6 @@ ...@@ -267,4 +267,6 @@
#define MGE_WIN_DECLSPEC_DATA #define MGE_WIN_DECLSPEC_DATA
#endif #endif
#define GIT_FULL_HASH "@GIT_FULL_HASH@"
#endif // _HEADER_MGB_BUILD_CONFIG #endif // _HEADER_MGB_BUILD_CONFIG
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册