diff --git a/CMakeLists.txt b/CMakeLists.txt index 01d7b0ff..3bd7d1ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}) diff --git a/cmake/FetchMegBrainVersion.cmake b/cmake/FetchMegBrainVersion.cmake index 5c625bb6..aab88bfa 100644 --- a/cmake/FetchMegBrainVersion.cmake +++ b/cmake/FetchMegBrainVersion.cmake @@ -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() diff --git a/imperative/CMakeLists.txt b/imperative/CMakeLists.txt index e3cccaac..5e4f0024 100644 --- a/imperative/CMakeLists.txt +++ b/imperative/CMakeLists.txt @@ -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} ) diff --git a/imperative/python/gen_version.py b/imperative/python/gen_version.py index d0e7ef26..bd38ffed 100644 --- a/imperative/python/gen_version.py +++ b/imperative/python/gen_version.py @@ -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") diff --git a/imperative/python/version_template.py b/imperative/python/version_template.py deleted file mode 100644 index 08159023..00000000 --- a/imperative/python/version_template.py +++ /dev/null @@ -1,9 +0,0 @@ -# -*- 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" diff --git a/src/core/impl/version.cpp b/src/core/impl/version.cpp index 7f168603..af76bf1b 100644 --- a/src/core/impl/version.cpp +++ b/src/core/impl/version.cpp @@ -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}}} diff --git a/src/core/include/megbrain/version.h b/src/core/include/megbrain/version.h index 099427df..72ac73fc 100644 --- a/src/core/include/megbrain/version.h +++ b/src/core/include/megbrain/version.h @@ -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 diff --git a/src/serialization/impl/serializer_oss.cpp b/src/serialization/impl/serializer_oss.cpp index ac7aca4d..d30d6971 100644 --- a/src/serialization/impl/serializer_oss.cpp +++ b/src/serialization/impl/serializer_oss.cpp @@ -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;