From f47dcd2bcea07ae2b1dc2e42d141ac42c14fe006 Mon Sep 17 00:00:00 2001 From: liubuyu Date: Wed, 14 Oct 2020 19:35:13 +0800 Subject: [PATCH] easy use for speed up download third_party --- build.sh | 14 ++++++++++++-- cmake/external_libs/gtest.cmake | 13 +++++++++++-- cmake/external_libs/json.cmake | 13 +++++++++++-- cmake/external_libs/mkl_dnn.cmake | 11 +++++++++-- cmake/external_libs/onnx.cmake | 12 ++++++++++-- cmake/external_libs/protobuf.cmake | 12 ++++++++++-- cmake/utils.cmake | 2 +- 7 files changed, 64 insertions(+), 13 deletions(-) diff --git a/build.sh b/build.sh index 70b6b77fb3..8d00f2d313 100755 --- a/build.sh +++ b/build.sh @@ -26,7 +26,7 @@ usage() echo " [-a on|off] [-p on|off] [-i] [-L] [-R] [-D on|off] [-j[n]] [-e gpu|d|cpu] \\" echo " [-P on|off] [-z [on|off]] [-M on|off] [-V 9.2|10.1] [-I arm64|arm32|x86_64] [-K] \\" echo " [-B on|off] [-w on|off] [-E] [-l on|off] [-n full|lite|off] [-T on|off] \\" - echo " [-A [cpp|java|object-c] [-C on|off] [-o on|off] \\" + echo " [-A [cpp|java|object-c] [-C on|off] [-o on|off] [-S on|off] \\" echo "" echo "Options:" echo " -d Debug mode" @@ -63,6 +63,7 @@ usage() echo " -T Enable on-device training, default off" echo " -C Enable mindspore lite converter compilation, enabled when -I is specified, default on" echo " -o Enable mindspore lite tools compilation, enabled when -I is specified, default on" + echo " -S Enable enable download cmake compile dependency from gitee , default off" } # check value of input is 'on' or 'off' @@ -113,9 +114,10 @@ checkopts() ENABLE_TOOLS="on" ENABLE_CONVERTER="on" LITE_LANGUAGE="cpp" + ENABLE_GITEE="off" # Process the options - while getopts 'drvj:c:t:hsb:a:g:p:ie:m:l:I:LRP:D:zM:V:K:swB:En:T:A:C:o:' opt + while getopts 'drvj:c:t:hsb:a:g:p:ie:m:l:I:LRP:D:zM:V:K:swB:En:T:A:C:o:S:' opt do OPTARG=$(echo ${OPTARG} | tr '[A-Z]' '[a-z]') case "${opt}" in @@ -199,6 +201,11 @@ checkopts() ENABLE_TIMELINE="on" echo "enable time_line record" ;; + S) + check_on_off $OPTARG S + ENABLE_GITEE="$OPTARG" + echo "enable download from gitee" + ;; e) if [[ "X$OPTARG" == "Xgpu" ]]; then ENABLE_GPU="on" @@ -374,6 +381,9 @@ build_mindspore() if [[ "X$ENABLE_DUMP2PROTO" = "Xon" ]]; then CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_DUMP_PROTO=ON" fi + if [[ "X$ENABLE_GITEE" = "Xon" ]]; then + CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_GITEE=ON" + fi CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_DUMP_IR=${ENABLE_DUMP_IR}" CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_PYTHON=${ENABLE_PYTHON}" if [[ "X$ENABLE_MPI" = "Xon" ]]; then diff --git a/cmake/external_libs/gtest.cmake b/cmake/external_libs/gtest.cmake index eb64655a86..89861e6e5b 100644 --- a/cmake/external_libs/gtest.cmake +++ b/cmake/external_libs/gtest.cmake @@ -1,10 +1,19 @@ set(gtest_CXXFLAGS "-D_FORTIFY_SOURCE=2 -D_GLIBCXX_USE_CXX11_ABI=0 -O2") set(gtest_CFLAGS "-D_FORTIFY_SOURCE=2 -O2") + +if (ENABLE_GITEE) + set(REQ_URL "https://gitee.com/mirrors/googletest/repository/archive/release-1.8.0.tar.gz") + set(MD5 "89e13ca1aa48d370719d58010b83f62c") +else() + set(REQ_URL "https://github.com/google/googletest/archive/release-1.8.0.tar.gz") + set(MD5 "16877098823401d1bf2ed7891d7dce36") +endif () + mindspore_add_pkg(gtest VER 1.8.0 LIBS gtest - URL https://github.com/google/googletest/archive/release-1.8.0.tar.gz - MD5 16877098823401d1bf2ed7891d7dce36 + 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) include_directories(${gtest_INC}) diff --git a/cmake/external_libs/json.cmake b/cmake/external_libs/json.cmake index 1912e80d35..5c817764ba 100644 --- a/cmake/external_libs/json.cmake +++ b/cmake/external_libs/json.cmake @@ -1,9 +1,18 @@ set(nlohmann_json_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2") set(nlohmann_json_CFLAGS "-D_FORTIFY_SOURCE=2 -O2") + +if (ENABLE_GITEE) + set(REQ_URL "https://gitee.com/mirrors/JSON-for-Modern-CPP/repository/archive/v3.6.1.zip") + set(MD5 "5bda78ce308e6cfcf614dcf1d5ff27a7") +else() + set(REQ_URL "https://github.com/nlohmann/json/releases/download/v3.6.1/include.zip") + set(MD5 "0dc903888211db3a0f170304cd9f3a89") +endif () + mindspore_add_pkg(nlohmann_json VER 3.6.1 HEAD_ONLY ./ - URL https://github.com/nlohmann/json/releases/download/v3.6.1/include.zip - MD5 0dc903888211db3a0f170304cd9f3a89) + URL ${REQ_URL} + MD5 ${MD5}) include_directories(${nlohmann_json_INC}) add_library(mindspore::json ALIAS nlohmann_json) \ No newline at end of file diff --git a/cmake/external_libs/mkl_dnn.cmake b/cmake/external_libs/mkl_dnn.cmake index 2c8a17c4e7..bc3ac16feb 100644 --- a/cmake/external_libs/mkl_dnn.cmake +++ b/cmake/external_libs/mkl_dnn.cmake @@ -9,11 +9,18 @@ if (CMAKE_SYSTEM_NAME MATCHES "Windows") URL https://github.com/oneapi-src/oneDNN/releases/download/v1.5/dnnl_win_1.5.0_cpu_vcomp.zip MD5 17757c84f49edd42d34ae8c9288110a1) else() + if (ENABLE_GITEE) + set(REQ_URL "https://gitee.com/mirrors/MKL-DNN/repository/archive/v1.5.tar.gz") + set(MD5 "5e0f3800d484969d420188e9cff7348c") + else() + set(REQ_URL "https://github.com/oneapi-src/oneDNN/archive/v1.5.tar.gz") + set(MD5 "5d97e0e8f4c0b37da5f524533b7a644b") + endif () mindspore_add_pkg(onednn VER 1.5 LIBS dnnl mkldnn - URL https://github.com/oneapi-src/oneDNN/archive/v1.5.tar.gz - MD5 5d97e0e8f4c0b37da5f524533b7a644b + URL ${REQ_URL} + MD5 ${MD5} CMAKE_OPTION -DDNNL_ARCH_OPT_FLAGS='' -DDNNL_CPU_RUNTIME='SEQ' -DDNNL_BUILD_EXAMPLES=OFF -DDNNL_BUILD_TESTS=OFF) endif() diff --git a/cmake/external_libs/onnx.cmake b/cmake/external_libs/onnx.cmake index fc77100866..d7ec8d47b2 100644 --- a/cmake/external_libs/onnx.cmake +++ b/cmake/external_libs/onnx.cmake @@ -1,5 +1,13 @@ +if (ENABLE_GITEE) + set(REQ_URL "https://gitee.com/mirrors/ONNX/repository/archive/v1.6.0.tar.gz") + set(MD5 "1bdbcecdd68ea8392630467646776e02") +else() + set(REQ_URL "https://github.com/onnx/onnx/releases/download/v1.6.0/onnx-1.6.0.tar.gz") + set(MD5 "512f2779d6215d4a36f366b6b9acdf1e") +endif () + mindspore_add_pkg(ms_onnx VER 1.6.0 HEAD_ONLY ./ - URL https://github.com/onnx/onnx/releases/download/v1.6.0/onnx-1.6.0.tar.gz - MD5 512f2779d6215d4a36f366b6b9acdf1e) + URL ${REQ_URL} + MD5 ${MD5}) diff --git a/cmake/external_libs/protobuf.cmake b/cmake/external_libs/protobuf.cmake index 5f30e1ef72..045c22d7bb 100644 --- a/cmake/external_libs/protobuf.cmake +++ b/cmake/external_libs/protobuf.cmake @@ -17,12 +17,20 @@ set(CMAKE_CXX_FLAGS ${_ms_tmp_CMAKE_CXX_FLAGS}) string(REPLACE " -Wall" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") string(REPLACE " -Werror" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") +if (ENABLE_GITEE) + set(REQ_URL "https://gitee.com/mirrors/protobuf_source/repository/archive/v3.8.0.tar.gz") + set(MD5 "eba86ae9f07ba5cfbaf8af3bc4e84236") +else() + set(REQ_URL "https://github.com/protocolbuffers/protobuf/archive/v3.8.0.tar.gz") + set(MD5 "3d9e32700639618a4d2d342c99d4507a") +endif () + mindspore_add_pkg(protobuf VER 3.8.0 LIBS protobuf EXE protoc - URL https://github.com/protocolbuffers/protobuf/archive/v3.8.0.tar.gz - MD5 3d9e32700639618a4d2d342c99d4507a + URL ${REQ_URL} + MD5 ${MD5} CMAKE_PATH cmake/ CMAKE_OPTION -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF) diff --git a/cmake/utils.cmake b/cmake/utils.cmake index 7577047729..465c7b8e8a 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -31,7 +31,7 @@ if (NOT EXISTS ${_MS_LIB_CACHE}) file(MAKE_DIRECTORY ${_MS_LIB_CACHE}) endif () -if (DEFINED ENV{MSLIBS_SERVER}) +if (DEFINED ENV{MSLIBS_SERVER} AND NOT ENABLE_GITEE) set(LOCAL_LIBS_SERVER $ENV{MSLIBS_SERVER}) message("LOCAL_LIBS_SERVER: ${LOCAL_LIBS_SERVER}") endif ()