• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3# Copyright (C) 2021 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, 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, large is for L3-L5, standard is for L2 default value is large"
29    echo "                  product_name     : PRODUCT_NAME     the name of product. such as 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:-"acts"}
85       PRODUCT_NAME=${PRODUCT_NAME:-"Hi3516DV300"}
86    else
87       BUILD_TARGET=${BUILD_TARGET:-"acts acts_ivi acts_intellitv acts_wearable"}
88       PRODUCT_NAME=${PRODUCT_NAME:-"arm64"}
89    fi
90}
91
92
93do_make()
94{
95    cd $BASE_HOME
96    ACTS_ROOT="$BASE_HOME/test/xts/acts"
97
98    rm -rf "$BASE_HOME/test/xts/autogen_apiobjs"
99    export XTS_SUITENAME=acts
100    if [ "$SYSTEM_SIZE" = "standard" ]; then
101        MUSL_ARGS=""
102        if [ "$PRODUCT_NAME" = "m40" ]; then
103            MUSL_ARGS="--gn-args use_musl=false --gn-args use_custom_libcxx=true --gn-args use_custom_clang=true"
104        fi
105       ./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 $MUSL_ARGS
106    else
107       if [ "$BUILD_TARGET" = "acts acts_ivi acts_intellitv acts_wearable" ]; then
108         ./build.sh --product-name $PRODUCT_NAME --gn-args build_xts=true --build-target "acts" --build-target "acts_ivi" --build-target "acts_intellitv" --build-target "acts_wearable" --build-target "deploy_testtools"
109       else
110         ./build.sh --product-name $PRODUCT_NAME --gn-args build_xts=true --build-target $BUILD_TARGET --build-target "deploy_testtools"
111       fi
112    fi
113    ret=$?
114
115    rm -rf "$BASE_HOME/test/xts/autogen_apiobjs"
116    if [ "$ret" != 0 ]; then
117        echo "build error"
118        exit 1
119    fi
120}
121parse_cmdline $@
122do_make
123exit 0
124