From 0a19758380883d3517ba2723ff4a3c4d19f77adf Mon Sep 17 00:00:00 2001 From: Xiaoyang LI Date: Fri, 30 Aug 2019 11:02:00 +0800 Subject: [PATCH] support ios tiny publish (#1910) (#1919) --- lite/CMakeLists.txt | 11 ++++++ lite/tools/build.sh | 52 ++++++++++++++++++++++++++--- lite/tools/build_ios_armv7_arm64.sh | 30 ----------------- 3 files changed, 58 insertions(+), 35 deletions(-) delete mode 100755 lite/tools/build_ios_armv7_arm64.sh diff --git a/lite/CMakeLists.txt b/lite/CMakeLists.txt index 39985d5b9c..7606507fba 100644 --- a/lite/CMakeLists.txt +++ b/lite/CMakeLists.txt @@ -89,6 +89,17 @@ if (LITE_WITH_LIGHT_WEIGHT_FRAMEWORK AND LITE_WITH_ARM) add_custom_command(TARGET publish_inference_cxx_lib POST_BUILD COMMAND ${CMAKE_STRIP} "--strip-debug" ${INFER_LITE_PUBLISH_ROOT}/cxx/lib/*.a) endif() + else() + if (IOS) + add_custom_target(tiny_publish_lib ${TARGET} + COMMAND mkdir -p "${INFER_LITE_PUBLISH_ROOT}/lib" + COMMAND mkdir -p "${INFER_LITE_PUBLISH_ROOT}/include" + COMMAND cp "${CMAKE_SOURCE_DIR}/lite/api/paddle_*.h" "${INFER_LITE_PUBLISH_ROOT}/include" + COMMAND cp "${CMAKE_BINARY_DIR}/libpaddle_api_light_bundled.a" "${INFER_LITE_PUBLISH_ROOT}/lib" + ) + add_dependencies(tiny_publish_lib bundle_light_api) + add_dependencies(publish_inference tiny_publish_lib) + endif() endif() diff --git a/lite/tools/build.sh b/lite/tools/build.sh index 6ec275c774..0edeeeede3 100755 --- a/lite/tools/build.sh +++ b/lite/tools/build.sh @@ -135,6 +135,41 @@ function make_all_tests { cd - > /dev/null } +function make_ios { + local os=$1 + local abi=$2 + build_dir=build.ios.${os}.${abi} + echo "building ios target into $build_dir" + echo "target os: $os" + echo "target abi: $abi" + mkdir -p ${build_dir} + cd ${build_dir} + GEN_CODE_PATH_PREFIX=lite/gen_code + mkdir -p ./${GEN_CODE_PATH_PREFIX} + touch ./${GEN_CODE_PATH_PREFIX}/__generated_code__.cc + + cmake .. \ + -DWITH_GPU=OFF \ + -DWITH_MKL=OFF \ + -DWITH_LITE=ON \ + -DLITE_WITH_CUDA=OFF \ + -DLITE_WITH_X86=OFF \ + -DLITE_WITH_ARM=ON \ + -DWITH_TESTING=OFF \ + -DLITE_WITH_JAVA=OFF \ + -DLITE_SHUTDOWN_LOG=ON \ + -DLITE_ON_TINY_PUBLISH=ON \ + -DLITE_WITH_OPENMP=OFF \ + -DWITH_ARM_DOTPROD=OFF \ + -DLITE_WITH_LIGHT_WEIGHT_FRAMEWORK=ON \ + -DARM_TARGET_ARCH_ABI=$abi \ + -DLITE_BUILD_EXTRA=$BUILD_EXTRA \ + -DARM_TARGET_OS=$os + + make -j4 publish_inference + cd - +} + function print_usage { set +x @@ -142,22 +177,25 @@ function print_usage { echo echo "----------------------------------------" echo -e "compile tiny publish so lib:" + echo -e "for android:" echo -e " ./build.sh --arm_os= --arm_abi= --arm_lang= --android_stl= tiny_publish" + echo -e "for ios:" + echo -e " ./build.sh --arm_os= --arm_abi= ios" echo - echo -e "compile full publish so lib:" + echo -e "compile full publish so lib (ios not support):" echo -e " ./build.sh --arm_os= --arm_abi= --arm_lang= --android_stl= full_publish" echo - echo -e "compile all arm tests:" + echo -e "compile all arm tests (ios not support):" echo -e " ./build.sh --arm_os= --arm_abi= --arm_lang= test" echo echo -e "optional argument:" echo -e "--build_extra: (OFF|ON); controls whether to publish extra operators and kernels for (sequence-related model such as OCR or NLP)" echo echo -e "argument choices:" - echo -e "--arm_os:\t android" + echo -e "--arm_os:\t android|ios|ios64" echo -e "--arm_abi:\t armv8|armv7" - echo -e "--arm_lang:\t gcc|clang" - echo -e "--android_stl:\t c++_static|c++_shared" + echo -e "--arm_lang:\t gcc|clang (for android)" + echo -e "--android_stl:\t c++_static|c++_shared (for android)" echo echo -e "tasks:" echo @@ -209,6 +247,10 @@ function main { make_all_tests $ARM_OS $ARM_ABI $ARM_LANG shift ;; + ios) + make_ios $ARM_OS $ARM_ABI + shift + ;; *) # unknown option print_usage diff --git a/lite/tools/build_ios_armv7_arm64.sh b/lite/tools/build_ios_armv7_arm64.sh deleted file mode 100755 index 718c3e37e9..0000000000 --- a/lite/tools/build_ios_armv7_arm64.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash -set -e - -build_dir=build.ios.armv7.arm64 -mkdir -p ${build_dir} -cd ${build_dir} - -GEN_CODE_PATH_PREFIX=lite/gen_code -mkdir -p ./${GEN_CODE_PATH_PREFIX} -touch ./${GEN_CODE_PATH_PREFIX}/__generated_code__.cc - -cmake .. \ - -DWITH_GPU=OFF \ - -DWITH_MKL=OFF \ - -DWITH_LITE=ON \ - -DLITE_WITH_CUDA=OFF \ - -DLITE_WITH_X86=OFF \ - -DLITE_WITH_ARM=ON \ - -DWITH_TESTING=OFF \ - -DLITE_WITH_JAVA=OFF \ - -DLITE_SHUTDOWN_LOG=ON \ - -DLITE_ON_TINY_PUBLISH=ON \ - -DLITE_WITH_OPENMP=OFF \ - -DWITH_ARM_DOTPROD=OFF \ - -DLITE_WITH_LIGHT_WEIGHT_FRAMEWORK=ON \ - -DARM_TARGET_OS=ios - -make -j4 - -cd - -- GitLab