• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# Copyright 2021 Huawei Technologies Co., Ltd
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15# ============================================================================
16
17set -e
18
19# Create building path
20build_mindspore()
21{
22    echo "start build mindspore project."
23    mkdir -pv "${BUILD_PATH}/mindspore"
24    cd "${BUILD_PATH}/mindspore"
25    CMAKE_ARGS="-DDEBUG_MODE=$DEBUG_MODE -DBUILD_PATH=$BUILD_PATH"
26    if [[ "X$ENABLE_COVERAGE" = "Xon" ]]; then
27      CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_COVERAGE=ON"
28    fi
29    if [[ "X$RUN_TESTCASES" = "Xon" ]]; then
30      CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_TESTCASES=ON"
31    fi
32    if [[ "X$RUN_CPP_ST_TESTS" = "Xon" ]]; then
33      CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_CPP_ST=ON"
34    fi
35    if [[ -n "$ENABLE_BACKEND" ]]; then
36      CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_${ENABLE_BACKEND}=ON"
37    fi
38    if [[ -n "$TRAIN_MODE" ]]; then
39        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_${TRAIN_MODE}=ON"
40    fi
41    if [[ "X$ENABLE_SYM_FILE" = "Xon" ]]; then
42        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_SYM_FILE=ON"
43    fi
44    if [[ "X$ENABLE_ASAN" = "Xon" ]]; then
45        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_ASAN=ON"
46    fi
47    if [[ "X$ENABLE_PROFILE" = "Xon" ]]; then
48        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_PROFILE=ON"
49    fi
50    if [[ "X$ENABLE_SECURITY" = "Xon" ]]; then
51        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_SECURITY=ON"
52    fi
53    if [[ "X$ENABLE_TIMELINE" = "Xon" ]]; then
54        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_TIMELINE=ON"
55    fi
56    if [[ "X$ENABLE_DUMP2PROTO" = "Xon" ]]; then
57        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_DUMP_PROTO=ON"
58    fi
59    if [[ "X$ENABLE_GITEE" = "Xon" ]]; then
60        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_GITEE=ON"
61    fi
62    CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_DUMP_IR=${ENABLE_DUMP_IR}"
63    CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_PYTHON=${ENABLE_PYTHON}"
64    if [[ "X$ENABLE_MPI" = "Xon" ]]; then
65        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_MPI=ON"
66    fi
67    if [[ "X$ENABLE_D" = "Xon" ]]; then
68        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_D=ON"
69    fi
70    if [[ "X$ENABLE_GPU" = "Xon" ]]; then
71        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_GPU=ON -DUSE_CUDA=ON -DCUDA_PATH=$CUDA_PATH -DMS_REQUIRE_CUDA_VERSION=${CUDA_VERSION}"
72    fi
73    if [[ "X$ENABLE_CPU" = "Xon" ]]; then
74        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_CPU=ON -DX86_64_SIMD=${X86_64_SIMD} -DARM_SIMD=${ARM_SIMD}"
75    fi
76    if [[ "X$COMPILE_MINDDATA" = "Xon" ]]; then
77        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_MINDDATA=ON"
78    fi
79    if [[ "X$USE_GLOG" = "Xon" ]]; then
80        CMAKE_ARGS="${CMAKE_ARGS} -DUSE_GLOG=ON"
81    fi
82    if [[ "X$ENABLE_AKG" = "Xon" ]] && [[ "X$ENABLE_D" = "Xon" || "X$ENABLE_GPU" = "Xon" ]]; then
83        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_AKG=ON"
84    fi
85    if [[ "X$ENABLE_ACL" = "Xon" ]]; then
86        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_ACL=ON"
87    fi
88    if [[ "X$ENABLE_DEBUGGER" = "Xon" ]]; then
89        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_DEBUGGER=ON"
90    fi
91
92    if [[ "X$ENABLE_IBVERBS" = "Xon" ]]; then
93        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_IBVERBS=ON"
94    fi
95    if [[ "X$ENABLE_HIDDEN" = "Xoff" ]]; then
96        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_HIDDEN=OFF"
97    fi
98    if [[ "X$ENABLE_TRT" == "Xon" ]]; then
99        CMAKE_ARGS="${CMAKE_ARGS} -DTENSORRT_HOME=${TENSORRT_HOME}"
100    fi
101    echo "${CMAKE_ARGS}"
102    if [[ "X$INC_BUILD" = "Xoff" ]]; then
103      cmake ${CMAKE_ARGS} ${BASEPATH}
104    fi
105    if [[ -n "$VERBOSE" ]]; then
106      CMAKE_VERBOSE="--verbose"
107    fi
108    cmake --build . --target package ${CMAKE_VERBOSE} -j$THREAD_NUM
109    echo "success building mindspore project!"
110}