• 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
19build_option_proc_b()
20{
21  if [[ "X$OPTARG" != "Xge" && "X$OPTARG" != "Xcpu" ]]; then
22    echo "Invalid value ${OPTARG} for option -b"
23    usage
24    exit 1
25  fi
26  ENABLE_BACKEND=$(echo "$OPTARG" | tr '[a-z]' '[A-Z]')
27  if [[ "X$ENABLE_BACKEND" != "XCPU" ]]; then
28    export ENABLE_CPU="on"
29  fi
30}
31
32build_option_proc_l()
33{
34  check_on_off $OPTARG l
35  export ENABLE_PYTHON="$OPTARG"
36}
37
38build_option_proc_m()
39{
40  if [[ "X$OPTARG" != "Xinfer" && "X$OPTARG" != "Xtrain" ]]; then
41    echo "Invalid value ${OPTARG} for option -m"
42    usage
43    exit 1
44  fi
45  export TRAIN_MODE=$(echo "$OPTARG" | tr '[a-z]' '[A-Z]')
46}
47
48build_option_proc_s()
49{
50  check_on_off $OPTARG s
51  if [[ "X$OPTARG" == "Xon" ]]; then
52    if [[ $USER_ENABLE_DUMP_IR == true ]]; then
53      echo "enable security, the dump ir is not available"
54      usage
55      exit 1
56    fi
57    if [[ $USER_ENABLE_DEBUGGER == true ]]; then
58      echo "enable security, the debugger is not available"
59      usage
60      exit 1
61    fi
62    export ENABLE_DUMP_IR="off"
63    export ENABLE_DEBUGGER="off"
64  fi
65  export ENABLE_SECURITY="$OPTARG"
66  echo "enable security"
67}
68
69build_option_proc_upper_s()
70{
71  check_on_off $OPTARG S
72  export ENABLE_GITEE="$OPTARG"
73  echo "enable download from gitee"
74}
75
76build_option_proc_z()
77{
78  eval ARG=\$\{$OPTIND\}
79  if [[ -n "$ARG" && "$ARG" != -* ]]; then
80    OPTARG="$ARG"
81    check_on_off $OPTARG z
82    OPTIND=$((OPTIND + 1))
83  else
84    OPTARG=""
85  fi
86  if [[ "X$OPTARG" == "Xoff" ]]; then
87    export COMPILE_MINDDATA="off"
88  fi
89}