10704ebd2Sopenharmony_ci#!/bin/bash 20704ebd2Sopenharmony_ci 30704ebd2Sopenharmony_ci# Copyright (C) 2022 Huawei Device Co., Ltd. 40704ebd2Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); 50704ebd2Sopenharmony_ci# you may not use this file except in compliance with the License. 60704ebd2Sopenharmony_ci# You may obtain a copy of the License at 70704ebd2Sopenharmony_ci# 80704ebd2Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 90704ebd2Sopenharmony_ci# 100704ebd2Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software 110704ebd2Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, 120704ebd2Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 130704ebd2Sopenharmony_ci# See the License for the specific language governing permissions and 140704ebd2Sopenharmony_ci# limitations under the License. 150704ebd2Sopenharmony_ci 160704ebd2Sopenharmony_ciset -e 170704ebd2Sopenharmony_ci 180704ebd2Sopenharmony_ciusage() 190704ebd2Sopenharmony_ci{ 200704ebd2Sopenharmony_ci echo 210704ebd2Sopenharmony_ci echo "USAGE" 220704ebd2Sopenharmony_ci echo " ./build.sh [suite=BUILD_TARGET] [target_os=TARGET_OS] [target_arch=TARGET_ARCH] [variant=BUILD_VARIANT] [target_subsystem=TARGET_SUBSYSTEM]" 230704ebd2Sopenharmony_ci echo " target_platform : TARGET_PLATFORM the target platform, such as phone or ivi; Default to phone" 240704ebd2Sopenharmony_ci echo " suite : BUILD_TARGET cts/hit/vts and so on, default value is hit" 250704ebd2Sopenharmony_ci echo " target_arch : TARGET_ARCH arm64 or arm32, default value is arm64" 260704ebd2Sopenharmony_ci echo " variant : BUILD_VARIANT release or debug. The default value is debug." 270704ebd2Sopenharmony_ci echo " target_subsystem : TARGET_SUBSYSTEM the target subsystem to build" 280704ebd2Sopenharmony_ci 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." 290704ebd2Sopenharmony_ci echo " product_name : PRODUCT_NAME product name,for example,hikey960,Hi3516DV300,and so on." 300704ebd2Sopenharmony_ci echo 310704ebd2Sopenharmony_ci exit 1 320704ebd2Sopenharmony_ci} 330704ebd2Sopenharmony_ci 340704ebd2Sopenharmony_ci 350704ebd2Sopenharmony_ciparse_cmdline() 360704ebd2Sopenharmony_ci{ 370704ebd2Sopenharmony_ci BASE_HOME=$(dirname $(cd $(dirname $0); pwd)) 380704ebd2Sopenharmony_ci BASE_HOME=${BASE_HOME}/../.. 390704ebd2Sopenharmony_ci BUILD_TOOLS_DIR=${BASE_HOME}/prebuilts/build-tools/linux-x86/bin 400704ebd2Sopenharmony_ci OUT_DIR=${BASE_HOME}/out 410704ebd2Sopenharmony_ci BUILD_SHELL=${BASE_HOME}/build.sh 420704ebd2Sopenharmony_ci # build all parts for all products by default 430704ebd2Sopenharmony_ci BUILD_TARGET="" 440704ebd2Sopenharmony_ci TARGET_PLATFORM=all 450704ebd2Sopenharmony_ci GN_ARGS="is_dbt_test=true include_all=false" 460704ebd2Sopenharmony_ci TARGET_ARCH=arm 470704ebd2Sopenharmony_ci BUILD_VARIANT=release 480704ebd2Sopenharmony_ci UPLOAD_API_INFO=False 490704ebd2Sopenharmony_ci SYSTEM_SIZE=large 500704ebd2Sopenharmony_ci PRODUCT_NAME="" 510704ebd2Sopenharmony_ci USE_MUSL=false 520704ebd2Sopenharmony_ci export PATH=${BASE_HOME}/prebuilts/python/linux-x86/3.8.3/bin:$PATH 530704ebd2Sopenharmony_ci 540704ebd2Sopenharmony_ci while [ -n "$1" ] 550704ebd2Sopenharmony_ci do 560704ebd2Sopenharmony_ci var="$1" 570704ebd2Sopenharmony_ci OPTIONS=${var%%=*} 580704ebd2Sopenharmony_ci PARAM=${var#*=} 590704ebd2Sopenharmony_ci echo "OPTIONS=$OPTIONS" 600704ebd2Sopenharmony_ci echo "PARAM=$PARAM" 610704ebd2Sopenharmony_ci echo "-------------------" 620704ebd2Sopenharmony_ci case "$OPTIONS" in 630704ebd2Sopenharmony_ci suite) BUILD_TARGET="$PARAM" 640704ebd2Sopenharmony_ci ;; 650704ebd2Sopenharmony_ci target_arch) TARGET_ARCH="$PARAM" 660704ebd2Sopenharmony_ci ;; 670704ebd2Sopenharmony_ci variant) BUILD_VARIANT="$PARAM" 680704ebd2Sopenharmony_ci ;; 690704ebd2Sopenharmony_ci target_platform) TARGET_PLATFORM="$PARAM" 700704ebd2Sopenharmony_ci ;; 710704ebd2Sopenharmony_ci use_musl) USE_MUSL="$PARAM" 720704ebd2Sopenharmony_ci ;; 730704ebd2Sopenharmony_ci target_subsystem) export target_subsystem=${PARAM} 740704ebd2Sopenharmony_ci ;; 750704ebd2Sopenharmony_ci system_size) SYSTEM_SIZE="$PARAM" 760704ebd2Sopenharmony_ci ;; 770704ebd2Sopenharmony_ci product_name) PRODUCT_NAME="$PARAM" 780704ebd2Sopenharmony_ci ;; 790704ebd2Sopenharmony_ci upload_api_info) UPLOAD_API_INFO=$(echo $PARAM |tr [a-z] [A-Z]) 800704ebd2Sopenharmony_ci ;; 810704ebd2Sopenharmony_ci cache_type) CACHE_TYPE="$PARAM" 820704ebd2Sopenharmony_ci ;; 830704ebd2Sopenharmony_ci *) usage 840704ebd2Sopenharmony_ci break;; 850704ebd2Sopenharmony_ci esac 860704ebd2Sopenharmony_ci shift 870704ebd2Sopenharmony_ci done 880704ebd2Sopenharmony_ci if [ "$SYSTEM_SIZE" = "standard" ]; then 890704ebd2Sopenharmony_ci BUILD_TARGET=${BUILD_TARGET:-"test/xts/dcts:xts_dcts"} 900704ebd2Sopenharmony_ci PRODUCT_NAME=${PRODUCT_NAME:-"Hi3516DV300"} 910704ebd2Sopenharmony_ci else 920704ebd2Sopenharmony_ci BUILD_TARGET=${BUILD_TARGET:-"dcts dcts_ivi dcts_intellitv dcts_wearable"} 930704ebd2Sopenharmony_ci PRODUCT_NAME=${PRODUCT_NAME:-"arm64"} 940704ebd2Sopenharmony_ci fi 950704ebd2Sopenharmony_ci} 960704ebd2Sopenharmony_ci 970704ebd2Sopenharmony_ci 980704ebd2Sopenharmony_cido_make() 990704ebd2Sopenharmony_ci{ 1000704ebd2Sopenharmony_ci cd $BASE_HOME 1010704ebd2Sopenharmony_ci HATS_ROOT="$BASE_HOME/test/xts/dcts" 1020704ebd2Sopenharmony_ci 1030704ebd2Sopenharmony_ci rm -rf "$BASE_HOME/test/xts/autogen_apiobjs" 1040704ebd2Sopenharmony_ci export XTS_SUITENAME=dcts 1050704ebd2Sopenharmony_ci if [ "$SYSTEM_SIZE" = "standard" ]; then 1060704ebd2Sopenharmony_ci MUSL_ARGS="" 1070704ebd2Sopenharmony_ci if [ "$PRODUCT_NAME" = "m40" ]; then 1080704ebd2Sopenharmony_ci if [ "$USE_MUSL" = "false" ]; then 1090704ebd2Sopenharmony_ci MUSL_ARGS="--gn-args use_musl=false --gn-args use_custom_libcxx=true --gn-args use_custom_clang=true" 1100704ebd2Sopenharmony_ci fi 1110704ebd2Sopenharmony_ci fi 1120704ebd2Sopenharmony_ci CACHE_ARG="" 1130704ebd2Sopenharmony_ci if [ "$CACHE_TYPE" == "xcache" ];then 1140704ebd2Sopenharmony_ci CACHE_ARG="--ccache false --xcache true" 1150704ebd2Sopenharmony_ci fi 1160704ebd2Sopenharmony_ci ./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 $CACHE_ARG --gn-args skip_generate_module_list_file=true 1170704ebd2Sopenharmony_ci else 1180704ebd2Sopenharmony_ci if [ "$BUILD_TARGET" = "dcts dcts_ivi dcts_intellitv dcts_wearable" ]; then 1190704ebd2Sopenharmony_ci ./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" 1200704ebd2Sopenharmony_ci else 1210704ebd2Sopenharmony_ci ./build.sh --product-name $PRODUCT_NAME --gn-args build_xts=true --build-target $BUILD_TARGET --build-target "deploy_testtools" 1220704ebd2Sopenharmony_ci fi 1230704ebd2Sopenharmony_ci fi 1240704ebd2Sopenharmony_ci ret=$? 1250704ebd2Sopenharmony_ci 1260704ebd2Sopenharmony_ci rm -rf "$BASE_HOME/test/xts/autogen_apiobjs" 1270704ebd2Sopenharmony_ci if [ "$ret" != 0 ]; then 1280704ebd2Sopenharmony_ci echo "build error" 1290704ebd2Sopenharmony_ci exit 1 1300704ebd2Sopenharmony_ci fi 1310704ebd2Sopenharmony_ci} 1320704ebd2Sopenharmony_ciparse_cmdline $@ 1330704ebd2Sopenharmony_cido_make 1340704ebd2Sopenharmony_ciexit 0 135