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 " suite : BUILD_TARGET acts, hats, dcts" 24 echo " target_arch : TARGET_ARCH arm64 or arm, default value is arm" 25 echo " variant : BUILD_VARIANT release or debug, default value is debug" 26 echo " target_subsystem : TARGET_SUBSYSTEM the target subsystem to build" 27 echo " system_size : SYSTEM_SIZE standard" 28 echo " product_name : PRODUCT_NAME the name of product. such as Hi3516DV300, and so on." 29 echo 30 exit 1 31} 32 33 34parse_cmdline() 35{ 36 BASE_HOME=$(dirname $(cd $(dirname $0); pwd)) 37 BASE_HOME=${BASE_HOME}/../.. 38 BUILD_TOOLS_DIR=${BASE_HOME}/prebuilts/build-tools/linux-x86/bin 39 OUT_DIR=${BASE_HOME}/out 40 BUILD_SHELL=${BASE_HOME}/build.sh 41 # build all parts for all products by default 42 BUILD_TARGET="" 43 GN_ARGS="is_dbt_test=true include_all=false" 44 TARGET_ARCH=arm 45 BUILD_VARIANT=release 46 UPLOAD_API_INFO=False 47 SYSTEM_SIZE=standard 48 PRODUCT_NAME="" 49 PR_PARTH_LIST="" 50 USE_MUSL=false 51 export PATH=${BASE_HOME}/prebuilts/python/linux-x86/3.8.3/bin:$PATH 52 53 system_build_params="build_xts=true" 54 55 while [ -n "$1" ] 56 do 57 var="$1" 58 OPTIONS=${var%%=*} 59 PARAM=${var#*=} 60 echo "OPTIONS=$OPTIONS" 61 echo "PARAM=$PARAM" 62 echo "-------------------" 63 case "$OPTIONS" in 64 suite) BUILD_TARGET="$PARAM" 65 ;; 66 target_arch) TARGET_ARCH="$PARAM" 67 ;; 68 variant) BUILD_VARIANT="$PARAM" 69 ;; 70 use_musl) USE_MUSL="$PARAM" 71 ;; 72 target_subsystem) export target_subsystem=${PARAM} 73 ;; 74 system_size) SYSTEM_SIZE="$PARAM" 75 ;; 76 product_name) PRODUCT_NAME="$PARAM" 77 ;; 78 pr_path_list) PR_PARTH_LIST="$PARAM" 79 ;; 80 upload_api_info) UPLOAD_API_INFO=$(echo $PARAM |tr [a-z] [A-Z]) 81 ;; 82 cache_type) CACHE_TYPE="$PARAM" 83 ;; 84 *) usage 85 break;; 86 esac 87 shift 88 done 89 if [ "$SYSTEM_SIZE" = "standard" ]; then 90 BUILD_TARGET=${BUILD_TARGET:-"test/xts/acts:xts_acts"} 91 PRODUCT_NAME=${PRODUCT_NAME:-"Hi3516DV300"} 92 else 93 BUILD_TARGET=${BUILD_TARGET:-"acts acts_ivi acts_intellitv acts_wearable"} 94 PRODUCT_NAME=${PRODUCT_NAME:-"arm64"} 95 fi 96} 97 98 99do_make() 100{ 101 BUILD_TARGET=$(echo "$BUILD_TARGET" | sed 's/,/ /g') 102 echo "BUILD_TARGET: $BUILD_TARGET" 103 cd $BASE_HOME 104 ACTS_ROOT="$BASE_HOME/test/xts/acts" 105 106 rm -rf "$BASE_HOME/test/xts/autogen_apiobjs" 107 export XTS_SUITENAME=acts 108 if [ "$SYSTEM_SIZE" = "standard" ]; then 109 MUSL_ARGS="" 110 if [ "$PRODUCT_NAME" = "m40" ]; then 111 if [ "$USE_MUSL" = "false" ]; then 112 MUSL_ARGS="--gn-args use_musl=false --gn-args use_custom_libcxx=true --gn-args use_custom_clang=true" 113 fi 114 fi 115 CACHE_ARG="" 116 117 if [ "$CACHE_TYPE" == "xcache" ];then 118 CACHE_ARG="--ccache false --xcache true" 119 fi 120 if [ "$PR_PARTH_LIST" != "" ]; then 121 system_build_params+=" pr_path_list=$PR_PARTH_LIST" 122 fi 123 ./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=true --compute-overlap-rate=false --deps-guard=false $CACHE_ARG --gn-args skip_generate_module_list_file=true 124 else 125 if [ "$BUILD_TARGET" = "acts acts_ivi acts_intellitv acts_wearable" ]; then 126 ./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" 127 else 128 ./build.sh --product-name $PRODUCT_NAME --gn-args build_xts=true --build-target $BUILD_TARGET --build-target "deploy_testtools" 129 fi 130 fi 131 ret=$? 132 133 rm -rf "$BASE_HOME/test/xts/autogen_apiobjs" 134 if [ "$ret" != 0 ]; then 135 echo "build error" 136 exit 1 137 fi 138} 139parse_cmdline $@ 140do_make 141exit 0 142