提交 7fa5f6f4 编写于 作者: M Megvii Engine Team

fix(mgb): correct version of fbs serialization

GitOrigin-RevId: 2a71d9afc29befae4619edbc146f1bad038d89c2
上级 a404c508
......@@ -1199,7 +1199,7 @@ if (NOT MGE_WITH_DISTRIBUTED)
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/MegEngineConfigVersion.cmake
VERSION ${MGB_VER_MAJOR}.${MGB_VER_MINOR}.${MGB_VER_PATCH}
VERSION ${MGB_VER_STRING}
COMPATIBILITY SameMajorVersion)
install(EXPORT ${MGE_EXPORT_TARGETS} DESTINATION ${MGE_INSTALL_CMAKEDIR})
......
......@@ -18,6 +18,15 @@ set (MGB_VER_MINOR ${CMAKE_MATCH_1})
string (REGEX MATCH "MGB_PATCH *([0-9]+)" _ ${content})
set (MGB_VER_PATCH ${CMAKE_MATCH_1})
string (REGEX MATCH "MGE_MAJOR +([0-9]+)" _ ${content})
set (MGE_VER_MAJOR ${CMAKE_MATCH_1})
string (REGEX MATCH "MGE_MINOR +([0-9]+)" _ ${content})
set (MGE_VER_MINOR ${CMAKE_MATCH_1})
string (REGEX MATCH "MGE_PATCH *([0-9]+)" _ ${content})
set (MGE_VER_PATCH ${CMAKE_MATCH_1})
if (MGB_FORCE_DEV_VERSION)
set (MGB_IS_DEV 1)
else()
......@@ -25,8 +34,12 @@ else()
set (MGB_IS_DEV ${CMAKE_MATCH_1})
endif()
set (MGB_VER_STRING "${MGB_VER_MAJOR}.${MGB_VER_MINOR}.${MGB_VER_PATCH}")
if (MGB_IS_DEV)
if (DEFINED MGB_VER_MAJOR)
set (MGB_VER_STRING "${MGB_VER_MAJOR}.${MGB_VER_MINOR}.${MGB_VER_PATCH}")
else()
set (MGB_VER_STRING "${MGE_VER_MAJOR}.${MGE_VER_MINOR}.${MGE_VER_PATCH}")
endif(DEFINED MGB_VER_MAJOR)
if (MGB_IS_DEV)
set (MGB_VER_STRING "${MGB_VER_STRING}-dev")
endif()
......
......@@ -75,7 +75,13 @@ add_custom_command(
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/python/requires-test.txt ${CMAKE_CURRENT_BINARY_DIR}/python/requires-test.txt
)
if(DEFINED MGB_VER_MAJOR)
set(IS_INTERNAL "--internal")
else()
set(IS_INTERNAL "")
endif()
add_custom_command(
TARGET ${MODULE_NAME} POST_BUILD
COMMAND "${PYTHON_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/python/gen_version.py --output ${CMAKE_CURRENT_BINARY_DIR}/python/megengine/version.py
COMMAND "${PYTHON_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/python/gen_version.py --output ${CMAKE_CURRENT_BINARY_DIR}/python/megengine/version.py --major ${MGE_VER_MAJOR} --minor ${MGE_VER_MINOR} --patch ${MGE_VER_PATCH} ${IS_INTERNAL}
)
......@@ -17,15 +17,16 @@ def get_mge_version(version_txt_path):
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="generate version.py to build path")
parser.add_argument("--output", type=str, required=True)
parser.add_argument("--major", type=int, required=True)
parser.add_argument("--minor", type=int, required=True)
parser.add_argument("--patch", type=int, required=True)
parser.add_argument("--internal", action='store_true')
args = parser.parse_args()
python_dir = os.path.dirname(__file__)
version_txt_path = os.path.join(python_dir, 'version_template.py')
commit_id = get_git_commit(python_dir)
mge_ver_map = get_mge_version(version_txt_path)
mge_ver = mge_ver_map['__version__'] if '__version__' in mge_ver_map else 'unknown'
mge_intl = mge_ver_map['__internal__'] if '__internal__' in mge_ver_map else False
mge_ver = str(args.major) + "." + str(args.minor) + "." + str(args.patch)
with open(args.output, 'w') as f:
f.write("__version__ = '{}'\n".format(mge_ver))
f.write("git_version = {}\n".format(repr(commit_id)))
if mge_intl:
if args.internal:
f.write("__internal__ = True\n")
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
#
# 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.
__version__ = "1.7.0.dev"
......@@ -14,7 +14,11 @@
using namespace mgb;
Version mgb::get_version() {
#ifdef MGB_MAJOR
return {MGB_MAJOR, MGB_MINOR, MGB_PATCH, MGB_IS_DEV};
#else
return {MGE_MAJOR, MGE_MINOR, MGE_PATCH, MGB_IS_DEV};
#endif
}
// vim: syntax=cpp.doxygen foldmethod=marker foldmarker=f{{{,f}}}
......@@ -13,9 +13,10 @@
#include "megbrain_build_config.h"
#define MGB_MAJOR 8
#define MGB_MINOR 9999
#define MGB_PATCH 0
#define MGE_MAJOR 1
#define MGE_MINOR 7
#define MGE_PATCH 0
//! whether it is development version
#ifndef MGB_IS_DEV
#define MGB_IS_DEV 0
......
......@@ -45,7 +45,7 @@ using namespace mgb::serialization;
namespace {
constexpr uint32_t MGB_VERSION = (MGB_MAJOR * 1000 + MGB_MINOR) * 100 + MGB_PATCH;
constexpr uint32_t MGB_VERSION = (MGE_MAJOR * 1000 + MGE_MINOR) * 100 + MGE_PATCH;
constexpr uint32_t MGB_MAGIC = 0x5342474D;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册