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=arm 47 BUILD_VARIANT=release 48 UPLOAD_API_INFO=False 49 SYSTEM_SIZE=large 50 PRODUCT_NAME="" 51 USE_MUSL=false 52 export PATH=${BASE_HOME}/prebuilts/python/linux-x86/3.8.3/bin:$PATH 53 54 while [ -n "$1" ] 55 do 56 var="$1" 57 OPTIONS=${var%%=*} 58 PARAM=${var#*=} 59 echo "OPTIONS=$OPTIONS" 60 echo "PARAM=$PARAM" 61 echo "-------------------" 62 case "$OPTIONS" in 63 suite) BUILD_TARGET="$PARAM" 64 ;; 65 target_arch) TARGET_ARCH="$PARAM" 66 ;; 67 variant) BUILD_VARIANT="$PARAM" 68 ;; 69 target_platform) TARGET_PLATFORM="$PARAM" 70 ;; 71 use_musl) USE_MUSL="$PARAM" 72 ;; 73 target_subsystem) export target_subsystem=${PARAM} 74 ;; 75 system_size) SYSTEM_SIZE="$PARAM" 76 ;; 77 product_name) PRODUCT_NAME="$PARAM" 78 ;; 79 upload_api_info) UPLOAD_API_INFO=$(echo $PARAM |tr [a-z] [A-Z]) 80 ;; 81 *) usage 82 break;; 83 esac 84 shift 85 done 86 if [ "$SYSTEM_SIZE" = "standard" ]; then 87 BUILD_TARGET=${BUILD_TARGET:-"dcts"} 88 PRODUCT_NAME=${PRODUCT_NAME:-"Hi3516DV300"} 89 else 90 BUILD_TARGET=${BUILD_TARGET:-"dcts dcts_ivi dcts_intellitv dcts_wearable"} 91 PRODUCT_NAME=${PRODUCT_NAME:-"arm64"} 92 fi 93} 94 95 96do_make() 97{ 98 cd $BASE_HOME 99 HATS_ROOT="$BASE_HOME/test/xts/dcts" 100 101 rm -rf "$BASE_HOME/test/xts/autogen_apiobjs" 102 export XTS_SUITENAME=dcts 103 if [ "$SYSTEM_SIZE" = "standard" ]; then 104 MUSL_ARGS="" 105 if [ "$PRODUCT_NAME" = "m40" ]; then 106 if [ "$USE_MUSL" = "false" ]; then 107 MUSL_ARGS="--gn-args use_musl=false --gn-args use_custom_libcxx=true --gn-args use_custom_clang=true" 108 fi 109 fi 110 ./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 111 else 112 if [ "$BUILD_TARGET" = "dcts dcts_ivi dcts_intellitv dcts_wearable" ]; then 113 ./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" 114 else 115 ./build.sh --product-name $PRODUCT_NAME --gn-args build_xts=true --build-target $BUILD_TARGET --build-target "deploy_testtools" 116 fi 117 fi 118 ret=$? 119 120 rm -rf "$BASE_HOME/test/xts/autogen_apiobjs" 121 if [ "$ret" != 0 ]; then 122 echo "build error" 123 exit 1 124 fi 125} 126parse_cmdline $@ 127do_make 128exit 0 129