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