From ed26ff636a511234146f2f65b76d146a20b24f4a Mon Sep 17 00:00:00 2001 From: hangangqiang Date: Sat, 12 Dec 2020 10:33:30 +0800 Subject: [PATCH] remove gtest flatbuffer protobuf eigen jpeg-turbo from third-party --- .gitmodules | 21 --------------- build.sh | 41 ------------------------------ cmake/external_libs/gtest.cmake | 31 +++++++++++++++++++--- mindspore/lite/CMakeLists.txt | 6 +++-- mindspore/lite/test/CMakeLists.txt | 27 ++------------------ third_party/googletest | 1 - 6 files changed, 34 insertions(+), 93 deletions(-) delete mode 160000 third_party/googletest diff --git a/.gitmodules b/.gitmodules index 36cc5905b6a..753f48c2c20 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,14 +1,3 @@ -[submodule "third_party/flatbuffers"] - path = third_party/flatbuffers - url = https://github.com/google/flatbuffers.git - ignore = all -[submodule "third_party/googletest"] - path = third_party/googletest - url = https://github.com/google/googletest.git -[submodule "third_party/protobuf"] - path = third_party/protobuf - url = https://github.com/protocolbuffers/protobuf.git - ignore = all [submodule "akg"] path = akg url = https://gitee.com/mindspore/akg.git @@ -21,13 +10,3 @@ [submodule "third_party/OpenCL-Headers"] path = third_party/OpenCL-Headers url = https://github.com/KhronosGroup/OpenCL-Headers.git -[submodule "third_party/opencv"] - path = third_party/opencv - url = https://github.com/opencv/opencv.git -[submodule "third_party/eigen"] - path = third_party/eigen - url = https://gitlab.com/libeigen/eigen.git -[submodule "third_party/libjpeg-turbo"] - path = third_party/libjpeg-turbo - url = https://github.com/libjpeg-turbo/libjpeg-turbo.git - ignore = dirty diff --git a/build.sh b/build.sh index 61e365c970d..2ea42120e5e 100755 --- a/build.sh +++ b/build.sh @@ -509,44 +509,6 @@ checkddk() { fi } -gene_flatbuffer() { - FLAT_DIR="${BASEPATH}/mindspore/lite/schema" - cd ${FLAT_DIR} && rm -rf "${FLAT_DIR}/inner" && mkdir -p "${FLAT_DIR}/inner" - find . -name "*.fbs" -print0 | xargs -0 "${FLATC}" -c -b - find . -name "*.fbs" -print0 | xargs -0 "${FLATC}" -c -b --reflect-types --gen-mutable --reflect-names --gen-object-api -o "${FLAT_DIR}/inner" - - FLAT_DIR="${BASEPATH}/mindspore/lite/tools/converter/parser/tflite" - cd ${FLAT_DIR} - find . -name "*.fbs" -print0 | xargs -0 "${FLATC}" -c -b --reflect-types --gen-mutable --reflect-names --gen-object-api -o "${FLAT_DIR}/" -} - -build_flatbuffer() { - cd ${BASEPATH} - FLATC="${BASEPATH}"/third_party/flatbuffers/build/flatc - if [[ ! -f "${FLATC}" ]]; then - if [[ "${MSLIBS_SERVER}" ]]; then - cd "${BASEPATH}"/third_party/ - rm -rf ./v1.11.0.tar.gz ./flatbuffers - wget http://${MSLIBS_SERVER}:8081/libs/flatbuffers/v1.11.0.tar.gz - tar -zxvf ./v1.11.0.tar.gz - mv ./flatbuffers-1.11.0 ./flatbuffers - else - git submodule update --init --recursive third_party/flatbuffers - fi - cd ${BASEPATH}/third_party/flatbuffers - rm -rf build && mkdir -pv build && cd build && cmake -DFLATBUFFERS_BUILD_SHAREDLIB=ON .. && make -j$THREAD_NUM - gene_flatbuffer - fi - if [[ "${INC_BUILD}" == "off" ]]; then - gene_flatbuffer - fi -} - -build_gtest() { - cd ${BASEPATH} - git submodule update --init --recursive third_party/googletest -} - gene_clhpp() { CL_SRC_DIR="${BASEPATH}/mindspore/lite/src/runtime/kernel/opencl/cl" if [ ! -d "${CL_SRC_DIR}" ]; then @@ -626,9 +588,6 @@ build_lite() if [ "${ENABLE_NPU}" == "on" ]; then checkddk fi - if [ "${RUN_TESTCASES}" == "on" ]; then - build_gtest - fi cd "${BASEPATH}/mindspore/lite" if [[ "${INC_BUILD}" == "off" || $2 == "off" ]]; then diff --git a/cmake/external_libs/gtest.cmake b/cmake/external_libs/gtest.cmake index 89861e6e5b1..774add1c594 100644 --- a/cmake/external_libs/gtest.cmake +++ b/cmake/external_libs/gtest.cmake @@ -1,6 +1,32 @@ -set(gtest_CXXFLAGS "-D_FORTIFY_SOURCE=2 -D_GLIBCXX_USE_CXX11_ABI=0 -O2") +set(gtest_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2") set(gtest_CFLAGS "-D_FORTIFY_SOURCE=2 -O2") +set(CMAKE_OPTION + -DBUILD_TESTING=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=ON + -DCMAKE_MACOSX_RPATH=TRUE -Dgtest_disable_pthreads=ON) +if (BUILD_LITE) + if (PLATFORM_ARM64) + set(CMAKE_OPTION -DCMAKE_TOOLCHAIN_FILE=$ENV{ANDROID_NDK}/build/cmake/android.toolchain.cmake + -DANDROID_NATIVE_API_LEVEL=19 + -DANDROID_NDK=$ENV{ANDROID_NDK} + -DANDROID_ABI=arm64-v8a + -DANDROID_TOOLCHAIN_NAME=aarch64-linux-android-clang + -DANDROID_STL=c++_shared -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + ${CMAKE_OPTION}) + endif() + if (PLATFORM_ARM32) + set(CMAKE_OPTION -DCMAKE_TOOLCHAIN_FILE=$ENV{ANDROID_NDK}/build/cmake/android.toolchain.cmake + -DANDROID_NATIVE_API_LEVEL=19 + -DANDROID_NDK=$ENV{ANDROID_NDK} + -DANDROID_ABI=armeabi-v7a + -DANDROID_TOOLCHAIN_NAME=aarch64-linux-android-clang + -DANDROID_STL=c++_shared -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + ${CMAKE_OPTION}) + endif() +else() + set(gtest_CXXFLAGS "${gtest_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0") +endif () + if (ENABLE_GITEE) set(REQ_URL "https://gitee.com/mirrors/googletest/repository/archive/release-1.8.0.tar.gz") set(MD5 "89e13ca1aa48d370719d58010b83f62c") @@ -14,8 +40,7 @@ mindspore_add_pkg(gtest LIBS gtest URL ${REQ_URL} MD5 ${MD5} - CMAKE_OPTION -DBUILD_TESTING=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=ON - -DCMAKE_MACOSX_RPATH=TRUE -Dgtest_disable_pthreads=ON) + CMAKE_OPTION ${CMAKE_OPTION}) include_directories(${gtest_INC}) add_library(mindspore::gtest ALIAS gtest::gtest) file(COPY ${gtest_LIBPATH}/libgtest${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${CMAKE_BINARY_DIR}/googletest/googlemock/gtest) diff --git a/mindspore/lite/CMakeLists.txt b/mindspore/lite/CMakeLists.txt index e9f73bc60ff..fafd5c7bbe9 100644 --- a/mindspore/lite/CMakeLists.txt +++ b/mindspore/lite/CMakeLists.txt @@ -114,10 +114,12 @@ include(${TOP_DIR}/cmake/utils.cmake) include(${TOP_DIR}/cmake/dependency_utils.cmake) include(${TOP_DIR}/cmake/dependency_securec.cmake) include(${TOP_DIR}/cmake/external_libs/flatbuffers.cmake) -include(${TOP_DIR}/cmake/external_libs/opencl.cmake) +if (SUPPORT_GPU) + include(${TOP_DIR}/cmake/external_libs/opencl.cmake) +endif() if (ENABLE_CONVERTER OR BUILD_MINDDATA STREQUAL "full") -include(${TOP_DIR}/cmake/external_libs/json.cmake) + include(${TOP_DIR}/cmake/external_libs/json.cmake) endif() file(GLOB FBS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/schema/*.fbs) diff --git a/mindspore/lite/test/CMakeLists.txt b/mindspore/lite/test/CMakeLists.txt index e961df4ecbb..9b9f2a20e76 100644 --- a/mindspore/lite/test/CMakeLists.txt +++ b/mindspore/lite/test/CMakeLists.txt @@ -4,7 +4,7 @@ set(LITE_DIR ${TOP_DIR}/mindspore/lite) set(CCSRC_DIR ${TOP_DIR}/mindspore/ccsrc) include_directories(${TOP_DIR}) include_directories(${TEST_DIR}) -include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/dependency_gtest.cmake) +include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/external_libs/gtest.cmake) STRING(REPLACE " -fvisibility=hidden " " -fvisibility=default " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") STRING(REPLACE " -fvisibility=hidden " " -fvisibility=default " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") @@ -104,22 +104,6 @@ if (PLATFORM_ARM32 OR PLATFORM_ARM64) set(BUILD_MINDDATA "off") endif() endif() -### minddata lite -if (BUILD_MINDDATA STREQUAL "lite") -# include_directories(${CCSRC_DIR}/minddata) -# set(DATASET_TEST_DIR ${TEST_DIR}/ut/src/dataset) -# set(TEST_MINDDATA_SRC -# ${DATASET_TEST_DIR}/de_tensor_test.cc -# ${DATASET_TEST_DIR}/eager_test.cc -# ) -elseif (BUILD_MINDDATA STREQUAL "full") - #include_directories(${CCSRC_DIR}/minddata) - #set(DATASET_TEST_DIR ${TEST_DIR}/ut/src/dataset) - #set(TEST_MINDDATA_SRC - # ${DATASET_TEST_DIR}/de_tensor_test.cc - # ${DATASET_TEST_DIR}/eager_test.cc - # ) -endif() ### runtime framework file(GLOB_RECURSE OPS_SRC ${LITE_DIR}/src/ops/*.cc ${LITE_DIR}/src/ops/populate/*.cc) set(TEST_LITE_SRC @@ -300,10 +284,9 @@ if (ENABLE_FP16) ${TEST_DIR}/ut/src/runtime/kernel/arm/fp16/convolution_fp16_tests.cc) endif () - add_executable(lite-test ${TEST_SRC}) add_dependencies(lite-test fbs_src) -target_link_libraries(lite-test dl ${GTEST_LIBRARY}) +target_link_libraries(lite-test dl mindspore::gtest) if (PLATFORM_ARM64) target_link_libraries(lite-test nnacl_fp16_mid nnacl_optimize_mid) endif() @@ -312,12 +295,6 @@ if (PLATFORM_ARM) target_link_libraries(lite-test log) endif() -#if (BUILD_MINDDATA STREQUAL "lite") -# target_link_libraries(lite-test - # minddata_eager_mid - #minddata-lite - # ) - #endif() if (SUPPORT_NPU) include_directories(${DDK_PATH}) target_link_libraries(lite-test npu_kernel_mid) diff --git a/third_party/googletest b/third_party/googletest deleted file mode 160000 index 2fe3bd994b3..00000000000 --- a/third_party/googletest +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2fe3bd994b3189899d93f1d5a881e725e046fdc2