ios simulator

This commit is contained in:
yefeng 2021-10-08 09:31:39 +08:00
parent 2df9728539
commit a541e9382e
7 changed files with 23 additions and 28 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

@ -49,14 +49,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

@ -186,12 +186,23 @@ build_lite() {
-DENABLE_ASAN=${ENABLE_ASAN} -DENABLE_VERBOSE=${ENABLE_VERBOSE} "${BASEPATH}/mindspore/lite"
fi
else
if [ "$(uname)" == "Darwin" ]; then
pkg_name=mindspore-lite-${VERSION_STR}-ios-simulator
cmake -DCMAKE_TOOLCHAIN_FILE=${BASEPATH}/cmake/lite_ios.cmake -DPLATFORM=SIMULATOR64 -DMSLITE_ENABLE_MINDRT="on" \
-DCMAKE_BUILD_TYPE="Release" -DPLATFORM_ARM64="off" -DENABLE_NEON="off" -DMSLITE_ENABLE_TOOLS="off" -DMSLITE_ENABLE_CONVERTER=off \
-DMSLITE_ENABLE_TRAIN="off" -DMSLITE_GPU_BACKEND="off" -DMSLITE_ENABLE_NPU="off" -DBUILD_MINDDATA="" -DMSLITE_ENABLE_V0=on \
-DENABLE_ASAN=${ENABLE_ASAN} -DCMAKE_INSTALL_PREFIX=${BASEPATH}/output/tmp -DENABLE_VERBOSE=${ENABLE_VERBOSE} "${BASEPATH}/mindspore/lite" \
-G Xcode ..
else
cmake -DPLATFORM_X86_64=on -DCMAKE_BUILD_TYPE=${LITE_BUILD_TYPE} -DBUILD_MINDDATA=${COMPILE_MINDDATA_LITE} \
-DMS_VERSION_MAJOR=${VERSION_MAJOR} -DMS_VERSION_MINOR=${VERSION_MINOR} -DMS_VERSION_REVISION=${VERSION_REVISION} \
-DENABLE_ASAN=${ENABLE_ASAN} -DCMAKE_INSTALL_PREFIX=${BASEPATH}/output/tmp -DENABLE_VERBOSE=${ENABLE_VERBOSE} "${BASEPATH}/mindspore/lite"
fi
fi
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
@ -210,7 +221,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_DELEGATE_USE)
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 \
@ -236,7 +236,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)