Browse Source

fix(build): fix build depends dirty file issue

GitOrigin-RevId: 435d8b5c50
release-1.10
Megvii Engine Team 3 years ago
parent
commit
b92866d2c2
6 changed files with 40 additions and 5 deletions
  1. +14
    -0
      CMakeLists.txt
  2. +8
    -0
      imperative/python/src/common.cpp
  3. +6
    -2
      src/core/impl/version.cpp
  4. +6
    -0
      src/cuda_sm_gen.h.in
  5. +6
    -0
      src/git_full_hash_header.h.in
  6. +0
    -3
      src/megbrain_build_config.h.in

+ 14
- 0
CMakeLists.txt View File

@@ -1224,10 +1224,24 @@ execute_process(
OUTPUT_STRIP_TRAILING_WHITESPACE) 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
# please don't put the configuration that is easy to change at
# megbrain_build_config.h.in for example cuda_sm_gen.h.in and git_full_hash_header.h.in,
# which will lead to CMake build dirty file issue
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)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/genfiles/megbrain_build_config.h install(FILES ${CMAKE_CURRENT_BINARY_DIR}/genfiles/megbrain_build_config.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
if(MGE_WITH_CUDA)
configure_file(src/cuda_sm_gen.h.in
${CMAKE_CURRENT_BINARY_DIR}/genfiles/cuda_sm_gen.h)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/genfiles/cuda_sm_gen.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
endif()

configure_file(src/git_full_hash_header.h.in
${CMAKE_CURRENT_BINARY_DIR}/genfiles/git_full_hash_header.h)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/genfiles/git_full_hash_header.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})


add_subdirectory(dnn) add_subdirectory(dnn)




+ 8
- 0
imperative/python/src/common.cpp View File

@@ -20,6 +20,10 @@
#include "megbrain/graph.h" #include "megbrain/graph.h"
#include "megbrain/imperative/physical_tensor.h" #include "megbrain/imperative/physical_tensor.h"


#if MEGDNN_WITH_CUDA
#include "cuda_sm_gen.h"
#endif

namespace py = pybind11; namespace py = pybind11;
using namespace mgb; using namespace mgb;
using namespace imperative; using namespace imperative;
@@ -248,7 +252,11 @@ void init_common(py::module m) {
m.def("get_device_prop", &CompNode::get_device_prop); m.def("get_device_prop", &CompNode::get_device_prop);


m.def("get_supported_sm_versions", []() { m.def("get_supported_sm_versions", []() {
#if MEGDNN_WITH_CUDA
static const char* mge_gen_code = MGE_CUDA_GENCODE; static const char* mge_gen_code = MGE_CUDA_GENCODE;
#else
static const char* mge_gen_code = "-1";
#endif
return mge_gen_code; return mge_gen_code;
}); });




+ 6
- 2
src/core/impl/version.cpp View File

@@ -12,6 +12,10 @@
#include "megbrain/version.h" #include "megbrain/version.h"
#include "megbrain/common.h" #include "megbrain/common.h"


#ifndef __IN_TEE_ENV__
#include "git_full_hash_header.h"
#endif

using namespace mgb; using namespace mgb;


//! some sdk do not call mgb::get_version explicitly, so we force show version for //! some sdk do not call mgb::get_version explicitly, so we force show version for
@@ -20,8 +24,8 @@ using namespace mgb;
#ifndef __IN_TEE_ENV__ #ifndef __IN_TEE_ENV__
static __attribute__((constructor)) void show_version() { static __attribute__((constructor)) void show_version() {
auto v = get_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);
mgb_log("init Engine with version: %d.%d.%d(%d) @(%s)", v.major, v.minor, v.patch,
v.is_dev, GIT_FULL_HASH);
} }
#endif #endif




+ 6
- 0
src/cuda_sm_gen.h.in View File

@@ -0,0 +1,6 @@
#ifndef _HEADER_MGB_CUDA_SM_GEN_CONFIG
#define _HEADER_MGB_CUDA_SM_GEN_CONFIG

#define MGE_CUDA_GENCODE "@MGE_CUDA_GENCODE@"

#endif // _HEADER_MGB_CUDA_SM_GEN_CONFIG

+ 6
- 0
src/git_full_hash_header.h.in View File

@@ -0,0 +1,6 @@
#ifndef _HEADER_MGB_GIT_FULL_HASH_HEADER_CONFIG
#define _HEADER_MGB_GIT_FULL_HASH_HEADER_CONFIG

#define GIT_FULL_HASH "commit id: @GIT_FULL_HASH@"

#endif // _HEADER_MGB_GIT_FULL_HASH_HEADER_CONFIG

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

@@ -267,7 +267,4 @@
#define MGE_WIN_DECLSPEC_DATA #define MGE_WIN_DECLSPEC_DATA
#endif #endif


#define GIT_FULL_HASH "@GIT_FULL_HASH@"
#define MGE_CUDA_GENCODE "@MGE_CUDA_GENCODE@"

#endif // _HEADER_MGB_BUILD_CONFIG #endif // _HEADER_MGB_BUILD_CONFIG

Loading…
Cancel
Save