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 cts/hit/vts and so on, default value is hit" 24 echo " target_arch : TARGET_ARCH arm64 or arm32, default value is arm64" 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, large and son on, large is for L3-L5, standard is for L2 default value is large" 28 echo " product_name : PRODUCT_NAME the name of product. such as hikey960, 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 TARGET_PLATFORM=all 44 GN_ARGS="is_dbt_test=true include_all=false" 45 TARGET_ARCH=arm 46 BUILD_VARIANT=release 47 UPLOAD_API_INFO=False 48 SYSTEM_SIZE=standard 49 PRODUCT_NAME="" 50 USE_MUSL=false 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 use_musl) USE_MUSL="$PARAM" 69 ;; 70 target_platform) TARGET_PLATFORM="$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 upload_api_info) UPLOAD_API_INFO=$(echo $PARAM |tr [a-z] [A-Z]) 79 ;; 80 *) usage 81 break;; 82 esac 83 shift 84 done 85 if [ "$SYSTEM_SIZE" = "standard" ]; then 86 BUILD_TARGET=${BUILD_TARGET:-"test/xts/hats:xts_hats"} 87 PRODUCT_NAME=${PRODUCT_NAME:-"Hi3516DV300"} 88 else 89 BUILD_TARGET=${BUILD_TARGET:-"hats hats_ivi hats_intellitv hats_wearable"} 90 PRODUCT_NAME=${PRODUCT_NAME:-"arm64"} 91 fi 92} 93 94 95do_make() 96{ 97 cd $BASE_HOME 98 HATS_ROOT="$BASE_HOME/test/xts/hats" 99 100 rm -rf "$BASE_HOME/test/xts/autogen_apiobjs" 101 export XTS_SUITENAME=hats 102 if [ "$SYSTEM_SIZE" = "standard" ]; then 103 MUSL_ARGS="" 104 if [ "$PRODUCT_NAME" = "m40" ]; then 105 if [ "$USE_MUSL" = "false" ]; then 106 MUSL_ARGS="--gn-args use_musl=false --gn-args use_custom_libcxx=true --gn-args use_custom_clang=true" 107 fi 108 fi 109 ./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 --generate-ninja-trace=false --gn-args skip_generate_module_list_file=true 110 else 111 if [ "$BUILD_TARGET" = "hats hats_ivi hats_intellitv hats_wearable" ]; then 112 ./build.sh --product-name $PRODUCT_NAME --gn-args build_xts=true --build-target "hats" --build-target "hats_ivi" --build-target "hats_intellitv" --build-target "hats_wearable" --build-target "deploy_testtools" 113 else 114 ./build.sh --product-name $PRODUCT_NAME --gn-args build_xts=true --build-target $BUILD_TARGET --build-target "deploy_testtools" 115 fi 116 fi 117 ret=$? 118 119 rm -rf "$BASE_HOME/test/xts/autogen_apiobjs" 120 if [ "$ret" != 0 ]; then 121 echo "build error" 122 exit 1 123 fi 124} 125parse_cmdline $@ 126do_make 127exit 0 128