• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# Copyright (c) 2021 Huawei Device Co., Ltd.
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15set -e
16
17# set default value
18target_os=ohos
19target_cpu=arm64
20use_ccache=false
21sparse_image=false
22
23
24while test $# -gt 0
25do
26  case "$1" in
27  --product-name)
28    shift
29    product_name="$1"
30    ;;
31  --device-name)
32    shift
33    device_name="$1"
34    ;;
35  --target-cpu)
36    shift
37    target_cpu="$1"
38    ;;
39  --target-os)
40    shift
41    target_os="$1"
42    ;;
43  --build-target | -t)
44    shift
45    build_target="${build_target} $1"
46    ;;
47  --gn-args)
48    shift
49    gn_args="${gn_args} $1"
50    ;;
51  --ninja-args)
52    shift
53    ninja_args="${ninja_args} $1"
54    ;;
55  --ccache)
56    use_ccache=true
57    ;;
58  --sparse-image)
59    sparse_image=true
60    ;;
61  --jobs)
62    shift
63    jobs="$1"
64    ;;
65  --export-para)
66    shift
67    PARAM1=$(echo "$1" | sed 's/\(.*\):\(.*\)/\1/')
68    PARAM2=$(echo "$1" | sed 's/.*://')
69    export $PARAM1=$PARAM2
70    ;;
71  --build-only-gn)
72    build_only_gn=true;;
73  -* | *)
74    echo "Unrecognized option: $1"
75    exit 1
76    ;;
77  esac
78  shift
79done
80
81if [[ "${product_name}x" == "x" ]]; then
82  echo "Error: the product name should be specified!"
83  exit 1
84fi
85
86if [[ "${use_ccache}" == true ]]; then
87  set +e
88  which ccache > /dev/null 2>&1
89  if [ $? -ne 0 ]; then
90    echo -e "\033[31mError: the ccache is not available, please install ccache.\033[0m"
91    exit 1
92  fi
93  source ${OHOS_ROOT_PATH}/build/core/build_scripts/set_ccache.sh
94  export CCACHE_EXEC=$(which ccache)
95  set_ccache
96  set -e
97fi
98
99if [[ "${sparse_image}" == true ]]; then
100  set +e
101  which img2simg > /dev/null 2>&1
102  if [[ $? -ne 0 ]]; then
103    echo -e "\033[31mError: the img2simg is not available, please install img2simg.\033[0m"
104    exit 1
105  fi
106  set -e
107fi
108