!32372 [MS][LITE][Develop] get version from version.txt

Merge pull request !32372 from sunsuodong/get_lite_version
This commit is contained in:
i-robot 2022-04-01 02:50:11 +00:00 committed by Gitee
commit c6f5210e8b
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 20 additions and 25 deletions

View File

@ -58,6 +58,10 @@ option(MSLITE_ENABLE_SHARING_MODEL_WEIGHT "enable sharing model weight" off)
#Option that can be configured through manually
option(ENABLE_VERBOSE "" off)
option(ENABLE_MODEL_OBF "if support model obfuscation" off)
set(VERSION_STR "1.7.0" CACHE STRING "get from version")
add_definitions(-DVERSION_STR=\"${VERSION_STR}\")
if(MACHINE_LINUX_ARM64)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv8-a+fp16")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv8-a+fp16")
@ -432,7 +436,7 @@ if(MSLITE_ENABLE_ACL)
set(ASCEND_CANN_RUNTIME_PATH ${ASCEND_PATH}/latest/fwkacllib/lib64)
endif()
set(PKG_NAME_PREFIX mindspore-lite-${MS_VERSION_MAJOR}.${MS_VERSION_MINOR}.${MS_VERSION_REVISION})
set(PKG_NAME_PREFIX mindspore-lite-${VERSION_STR})
if(SUPPORT_NPU)
set(DDK_PATH "$ENV{HWHIAI_DDK}/ddk/ai_ddk_lib")

View File

@ -35,10 +35,7 @@ check_Hi35xx() {
}
get_version() {
VERSION_MAJOR=$(grep "const int ms_version_major =" ${BASEPATH}/mindspore/lite/include/version.h | tr -dc "[0-9]")
VERSION_MINOR=$(grep "const int ms_version_minor =" ${BASEPATH}/mindspore/lite/include/version.h | tr -dc "[0-9]")
VERSION_REVISION=$(grep "const int ms_version_revision =" ${BASEPATH}/mindspore/lite/include/version.h | tr -dc "[0-9]")
VERSION_STR=${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION}
VERSION_STR=$(cat ${BASEPATH}/version.txt)
}
write_commit_file() {
@ -74,6 +71,7 @@ build_lite_x86_64_jni_and_jar() {
cd ${BASEPATH}/mindspore/lite/build
rm -rf java/jni && mkdir -pv java/jni
cd java/jni
echo "cmake ${X86_JNI_CMAKE_ARGS} -DSUPPORT_TRAIN=${is_train} ${LITE_JAVA_PATH}/native/"
cmake ${X86_JNI_CMAKE_ARGS} -DSUPPORT_TRAIN=${is_train} "${LITE_JAVA_PATH}/native/"
make -j$THREAD_NUM
if [[ $? -ne 0 ]]; then
@ -172,7 +170,7 @@ build_lite_aarch64_jni_and_jar() {
cd ${BASEPATH}/mindspore/lite/build
rm -rf java/jni && mkdir -pv java/jni
cd java/jni
cmake ${AARCH64_JNI_CMAKE_ARGS} -DSUPPORT_TRAIN=${is_train} "${LITE_JAVA_PATH}/native/"
cmake ${AARCH64_JNI_CMAKE_ARGS} -DMACHINE_LINUX_ARM64=on -DSUPPORT_TRAIN=${is_train} "${LITE_JAVA_PATH}/native/"
make -j$THREAD_NUM
if [[ $? -ne 0 ]]; then
echo "---------------- mindspore lite: build jni arm64 failed----------------"
@ -405,7 +403,7 @@ build_lite() {
if [[ "${local_lite_platform}" == "x86_64" ]]; then
if [ "${JAVA_HOME}" ]; then
echo -e "\e[31mJAVA_HOME=$JAVA_HOME \e[0m"
build_lite_x86_64_jni_and_jar $1
build_lite_x86_64_jni_and_jar "${CMAKE_ARGS}"
else
echo -e "\e[31mJAVA_HOME is not set, so jni and jar packages will not be compiled \e[0m"
echo -e "\e[31mIf you want to compile the JAR package, please set $JAVA_HOME. For example: export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64 \e[0m"
@ -413,7 +411,7 @@ build_lite() {
elif [[ "${local_lite_platform}" == "arm64" ]] && [[ "${machine}" == "aarch64" ]]; then
if [ "${JAVA_HOME}" ]; then
echo -e "\e[31mJAVA_HOME=$JAVA_HOME \e[0m"
build_lite_aarch64_jni_and_jar "-DMACHINE_LINUX_ARM64=on"
build_lite_aarch64_jni_and_jar "${CMAKE_ARGS}"
else
echo -e "\e[31mJAVA_HOME is not set, so jni and jar packages will not be compiled \e[0m"
echo -e "\e[31mIf you want to compile the JAR package, please set $JAVA_HOME. For example: export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64 \e[0m"
@ -644,6 +642,7 @@ update_submodule()
git submodule update --init graphengine
cd "${BASEPATH}/graphengine"
git submodule update --init metadef
cd "${BASEPATH}"
}
build_lite_x86_64_aarch64_jar()
@ -753,9 +752,9 @@ fi
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_VERBOSE=${ENABLE_VERBOSE}"
if [[ "${DEBUG_MODE}" == "on" ]]; then
CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Debug "
CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_BUILD_TYPE=Debug "
else
CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release "
CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_BUILD_TYPE=Release "
fi
if [[ "X$ENABLE_GITEE" = "Xon" ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_GITEE=ON"
@ -767,7 +766,7 @@ else
fi
get_version
CMAKE_ARGS="${CMAKE_ARGS} -DMS_VERSION_MAJOR=${VERSION_MAJOR} -DMS_VERSION_MINOR=${VERSION_MINOR} -DMS_VERSION_REVISION=${VERSION_REVISION}"
CMAKE_ARGS="${CMAKE_ARGS} -DVERSION_STR=${VERSION_STR}"
if [[ "X$LITE_ENABLE_AAR" = "Xon" ]]; then
build_aar
@ -779,4 +778,4 @@ fi
if [[ -n "${SERVER_X86_64_PACKAGE_FILE}" ]] && [[ -n "${SERVER_AARCH64_PACKAGE_FILE}" ]]; then
build_lite_x86_64_aarch64_jar
fi
fi

View File

@ -21,16 +21,12 @@
namespace mindspore {
namespace lite {
const int ms_version_major = 1;
const int ms_version_minor = 7;
const int ms_version_revision = 0;
/// \brief Global method to get a version string.
///
/// \return The version string of MindSpore Lite.
inline String Version() {
return "MindSpore Lite " + to_string(ms_version_major) + "." + to_string(ms_version_minor) + "." +
to_string(ms_version_revision);
String version = VERSION_STR;
return "MindSpore Lite " + version;
}
} // namespace lite
} // namespace mindspore

View File

@ -1,6 +1,9 @@
cmake_minimum_required(VERSION 3.10)
project(Lite-java)
set(VERSION_STR "1.7.0" CACHE STRING "get from version")
add_definitions(-DVERSION_STR=\"${VERSION_STR}\")
set(BUILD_LITE "on")
include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/secure_option.cmake)
@ -21,13 +24,6 @@ if(PLATFORM_ARM32 OR PLATFORM_ARM64)
endif()
endif()
set(MS_VERSION_MAJOR ${MS_VERSION_MAJOR})
set(MS_VERSION_MINOR ${MS_VERSION_MINOR})
set(MS_VERSION_REVISION ${MS_VERSION_REVISION})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DMS_VERSION_MAJOR=${MS_VERSION_MAJOR} -DMS_VERSION_MINOR=${MS_VERSION_MINOR} \
-DMS_VERSION_REVISION=${MS_VERSION_REVISION}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMS_VERSION_MAJOR=${MS_VERSION_MAJOR} -DMS_VERSION_MINOR=${MS_VERSION_MINOR} \
-DMS_VERSION_REVISION=${MS_VERSION_REVISION}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
set(CMAKE_SKIP_BUILD_RPATH on)