• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# Copyright 2019-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
18BASEPATH=$(cd "$(dirname $0)"; pwd)
19export CUDA_PATH=""
20export BUILD_PATH="${BASEPATH}/build/"
21
22source ./scripts/build/usage.sh
23source ./scripts/build/default_options.sh
24source ./scripts/build/option_proc_debug.sh
25source ./scripts/build/option_proc_mindspore.sh
26source ./scripts/build/option_proc_lite.sh
27source ./scripts/build/process_options.sh
28source ./scripts/build/parse_device.sh
29source ./scripts/build/build_mindspore.sh
30
31# check value of input is 'on' or 'off'
32# usage: check_on_off arg_value arg_name
33check_on_off()
34{
35  if [[ "X$1" != "Xon" && "X$1" != "Xoff" ]]; then
36    echo "Invalid value $1 for option -$2"
37    usage
38    exit 1
39  fi
40}
41
42update_submodule()
43{
44  git submodule update --init graphengine
45  cd "${BASEPATH}/graphengine"
46  GRAPHENGINE_SUBMODULE="910/metadef"
47  git submodule update --init ${GRAPHENGINE_SUBMODULE}
48  cd "${BASEPATH}"
49  if [[ "X$ENABLE_AKG" = "Xon" ]]; then
50    if [[ "X$ENABLE_D" == "Xon" ]]; then
51      git submodule update --init akg
52    else
53      GIT_LFS_SKIP_SMUDGE=1 git submodule update --init akg
54    fi
55  fi
56}
57
58build_exit()
59{
60    echo "$@" >&2
61    stty echo
62    exit 1
63}
64
65make_clean()
66{
67  echo "enable make clean"
68  cd "${BUILD_PATH}/mindspore"
69  cmake --build . --target clean
70}
71
72echo "---------------- MindSpore: build start ----------------"
73init_default_options
74process_options "$@"
75parse_device
76
77if [[ "X$COMPILE_LITE" = "Xon" ]]; then
78  export COMPILE_MINDDATA_LITE
79  export ENABLE_VERBOSE
80  export LITE_PLATFORM
81  export LITE_ENABLE_AAR
82  source mindspore/lite/build_lite.sh
83else
84  mkdir -pv "${BUILD_PATH}/package/mindspore/lib"
85  mkdir -pv "${BUILD_PATH}/package/mindspore/lib/plugin"
86  update_submodule
87
88  build_mindspore
89
90  if [[ "X$ENABLE_MAKE_CLEAN" = "Xon" ]]; then
91    make_clean
92  fi
93  if [[ "X$ENABLE_ACL" == "Xon" ]] && [[ "X$ENABLE_D" == "Xoff" ]]; then
94      echo "acl mode, skipping deploy phase"
95      rm -rf ${BASEPATH}/output/_CPack_Packages/
96  elif [[ "X$FASTER_BUILD_FOR_PLUGINS" == "Xon" ]]; then
97      echo "plugin mode, skipping deploy phase"
98      rm -rf ${BASEPATH}/output/_CPack_Packages/
99  else
100      cp -rf ${BUILD_PATH}/package/mindspore/lib ${BASEPATH}/mindspore/python/mindspore
101      cp -rf ${BUILD_PATH}/package/mindspore/*.so ${BASEPATH}/mindspore/python/mindspore
102  fi
103fi
104echo "---------------- MindSpore: build end   ----------------"
105