ios simulator

This commit is contained in:
yefeng 2021-10-07 15:24:37 +08:00
parent c8ffcaa1dd
commit 8ce5dd4867
7 changed files with 26 additions and 31 deletions

View File

@ -20,14 +20,12 @@ else()
endif()
if(APPLE)
set(FLATBUFFERS_PATCH ${TOP_DIR}/third_party/patch/flatbuffers/flatbuffers.patch001)
mindspore_add_pkg(flatbuffers
VER 2.0.0
LIBS flatbuffers
EXE flatc
URL ${REQ_URL}
MD5 ${MD5}
PATCHES ${FLATBUFFERS_PATCH}
CMAKE_OPTION -DFLATBUFFERS_BUILD_TESTS=OFF -DCMAKE_INSTALL_LIBDIR=lib)
else()
mindspore_add_pkg(flatbuffers

View File

@ -133,7 +133,13 @@ function(__find_pkg_then_add_target pkg_name pkg_exe lib_path)
set(_LIB_TYPE STATIC)
endif()
set(${_LIB_NAME}_LIB ${_LIB_NAME}_LIB-NOTFOUND)
find_library(${_LIB_NAME}_LIB ${_LIB_SEARCH_NAME} PATHS ${${pkg_name}_BASE_DIR}/${lib_path} NO_DEFAULT_PATH)
if(APPLE)
find_library(${_LIB_NAME}_LIB ${_LIB_SEARCH_NAME} PATHS ${${pkg_name}_BASE_DIR}/${lib_path}
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
else()
find_library(${_LIB_NAME}_LIB ${_LIB_SEARCH_NAME} PATHS ${${pkg_name}_BASE_DIR}/${lib_path}
NO_DEFAULT_PATH)
endif()
if(NOT ${_LIB_NAME}_LIB)
return()
endif()

View File

@ -3,7 +3,7 @@ project(nnacl)
set(NNACL_DIR ${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${NNACL_DIR}/..)
if(PLATFORM_ARM32 OR PLATFORM_ARM64)
if(APPLE OR PLATFORM_ARM32 OR PLATFORM_ARM64)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release" AND DEFINED ARCHS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstrict-aliasing \
-ffunction-sections -fdata-sections -ffast-math -Wno-shorten-64-to-32")

View File

@ -36,14 +36,6 @@ option(ENABLE_VERBOSE "" off)
option(ENABLE_MODEL_OBF "if support model obfuscation" off)
set(BUILD_MINDDATA "lite_cv" CACHE STRING "off, lite, lite_cv, wrapper or full")
if(APPLE)
find_package(Patch)
if(NOT Patch_FOUND)
message(FATAL_ERROR "Patch not found, "
"please set environment variable MS_PATCH_PATH to path where Patch is located,"
"usually found in GIT_PATH/usr/bin on Windows")
endif()
endif()
if(DEFINED ENV{MSLITE_GPU_BACKEND})
set(MSLITE_GPU_BACKEND $ENV{MSLITE_GPU_BACKEND})
endif()

View File

@ -133,7 +133,7 @@ build_lite() {
LITE_CMAKE_ARGS="${LITE_CMAKE_ARGS} -DENABLE_ASAN=${ENABLE_ASAN} -DCMAKE_INSTALL_PREFIX=${BUILD_PATH}/output/tmp"
if [ "$(uname)" == "Darwin" ]; then
if [[ "$(uname)" == "Darwin" && "${local_lite_platform}" != "x86_64" ]]; then
LITE_CMAKE_ARGS=`echo $LITE_CMAKE_ARGS | sed 's/-DCMAKE_BUILD_TYPE=Debug/-DCMAKE_BUILD_TYPE=Release/g'`
LITE_CMAKE_ARGS="${LITE_CMAKE_ARGS} -DMSLITE_ENABLE_TRAIN=off -DMSLITE_GPU_BACKEND=off -DMSLITE_ENABLE_NPU=off"
LITE_CMAKE_ARGS="${LITE_CMAKE_ARGS} -DBUILD_MINDDATA=off"
@ -183,8 +183,17 @@ build_lite() {
LITE_CMAKE_ARGS="${LITE_CMAKE_ARGS} -DANDROID_NATIVE_API_LEVEL=19 -DANDROID_NDK=${ANDROID_NDK} -DANDROID_ABI=arm64-v8a -DANDROID_TOOLCHAIN_NAME=aarch64-linux-android-clang -DANDROID_STL=${MSLITE_ANDROID_STL}"
fi
else
LITE_CMAKE_ARGS="${LITE_CMAKE_ARGS} -DBUILD_MINDDATA=lite_cv"
LITE_CMAKE_ARGS="${LITE_CMAKE_ARGS} -DPLATFORM_X86_64=on"
if [ "$(uname)" == "Darwin" ]; then
pkg_name=mindspore-lite-${VERSION_STR}-ios-simulator
CMAKE_TOOLCHAIN_FILE=${BASEPATH}/cmake/lite_ios.cmake
LITE_CMAKE_ARGS=`echo $LITE_CMAKE_ARGS | sed 's/-DCMAKE_BUILD_TYPE=Debug/-DCMAKE_BUILD_TYPE=Release/g'`
LITE_CMAKE_ARGS="${LITE_CMAKE_ARGS} -DPLATFORM=SIMULATOR64 -DPLATFORM_ARM64=off -DENABLE_NEON=off -DMSLITE_ENABLE_TRAIN=off -DMSLITE_GPU_BACKEND=off -DMSLITE_ENABLE_NPU=off -DBUILD_MINDDATA=off -DMSLITE_ENABLE_V0=on"
LITE_CMAKE_ARGS="${LITE_CMAKE_ARGS} -DMSLITE_ENABLE_TOOLS=off -DMSLITE_ENABLE_CONVERTER=off"
LITE_CMAKE_ARGS="${LITE_CMAKE_ARGS} -G Xcode .."
else
LITE_CMAKE_ARGS="${LITE_CMAKE_ARGS} -DBUILD_MINDDATA=lite_cv"
LITE_CMAKE_ARGS="${LITE_CMAKE_ARGS} -DPLATFORM_X86_64=on"
fi
fi
if [[ "X$CMAKE_TOOLCHAIN_FILE" != "X" ]]; then
@ -197,8 +206,10 @@ build_lite() {
echo "cmake ${LITE_CMAKE_ARGS} ${BASEPATH}/mindspore/lite"
cmake ${LITE_CMAKE_ARGS} "${BASEPATH}/mindspore/lite"
if [ "$(uname)" == "Darwin" ]; then
if [[ "$(uname)" == "Darwin" && "${local_lite_platform}" != "x86_64" ]]; then
xcodebuild ONLY_ACTIVE_ARCH=NO -configuration Release -scheme mindspore-lite_static -target mindspore-lite_static -sdk iphoneos -quiet
elif [[ "$(uname)" == "Darwin" && "${local_lite_platform}" == "x86_64" ]]; then
xcodebuild ONLY_ACTIVE_ARCH=NO -configuration Release -scheme mindspore-lite_static -target mindspore-lite_static -sdk iphonesimulator -quiet
else
make -j$THREAD_NUM && make install && make package
if [[ "${local_lite_platform}" == "x86_64" ]]; then
@ -217,7 +228,7 @@ build_lite() {
else
if [ "$(uname)" == "Darwin" ]; then
mkdir -p ${BASEPATH}/output
cp -r ${BASEPATH}/mindspore/lite/build/src/Release-iphoneos/mindspore-lite.framework ${BASEPATH}/output/mindspore-lite.framework
cp -r ${BASEPATH}/mindspore/lite/build/src/Release-*/mindspore-lite.framework ${BASEPATH}/output/mindspore-lite.framework
cd ${BASEPATH}/output
tar -zcvf ${pkg_name}.tar.gz mindspore-lite.framework/
sha256sum ${pkg_name}.tar.gz > ${pkg_name}.tar.gz.sha256

View File

@ -26,7 +26,7 @@ if(NOT MSLITE_ENABLE_DELEGATE)
add_compile_definitions(DELEGATE_CLIP)
endif()
if(PLATFORM_ARM32 OR PLATFORM_ARM64)
if(APPLE OR PLATFORM_ARM32 OR PLATFORM_ARM64)
#for performance
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release" AND NOT APPLE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fomit-frame-pointer -fstrict-aliasing -ffunction-sections \
@ -237,7 +237,7 @@ endif()
add_library(mindspore-lite SHARED $<TARGET_OBJECTS:lite_src_mid>)
set_target_properties(mindspore-lite PROPERTIES CLEAN_DIRECT_OUTPUT 1)
if(DEFINED ARCHS)
if(APPLE)
set(MINDSPORE_LITE_PUB_HDRS
${CMAKE_CURRENT_SOURCE_DIR}/../include/context.h
${CMAKE_CURRENT_SOURCE_DIR}/../include/errorcode.h

View File

@ -1,12 +0,0 @@
diff -Npur flatbuffers-src/CMakeLists.txt flatbuffers-src_patch/CMakeLists.txt
--- flatbuffers-src/CMakeLists.txt 2019-04-25 02:34:53.000000000 +0800
+++ flatbuffers-src_patch/CMakeLists.txt 2021-06-28 11:37:12.922988687 +0800
@@ -161,7 +161,7 @@
message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.")
elseif(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra -Wno-unused-parameter")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra -Wno-unused-parameter -Wno-deprecated")
set(FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wold-style-cast")
elseif(CMAKE_COMPILER_IS_GNUCXX)
if(CYGWIN)