• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3# Copyright (C) 2022 Huawei Device Co., Ltd.
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
16set -e
17
18usage()
19{
20    echo
21    echo "USAGE"
22    echo "       ./build.sh [suite=BUILD_TARGET] [target_os=TARGET_OS] [target_arch=TARGET_ARCH] [variant=BUILD_VARIANT] [target_subsystem=TARGET_SUBSYSTEM]"
23    echo "                  target_platform  : TARGET_PLATFORM  the target platform, such as phone or ivi; Default to phone"
24    echo "                  suite            : BUILD_TARGET       cts/hit/vts and so on, default value is hit"
25    echo "                  target_arch      : TARGET_ARCH      arm64 or arm32, default value is arm64"
26    echo "                  variant          : BUILD_VARIANT    release or debug. The default value is debug."
27    echo "                  target_subsystem : TARGET_SUBSYSTEM the target subsystem to build"
28    echo "                  system_size      : SYSTEM_SIZE      standard, large, and son on. Wherein,large is for L3-L5, and standard is for L2. The default value is large."
29    echo "                  product_name     : PRODUCT_NAME     product name,for example,hikey960,Hi3516DV300,and so on."
30    echo
31    exit 1
32}
33
34
35parse_cmdline()
36{
37    BASE_HOME=$(dirname $(cd $(dirname $0); pwd))
38    BASE_HOME=${BASE_HOME}/../..
39    BUILD_TOOLS_DIR=${BASE_HOME}/prebuilts/build-tools/linux-x86/bin
40    OUT_DIR=${BASE_HOME}/out
41    BUILD_SHELL=${BASE_HOME}/build.sh
42    # build all parts for all products by default
43    BUILD_TARGET=""
44    TARGET_PLATFORM=all
45    GN_ARGS="is_dbt_test=true include_all=false"
46    TARGET_ARCH=arm64
47    BUILD_VARIANT=release
48    UPLOAD_API_INFO=False
49    SYSTEM_SIZE=large
50    PRODUCT_NAME=""
51    export PATH=${BASE_HOME}/prebuilts/python/linux-x86/3.8.3/bin:$PATH
52
53    while [ -n "$1" ]
54    do
55        var="$1"
56        OPTIONS=${var%%=*}
57        PARAM=${var#*=}
58        echo "OPTIONS=$OPTIONS"
59        echo "PARAM=$PARAM"
60        echo "-------------------"
61        case "$OPTIONS" in
62        suite)            BUILD_TARGET="$PARAM"
63                          ;;
64        target_arch)      TARGET_ARCH="$PARAM"
65                          ;;
66        variant)          BUILD_VARIANT="$PARAM"
67                          ;;
68	target_platform)  TARGET_PLATFORM="$PARAM"
69                          ;;
70        target_subsystem) export target_subsystem=${PARAM}
71                          ;;
72        system_size)      SYSTEM_SIZE="$PARAM"
73                          ;;
74        product_name)     PRODUCT_NAME="$PARAM"
75                          ;;
76        upload_api_info)  UPLOAD_API_INFO=$(echo $PARAM |tr [a-z] [A-Z])
77                         ;;
78        *)   usage
79             break;;
80        esac
81        shift
82    done
83    if [ "$SYSTEM_SIZE" = "standard" ]; then
84       BUILD_TARGET=${BUILD_TARGET:-"dcts"}
85       PRODUCT_NAME=${PRODUCT_NAME:-"Hi3516DV300"}
86    else
87       BUILD_TARGET=${BUILD_TARGET:-"dcts dcts_ivi dcts_intellitv dcts_wearable"}
88       PRODUCT_NAME=${PRODUCT_NAME:-"arm64"}
89    fi
90}
91
92
93do_make()
94{
95    cd $BASE_HOME
96    HATS_ROOT="$BASE_HOME/test/xts/dcts"
97
98    rm -rf "$BASE_HOME/test/xts/autogen_apiobjs"
99    export XTS_SUITENAME=dcts
100    if [ "$SYSTEM_SIZE" = "standard" ]; then
101       ./build.sh --product-name $PRODUCT_NAME --gn-args build_xts=true --build-target $BUILD_TARGET --build-target "deploy_testtools" --gn-args is_standard_system=true
102    else
103       if [ "$BUILD_TARGET" = "dcts dcts_ivi dcts_intellitv dcts_wearable" ]; then
104         ./build.sh --product-name $PRODUCT_NAME --gn-args build_xts=true --build-target "dcts" --build-target "dcts_ivi" --build-target "dcts_intellitv" --build-target "dcts_wearable" --build-target "deploy_testtools"
105       else
106         ./build.sh --product-name $PRODUCT_NAME --gn-args build_xts=true --build-target $BUILD_TARGET --build-target "deploy_testtools"
107       fi
108    fi
109    ret=$?
110
111    rm -rf "$BASE_HOME/test/xts/autogen_apiobjs"
112    if [ "$ret" != 0 ]; then
113        echo "build error"
114        exit 1
115    fi
116}
117parse_cmdline $@
118do_make
119exit 0
120