-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
130 lines (121 loc) · 3.27 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/bash
set -e
PROJECTPATH=$(cd "$(dirname $0)"; pwd)
export BUILD_PATH="${PROJECTPATH}/build/"
# print usage message
usage()
{
echo "Usage:"
echo " bash build.sh [-j[n]] [-d] [-S on|off] "
echo " bash build.sh -t on [-j[n]] [-d] [-S on|off] "
echo ""
echo "Options:"
echo " -j[n] Set the threads when building (Default: -j8)"
echo " -d Debug model"
echo " -t Build testcases."
echo " -S Enable enable download cmake compile dependency from gitee instead of github, default off"
}
# check value of input is 'on' or 'off'
# usage: check_on_off arg_value arg_name
check_on_off()
{
if [[ "X$1" != "Xon" && "X$1" != "Xoff" ]]; then
echo "Invalid value $1 for option -$2"
usage
exit 1
fi
}
# check and set options
checkopts()
{
# Init default values of build options
THREAD_NUM=8
VERBOSE=""
DEBUG_MODE="off"
ENABLE_COVERAGE="off"
ENABLE_ASAN="off"
ENABLE_PYTHON="on"
MS_VERSION=""
RUN_TESTCASES="off"
ENABLE_GITEE="off"
# Process the options
while getopts 'dvc:j:a:p:e:V:t:S:' opt
do
LOW_OPTARG=$(echo ${OPTARG} | tr '[A-Z]' '[a-z]')
case "${opt}" in
d)
echo "user opt: -d"${LOW_OPTARG}
DEBUG_MODE="on"
;;
j)
echo "user opt: -j"${LOW_OPTARG}
THREAD_NUM=$OPTARG
;;
v)
echo "user opt: -v"${LOW_OPTARG}
VERBOSE="VERBOSE=1"
;;
c)
check_on_off $OPTARG c
ENABLE_COVERAGE="$OPTARG"
;;
a)
check_on_off $OPTARG a
ENABLE_ASAN="$OPTARG"
;;
t)
echo "user opt: -t"${LOW_OPTARG}
RUN_TESTCASES="$OPTARG"
;;
S)
check_on_off $OPTARG S
ENABLE_GITEE="$OPTARG"
echo "enable download from gitee"
;;
*)
echo "Unknown option ${opt}!"
usage
exit 1
esac
done
}
checkopts "$@"
echo "---------------- MindSpore Federated: build start ----------------"
mkdir -pv "${BUILD_PATH}/package/mindspore_federated/lib"
#if [[ "$MS_BACKEND_HEADER" != "off" ]]; then
# git submodule update --init third_party/mindspore
#fi
# Create building path
build_mindspore_federated()
{
echo "start build mindspore_federated project."
mkdir -pv "${BUILD_PATH}/mindspore_federated"
cd "${BUILD_PATH}/mindspore_federated"
CMAKE_ARGS="-DDEBUG_MODE=$DEBUG_MODE -DBUILD_PATH=$BUILD_PATH"
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_PYTHON=${ENABLE_PYTHON}"
CMAKE_ARGS="${CMAKE_ARGS} -DTHREAD_NUM=${THREAD_NUM}"
if [[ "X$ENABLE_COVERAGE" = "Xon" ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_COVERAGE=ON"
fi
if [[ "X$ENABLE_ASAN" = "Xon" ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_ASAN=ON"
fi
if [[ "$MS_VERSION" != "" ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DMS_VERSION=${MS_VERSION}"
fi
if [[ "X$RUN_TESTCASES" = "Xon" ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_TESTCASES=ON"
fi
if [[ "X$ENABLE_GITEE" = "Xon" ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_GITEE=ON"
fi
echo "${CMAKE_ARGS}"
cmake ${CMAKE_ARGS} ../..
if [[ -n "$VERBOSE" ]]; then
CMAKE_VERBOSE="--verbose"
fi
cmake --build . --target package ${CMAKE_VERBOSE} -j$THREAD_NUM
echo "success building mindspore_federated project!"
}
build_mindspore_federated
echo "---------------- mindspore_federated: build end ----------------"