Browse Source

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

GitOrigin-RevId: 4daa5be6d6
release-1.10
Megvii Engine Team 3 years ago
parent
commit
3949d425fb
4 changed files with 20 additions and 1 deletions
  1. +6
    -0
      CMakeLists.txt
  2. +0
    -1
      dnn/include/megdnn/common.h
  3. +12
    -0
      src/core/impl/version.cpp
  4. +2
    -0
      src/megbrain_build_config.h.in

+ 6
- 0
CMakeLists.txt View File

@@ -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)


+ 0
- 1
dnn/include/megdnn/common.h View File

@@ -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


+ 12
- 0
src/core/impl/version.cpp View File

@@ -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};


+ 2
- 0
src/megbrain_build_config.h.in View File

@@ -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

Loading…
Cancel
Save