version.cpp 1.2 KB
Newer Older
1 2 3 4
/**
 * \file src/core/impl/version.cpp
 * MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
 *
5
 * Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
6 7 8 9 10 11 12
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 */

#include "megbrain/version.h"
13
#include "megbrain/common.h"
14 15 16

using namespace mgb;

17 18 19 20 21 22 23 24 25 26 27
//! 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

28
Version mgb::get_version() {
29
#ifdef MGB_MAJOR
30
    return {MGB_MAJOR, MGB_MINOR, MGB_PATCH, MGB_IS_DEV};
31 32 33
#else
    return {MGE_MAJOR, MGE_MINOR, MGE_PATCH, MGB_IS_DEV};
#endif
34 35 36
}

// vim: syntax=cpp.doxygen foldmethod=marker foldmarker=f{{{,f}}}