build.sh 4.6 KB
Newer Older
M
mamingshuai 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#!/bin/bash

# Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -e

usage()
{
    echo
    echo "USAGE"
    echo "       ./build.sh [suite=BUILD_TARGET] [target_os=TARGET_OS] [target_arch=TARGET_ARCH] [variant=BUILD_VARIANT] [target_subsystem=TARGET_SUBSYSTEM]"
J
jiyong 已提交
23 24
    echo "                  suite            : BUILD_TARGET     acts, hats, dcts"
    echo "                  target_arch      : TARGET_ARCH      arm64 or arm, default value is arm"
M
mamingshuai 已提交
25 26
    echo "                  variant          : BUILD_VARIANT    release or debug, default value is debug"
    echo "                  target_subsystem : TARGET_SUBSYSTEM the target subsystem to build"
J
jiyong 已提交
27 28
    echo "                  system_size      : SYSTEM_SIZE      standard"
    echo "                  product_name     : PRODUCT_NAME     the name of product. such as Hi3516DV300, and so on."
M
mamingshuai 已提交
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
    echo
    exit 1
}


parse_cmdline()
{
    BASE_HOME=$(dirname $(cd $(dirname $0); pwd))
    BASE_HOME=${BASE_HOME}/../..
    BUILD_TOOLS_DIR=${BASE_HOME}/prebuilts/build-tools/linux-x86/bin
    OUT_DIR=${BASE_HOME}/out
    BUILD_SHELL=${BASE_HOME}/build.sh
    # build all parts for all products by default
    BUILD_TARGET=""
    GN_ARGS="is_dbt_test=true include_all=false"
J
up 64  
jiyong 已提交
44
    TARGET_ARCH=arm
M
mamingshuai 已提交
45 46
    BUILD_VARIANT=release
    UPLOAD_API_INFO=False
J
jiyong 已提交
47
    SYSTEM_SIZE=standard
M
mamingshuai 已提交
48
    PRODUCT_NAME=""
J
jiyong 已提交
49
    USE_MUSL=false
M
mamingshuai 已提交
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
    export PATH=${BASE_HOME}/prebuilts/python/linux-x86/3.8.3/bin:$PATH

    while [ -n "$1" ]
    do
        var="$1"
        OPTIONS=${var%%=*}
        PARAM=${var#*=}
        echo "OPTIONS=$OPTIONS"
        echo "PARAM=$PARAM"
        echo "-------------------"
        case "$OPTIONS" in
        suite)            BUILD_TARGET="$PARAM"
                          ;;
        target_arch)      TARGET_ARCH="$PARAM"
                          ;;
        variant)          BUILD_VARIANT="$PARAM"
                          ;;
J
jiyong 已提交
67
        use_musl)         USE_MUSL="$PARAM"
M
mamingshuai 已提交
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
                          ;;
        target_subsystem) export target_subsystem=${PARAM}
                          ;;
        system_size)      SYSTEM_SIZE="$PARAM"
                          ;;
        product_name)     PRODUCT_NAME="$PARAM"
                          ;;
        upload_api_info)  UPLOAD_API_INFO=$(echo $PARAM |tr [a-z] [A-Z])
                         ;;
        *)   usage
             break;;
        esac
        shift
    done
    if [ "$SYSTEM_SIZE" = "standard" ]; then
       BUILD_TARGET=${BUILD_TARGET:-"acts"}
       PRODUCT_NAME=${PRODUCT_NAME:-"Hi3516DV300"}
    else
       BUILD_TARGET=${BUILD_TARGET:-"acts acts_ivi acts_intellitv acts_wearable"}
       PRODUCT_NAME=${PRODUCT_NAME:-"arm64"}
    fi
}


do_make()
{
    cd $BASE_HOME
    ACTS_ROOT="$BASE_HOME/test/xts/acts"

    rm -rf "$BASE_HOME/test/xts/autogen_apiobjs"
    export XTS_SUITENAME=acts
    if [ "$SYSTEM_SIZE" = "standard" ]; then
J
jiyong_sd 已提交
100 101
        MUSL_ARGS=""
        if [ "$PRODUCT_NAME" = "m40" ]; then
J
jiyong 已提交
102 103 104
		    if [ "$USE_MUSL" = "false" ]; then
                        MUSL_ARGS="--gn-args use_musl=false --gn-args use_custom_libcxx=true --gn-args use_custom_clang=true"			
		    fi
J
jiyong_sd 已提交
105
        fi
Q
add  
qu-xianfei 已提交
106
       ./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 --target-cpu $TARGET_ARCH --get-warning-list=false --stat-ccache=false --compute-overlap-rate=false --deps-guard=false --generate-ninja-trace=false --gn-args skip_generate_module_list_file=true
M
mamingshuai 已提交
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
    else
       if [ "$BUILD_TARGET" = "acts acts_ivi acts_intellitv acts_wearable" ]; then
         ./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"
       else
         ./build.sh --product-name $PRODUCT_NAME --gn-args build_xts=true --build-target $BUILD_TARGET --build-target "deploy_testtools"
       fi
    fi
    ret=$?

    rm -rf "$BASE_HOME/test/xts/autogen_apiobjs"
    if [ "$ret" != 0 ]; then
        echo "build error"
        exit 1
    fi
}
parse_cmdline $@
do_make
exit 0