!5742 remove version string in build_aar.sh

Merge pull request !5742 from hangq/master
This commit is contained in:
mindspore-ci-bot 2020-09-04 11:10:19 +08:00 committed by Gitee
commit 680b6ded1e
13 changed files with 116 additions and 91 deletions

View File

@ -571,8 +571,10 @@ build_minddata_lite_deps()
build_lite()
{
echo "start build mindspore lite project"
VERSION_MAJOR=`grep "#define MS_VERSION_MAJOR" mindspore/lite/include/version.h | tr -dc "[0-9]"`
VERSION_MINOR=`grep "#define MS_VERSION_MINOR" mindspore/lite/include/version.h | tr -dc "[0-9]"`
VERSION_REVISION=`grep "#define MS_VERSION_REVISION" mindspore/lite/include/version.h | tr -dc "[0-9]"`
echo "============ Start building MindSpore Lite ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION} ============"
if [ "${ENABLE_GPU}" == "on" ] && [ "${LITE_PLATFORM}" == "arm64" ]; then
echo "start build opencl"
build_opencl
@ -605,7 +607,8 @@ build_lite()
-DANDROID_STL="c++_shared" -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DSUPPORT_TRAIN=${SUPPORT_TRAIN} \
-DBUILD_DEVICE=on -DPLATFORM_ARM64=on -DBUILD_CONVERTER=off -DENABLE_NEON=on -DENABLE_FP16="off" \
-DSUPPORT_GPU=${ENABLE_GPU} -DOFFLINE_COMPILE=${OPENCL_OFFLINE_COMPILE} -DBUILD_MINDDATA=${COMPILE_MINDDATA_LITE} \
-DCMAKE_INSTALL_PREFIX=${BASEPATH}/output/tmp "${BASEPATH}/mindspore/lite"
-DCMAKE_INSTALL_PREFIX=${BASEPATH}/output/tmp -DMS_VERSION_MAJOR=${VERSION_MAJOR} \
-DMS_VERSION_MINOR=${VERSION_MINOR} -DMS_VERSION_REVISION=${VERSION_REVISION} "${BASEPATH}/mindspore/lite"
elif [[ "${LITE_PLATFORM}" == "arm32" ]]; then
checkndk
cmake -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" -DANDROID_NATIVE_API_LEVEL="19" \
@ -613,11 +616,14 @@ build_lite()
-DANDROID_STL="c++_shared" -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DBUILD_DEVICE=on -DPLATFORM_ARM32=on -DENABLE_NEON=on -DSUPPORT_TRAIN=${SUPPORT_TRAIN} -DBUILD_CONVERTER=off \
-DSUPPORT_GPU=${ENABLE_GPU} -DOFFLINE_COMPILE=${OPENCL_OFFLINE_COMPILE} -DBUILD_MINDDATA=${COMPILE_MINDDATA_LITE} \
-DCMAKE_INSTALL_PREFIX=${BASEPATH}/output/tmp "${BASEPATH}/mindspore/lite"
-DCMAKE_INSTALL_PREFIX=${BASEPATH}/output/tmp -DMS_VERSION_MAJOR=${VERSION_MAJOR} \
-DMS_VERSION_MINOR=${VERSION_MINOR} -DMS_VERSION_REVISION=${VERSION_REVISION} "${BASEPATH}/mindspore/lite"
else
cmake -DBUILD_DEVICE=on -DPLATFORM_ARM64=off -DBUILD_CONVERTER=${ENABLE_CONVERTER} -DSUPPORT_TRAIN=${SUPPORT_TRAIN} \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DSUPPORT_GPU=${ENABLE_GPU} -DBUILD_MINDDATA=${COMPILE_MINDDATA_LITE} \
-DOFFLINE_COMPILE=${OPENCL_OFFLINE_COMPILE} -DCMAKE_INSTALL_PREFIX=${BASEPATH}/output/tmp "${BASEPATH}/mindspore/lite"
-DOFFLINE_COMPILE=${OPENCL_OFFLINE_COMPILE} -DCMAKE_INSTALL_PREFIX=${BASEPATH}/output/tmp \
-DMS_VERSION_MAJOR=${VERSION_MAJOR} -DMS_VERSION_MINOR=${VERSION_MINOR} -DMS_VERSION_REVISION=${VERSION_REVISION} \
"${BASEPATH}/mindspore/lite"
fi
VERBOSE=2 make -j$THREAD_NUM && make install && make package
COMPILE_RET=$?

View File

@ -5,9 +5,9 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_
message(FATAL_ERROR "GCC vesion ${CMAKE_CXX_COMPILER_VERSION} must not be less than 7.3.0")
endif ()
set(MS_VERSION_MAJOR 0)
set(MS_VERSION_MINOR 7)
set(MS_VERSION_REVISION 0)
option(MS_VERSION_MAJOR "major version" 0)
option(MS_VERSION_MINOR "minor version" 7)
option(MS_VERSION_REVISION "revision version" 0)
set(DIR_PREFIX mindspore-lite)
set(MS_VERSION ${MS_VERSION_MAJOR}.${MS_VERSION_MINOR}.${MS_VERSION_REVISION})

View File

@ -21,18 +21,13 @@
namespace mindspore {
namespace lite {
#define MS_VERSION_MAJOR 0
#define MS_VERSION_MINOR 7
#define MS_VERSION_REVISION 0
/// \brief Global method to get a version string.
///
/// \return The version string of MindSpore Lite.
#ifndef MS_VERSION_MAJOR
#define MS_VERSION_MAJOR 0
#endif
#ifndef MS_VERSION_MINOR
#define MS_VERSION_MINOR 7
#endif
#ifndef MS_VERSION_REVISION
#define MS_VERSION_REVISION 0
#endif
std::string Version() {
return "MindSpore Lite " + std::to_string(MS_VERSION_MAJOR) + "." + std::to_string(MS_VERSION_MINOR) + "." +
std::to_string(MS_VERSION_REVISION);

View File

@ -3,82 +3,106 @@
set -e
BASE_PATH=$(cd "$(dirname $0)"; pwd)
TOP_PATH="${BASE_PATH}/../../.."
# build mindspore-lite arm64
cd ${TOP_PATH}
bash build.sh -I arm64
COMPILE_ARM64_RET=$?
if [[ "${COMPILE_ARM64_RET}" -ne 0 ]]; then
echo "---------------- mindspore lite: build failed ----------------"
exit
fi
# copy arm64 so
cd ${TOP_PATH}/output/
rm -rf mindspore-lite-0.7.0
tar -zxvf mindspore-lite-0.7.0-runtime-arm64-cpu.tar.gz
mkdir -p ${BASE_PATH}/lib/
cp ${TOP_PATH}/output/mindspore-lite-0.7.0-runtime-arm64-cpu/lib/libmindspore-lite.so ${BASE_PATH}/lib/
cp ${TOP_PATH}/output/mindspore-lite-0.7.0-runtime-arm64-cpu/lib/liboptimize.so ${BASE_PATH}/lib/
cp ${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so ${BASE_PATH}/lib/
get_version() {
VERSION_MAJOR=`grep "#define MS_VERSION_MAJOR" ../../include/version.h | tr -dc "[0-9]"`
VERSION_MINOR=`grep "#define MS_VERSION_MINOR" ../../include/version.h | tr -dc "[0-9]"`
VERSION_REVISION=`grep "#define MS_VERSION_REVISION" ../../include/version.h | tr -dc "[0-9]"`
VERSION_STR=${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION}
}
# build jni so
cd ${BASE_PATH}/native
rm -rf build
mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" -DANDROID_NATIVE_API_LEVEL="19" \
-DANDROID_NDK="${ANDROID_NDK}" -DANDROID_ABI="arm64-v8a" -DANDROID_TOOLCHAIN_NAME="aarch64-linux-android-clang" \
-DANDROID_STL="c++_shared" -DCMAKE_BUILD_TYPE=Debug ..
VERBOSE=2 make -j8
cp ${BASE_PATH}/native/build/libmindspore-lite-jni.so ${BASE_PATH}/lib/
mkdir -p ${BASE_PATH}/java/app/libs/arm64-v8a/
rm -rf ${BASE_PATH}/java/app/libs/arm64-v8a/*
cp ${BASE_PATH}/lib/*.so ${BASE_PATH}/java/app/libs/arm64-v8a/
rm -rf "${BASE_PATH:?}/lib/*"
build_mslite_arm64() {
# build mindspore-lite arm64
cd ${TOP_PATH}
bash build.sh -I arm64
COMPILE_RET=$?
# build mindspore-lite arm32
cd ${TOP_PATH}
bash build.sh -I arm32
COMPILE_ARM32_RET=$?
if [[ "${COMPILE_RET}" -ne 0 ]]; then
echo "---------------- mindspore lite arm64: build failed ----------------"
exit
fi
# copy arm64 so
cd ${TOP_PATH}/output/
rm -rf mindspore-lite-${VERSION_STR}-runtime-arm64-cpu
tar -zxvf mindspore-lite-${VERSION_STR}-runtime-arm64-cpu.tar.gz
mkdir -p ${BASE_PATH}/java/app/libs/arm64-v8a/
rm -rf ${BASE_PATH}/java/app/libs/arm64-v8a/*
cp ${TOP_PATH}/output/mindspore-lite-${VERSION_STR}-runtime-arm64-cpu/lib/libmindspore-lite.so ${BASE_PATH}/java/app/libs/arm64-v8a/
cp ${TOP_PATH}/output/mindspore-lite-${VERSION_STR}-runtime-arm64-cpu/lib/liboptimize.so ${BASE_PATH}/java/app/libs/arm64-v8a/
cp ${ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++_shared.so ${BASE_PATH}/java/app/libs/arm64-v8a/
}
if [[ "${COMPILE_ARM32_RET}" -ne 0 ]]; then
echo "---------------- mindspore lite: build failed ----------------"
exit
fi
build_mslite_arm32() {
# build mindspore-lite arm64
cd ${TOP_PATH}
bash build.sh -I arm32
COMPILE_RET=$?
# copy arm32 so
cd ${TOP_PATH}/output/
rm -rf mindspore-lite-0.7.0
tar -zxvf mindspore-lite-0.7.0-runtime-arm32-cpu.tar.gz
mkdir -p ${BASE_PATH}/lib/
cp ${TOP_PATH}/output/mindspore-lite-0.7.0-runtime-arm32-cpu/lib/libmindspore-lite.so ${BASE_PATH}/lib/
cp ${ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_shared.so ${BASE_PATH}/lib/
if [[ "${COMPILE_RET}" -ne 0 ]]; then
echo "---------------- mindspore lite arm32: build failed ----------------"
exit
fi
# copy arm32 so
cd ${TOP_PATH}/output/
rm -rf mindspore-lite-${VERSION_STR}runtime-arm32-cpu
tar -zxvf mindspore-lite-${VERSION_STR}-runtime-arm32-cpu.tar.gz
mkdir -p ${BASE_PATH}/java/app/libs/armeabi-v7a/
rm -rf ${BASE_PATH}/java/app/libs/armeabi-v7a/*
cp ${TOP_PATH}/output/mindspore-lite-${VERSION_STR}-runtime-arm32-cpu/lib/libmindspore-lite.so ${BASE_PATH}/java/app/libs/armeabi-v7a/
cp ${ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_shared.so ${BASE_PATH}/java/app/libs/armeabi-v7a/
}
# build jni so
cd ${BASE_PATH}/native
rm -rf build
mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" -DANDROID_NATIVE_API_LEVEL="19" \
-DANDROID_NDK="${ANDROID_NDK}" -DANDROID_ABI="armeabi-v7a" -DANDROID_TOOLCHAIN_NAME="aarch64-linux-android-clang" \
-DANDROID_STL="c++_shared" -DCMAKE_BUILD_TYPE=Debug ..
VERBOSE=2 make -j8
cp ${BASE_PATH}/native/build/libmindspore-lite-jni.so ${BASE_PATH}/lib/
mkdir -p ${BASE_PATH}/java/app/libs/armeabi-v7a/
rm -rf ${BASE_PATH}/java/app/libs/armeabi-v7a/*
cp ${BASE_PATH}/lib/*.so ${BASE_PATH}/java/app/libs/armeabi-v7a/
build_jni_arm64() {
# build jni so
cd ${BASE_PATH}/java/app/src/main/native
rm -rf build
mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" -DANDROID_NATIVE_API_LEVEL="19" \
-DANDROID_NDK="${ANDROID_NDK}" -DANDROID_ABI="arm64-v8a" -DANDROID_TOOLCHAIN_NAME="aarch64-linux-android-clang" \
-DANDROID_STL="c++_shared" -DCMAKE_BUILD_TYPE=Debug ..
VERBOSE=2 make -j8
mkdir -p ${BASE_PATH}/java/app/libs/arm64-v8a/
cp ${BASE_PATH}/java/app/src/main/native/build/libmindspore-lite-jni.so ${BASE_PATH}/java/app/libs/arm64-v8a/
}
# build aar
## check sdk gradle
cd ${BASE_PATH}/java
rm -rf .gradle build gradle gradlew gradlew.bat build app/build
build_jni_arm32() {
# build jni so
cd ${BASE_PATH}/java/app/src/main/native
rm -rf build
mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" -DANDROID_NATIVE_API_LEVEL="19" \
-DANDROID_NDK="${ANDROID_NDK}" -DANDROID_ABI="armeabi-v7a" -DANDROID_TOOLCHAIN_NAME="aarch64-linux-android-clang" \
-DANDROID_STL="c++_shared" -DCMAKE_BUILD_TYPE=Debug ..
VERBOSE=2 make -j8
mkdir -p ${BASE_PATH}/java/app/libs/armeabi-v7a/
cp ${BASE_PATH}/java/app/src/main/native/build/libmindspore-lite-jni.so ${BASE_PATH}/java/app/libs/armeabi-v7a/
}
gradle init
gradle wrapper
./gradlew build
build_aar() {
# build aar
## check sdk gradle
cd ${BASE_PATH}/java
rm -rf .gradle build gradle gradlew gradlew.bat build app/build
# copy output
cd ${BASE_PATH}/
rm -rf output
mkdir -pv output
cp ${BASE_PATH}/java/app/build/outputs/aar/mindspore-lite.aar ${BASE_PATH}/output/
gradle init
gradle wrapper
./gradlew build
}
copy_output() {
# copy output
cd ${BASE_PATH}/
rm -rf output
mkdir -pv output
cp ${BASE_PATH}/java/app/build/outputs/aar/mindspore-lite.aar ${BASE_PATH}/output/
}
get_version
build_mslite_arm64
build_mslite_arm32
build_jni_arm64
build_jni_arm32
build_aar
copy_output

View File

@ -8,10 +8,10 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DMS_VERSION_MAJOR=${MS_VERSION_MAJOR} -DMS_
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}")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../lite/)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../core/)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../../third_party/flatbuffers/include)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/../lib)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../) ## lite include
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../core/) ## core include
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../../third_party/flatbuffers/include) ## third_party
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/${ANDROID_ABI}/)
add_library(mindspore-lite-jni SHARED
${CMAKE_CURRENT_SOURCE_DIR}/common/jni_utils.cpp