1#!/bin/bash 2# Copyright 2021 Huawei Technologies Co., Ltd 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# ============================================================================ 16 17BASEPATH=$(cd "$(dirname $0)" || exit; pwd) 18get_version() { 19 VERSION_MAJOR=$(grep "const int ms_version_major =" ${BASEPATH}/../../include/version.h | tr -dc "[0-9]") 20 VERSION_MINOR=$(grep "const int ms_version_minor =" ${BASEPATH}/../../include/version.h | tr -dc "[0-9]") 21 VERSION_REVISION=$(grep "const int ms_version_revision =" ${BASEPATH}/../../include/version.h | tr -dc "[0-9]") 22 VERSION_STR=${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION} 23} 24get_version 25MODEL_DOWNLOAD_URL="https://download.mindspore.cn/model_zoo/official/lite/quick_start/add_extend.ms" 26MODEL_DOWNLOAD_URL2="https://download.mindspore.cn/model_zoo/official/lite/quick_start/add.ms" 27MINDSPORE_FILE_NAME="mindspore-lite-${VERSION_STR}-linux-x64" 28MINDSPORE_FILE="${MINDSPORE_FILE_NAME}.tar.gz" 29MINDSPORE_LITE_DOWNLOAD_URL="https://ms-release.obs.cn-north-4.myhuaweicloud.com/${VERSION_STR}/MindSpore/lite/release/linux/${MINDSPORE_FILE}" 30 31mkdir -p build 32mkdir -p model 33if [ ! -e ${BASEPATH}/model/add_extend.ms ]; then 34 wget -c -O ${BASEPATH}/model/add_extend.ms --no-check-certificate ${MODEL_DOWNLOAD_URL} 35fi 36if [ ! -e ${BASEPATH}/model/add.ms ]; then 37 wget -c -O ${BASEPATH}/model/add.ms --no-check-certificate ${MODEL_DOWNLOAD_URL2} 38fi 39if [ ! -e ${BASEPATH}/build/${MINDSPORE_FILE} ]; then 40 wget -c -O ${BASEPATH}/build/${MINDSPORE_FILE} --no-check-certificate ${MINDSPORE_LITE_DOWNLOAD_URL} 41fi 42tar -xzf ${BASEPATH}/build/${MINDSPORE_FILE} 43cp -r ${BASEPATH}/build/${MINDSPORE_FILE_NAME}/runtime ${BASEPATH}/ 44cd ${BASEPATH}/build || exit 45cmake -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" -DANDROID_NATIVE_API_LEVEL="19" \ 46 -DANDROID_ABI="arm64-v8a" -DCMAKE_BUILD_TYPE="Release" ${BASEPATH} 47make 48