1f6603c60Sopenharmony_ci#!/bin/bash 2f6603c60Sopenharmony_ci 3f6603c60Sopenharmony_ci# Copyright (C) 2021 Huawei Device Co., Ltd. 4f6603c60Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); 5f6603c60Sopenharmony_ci# you may not use this file except in compliance with the License. 6f6603c60Sopenharmony_ci# You may obtain a copy of the License at 7f6603c60Sopenharmony_ci# 8f6603c60Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 9f6603c60Sopenharmony_ci# 10f6603c60Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software 11f6603c60Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, 12f6603c60Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13f6603c60Sopenharmony_ci# See the License for the specific language governing permissions and 14f6603c60Sopenharmony_ci# limitations under the License. 15f6603c60Sopenharmony_ci 16f6603c60Sopenharmony_ciset -e 17f6603c60Sopenharmony_ci 18f6603c60Sopenharmony_ciusage() { 19f6603c60Sopenharmony_ci echo 20f6603c60Sopenharmony_ci echo "USAGE" 21f6603c60Sopenharmony_ci echo " ./build.sh [suite=BUILD_TARGET] [target_os=TARGET_OS] [target_arch=TARGET_ARCH] [variant=BUILD_VARIANT] [target_subsystem=TARGET_SUBSYSTEM]" 22f6603c60Sopenharmony_ci echo " suite : BUILD_TARGET acts, hats, dcts" 23f6603c60Sopenharmony_ci echo " target_arch : TARGET_ARCH arm64 or arm, default value is arm" 24f6603c60Sopenharmony_ci echo " variant : BUILD_VARIANT release or debug, default value is debug" 25f6603c60Sopenharmony_ci echo " target_subsystem : TARGET_SUBSYSTEM the target subsystem to build" 26f6603c60Sopenharmony_ci echo " system_size : SYSTEM_SIZE standard" 27f6603c60Sopenharmony_ci echo " product_name : PRODUCT_NAME the name of product. such as Hi3516DV300, and so on." 28f6603c60Sopenharmony_ci echo 29f6603c60Sopenharmony_ci exit 1 30f6603c60Sopenharmony_ci} 31f6603c60Sopenharmony_ci 32f6603c60Sopenharmony_ciparse_cmdline() { 33f6603c60Sopenharmony_ci BASE_HOME=$(dirname $(cd $(dirname $0); pwd)) 34f6603c60Sopenharmony_ci BASE_HOME=${BASE_HOME}/../.. 35f6603c60Sopenharmony_ci BUILD_TOOLS_DIR=${BASE_HOME}/prebuilts/build-tools/linux-x86/bin 36f6603c60Sopenharmony_ci OUT_DIR=${BASE_HOME}/out 37f6603c60Sopenharmony_ci BUILD_SHELL=${BASE_HOME}/build.sh 38f6603c60Sopenharmony_ci # build all parts for all products by default 39f6603c60Sopenharmony_ci BUILD_TARGET="" 40f6603c60Sopenharmony_ci GN_ARGS="is_dbt_test=true include_all=false" 41f6603c60Sopenharmony_ci TARGET_ARCH=arm 42f6603c60Sopenharmony_ci BUILD_VARIANT=release 43f6603c60Sopenharmony_ci UPLOAD_API_INFO=False 44f6603c60Sopenharmony_ci SYSTEM_SIZE=standard 45f6603c60Sopenharmony_ci PRODUCT_NAME="" 46f6603c60Sopenharmony_ci PR_PARTH_LIST="" 47f6603c60Sopenharmony_ci USE_MUSL=false 48f6603c60Sopenharmony_ci export PATH=${BASE_HOME}/prebuilts/python/linux-x86/3.8.3/bin:$PATH 49f6603c60Sopenharmony_ci 50f6603c60Sopenharmony_ci 51f6603c60Sopenharmony_ci system_build_params="build_xts=true" 52f6603c60Sopenharmony_ci 53f6603c60Sopenharmony_ci while [ -n "$1" ]; do 54f6603c60Sopenharmony_ci var="$1" 55f6603c60Sopenharmony_ci OPTIONS=${var%%=*} 56f6603c60Sopenharmony_ci PARAM=${var#*=} 57f6603c60Sopenharmony_ci echo "OPTIONS=$OPTIONS" 58f6603c60Sopenharmony_ci echo "PARAM=$PARAM" 59f6603c60Sopenharmony_ci echo "-------------------" 60f6603c60Sopenharmony_ci case "$OPTIONS" in 61f6603c60Sopenharmony_ci suite) BUILD_TARGET="$PARAM" 62f6603c60Sopenharmony_ci ;; 63f6603c60Sopenharmony_ci target_arch) TARGET_ARCH="$PARAM" 64f6603c60Sopenharmony_ci ;; 65f6603c60Sopenharmony_ci variant) BUILD_VARIANT="$PARAM" 66f6603c60Sopenharmony_ci ;; 67f6603c60Sopenharmony_ci use_musl) USE_MUSL="$PARAM" 68f6603c60Sopenharmony_ci ;; 69f6603c60Sopenharmony_ci target_subsystem) export target_subsystem=${PARAM} 70f6603c60Sopenharmony_ci ;; 71f6603c60Sopenharmony_ci system_size) SYSTEM_SIZE="$PARAM" 72f6603c60Sopenharmony_ci ;; 73f6603c60Sopenharmony_ci product_name) PRODUCT_NAME="$PARAM" 74f6603c60Sopenharmony_ci ;; 75f6603c60Sopenharmony_ci pr_path_list) PR_PARTH_LIST="$PARAM" 76f6603c60Sopenharmony_ci ;; 77f6603c60Sopenharmony_ci upload_api_info) UPLOAD_API_INFO=$(echo $PARAM |tr [a-z] [A-Z]) 78f6603c60Sopenharmony_ci ;; 79f6603c60Sopenharmony_ci cache_type) CACHE_TYPE="$PARAM" 80f6603c60Sopenharmony_ci ;; 81f6603c60Sopenharmony_ci *) usage 82f6603c60Sopenharmony_ci break;; 83f6603c60Sopenharmony_ci esac 84f6603c60Sopenharmony_ci shift 85f6603c60Sopenharmony_ci done 86f6603c60Sopenharmony_ci if [ "$SYSTEM_SIZE" = "standard" ]; then 87f6603c60Sopenharmony_ci BUILD_TARGET=${BUILD_TARGET:-"test/xts/acts:xts_acts"} 88f6603c60Sopenharmony_ci PRODUCT_NAME=${PRODUCT_NAME:-"Hi3516DV300"} 89f6603c60Sopenharmony_ci else 90f6603c60Sopenharmony_ci BUILD_TARGET=${BUILD_TARGET:-"acts acts_ivi acts_intellitv acts_wearable"} 91f6603c60Sopenharmony_ci PRODUCT_NAME=${PRODUCT_NAME:-"arm64"} 92f6603c60Sopenharmony_ci fi 93f6603c60Sopenharmony_ci} 94f6603c60Sopenharmony_ci 95f6603c60Sopenharmony_cido_make() { 96f6603c60Sopenharmony_ci BUILD_TARGET=$(echo "$BUILD_TARGET" | sed 's/,/ /g') 97f6603c60Sopenharmony_ci echo "BUILD_TARGET: $BUILD_TARGET" 98f6603c60Sopenharmony_ci cd $BASE_HOME 99f6603c60Sopenharmony_ci ACTS_ROOT="$BASE_HOME/test/xts/acts" 100f6603c60Sopenharmony_ci 101f6603c60Sopenharmony_ci ${BASE_HOME}/prebuilts/python/linux-x86/current/bin/python3 -B ${ACTS_ROOT}/check_hvigor.py 102f6603c60Sopenharmony_ci if [ "$?" != 0 ]; then 103f6603c60Sopenharmony_ci exit 1 104f6603c60Sopenharmony_ci fi 105f6603c60Sopenharmony_ci 106f6603c60Sopenharmony_ci rm -rf "$BASE_HOME/test/xts/autogen_apiobjs" 107f6603c60Sopenharmony_ci export XTS_SUITENAME=acts 108f6603c60Sopenharmony_ci if [ "$SYSTEM_SIZE" = "standard" ]; then 109f6603c60Sopenharmony_ci MUSL_ARGS="" 110f6603c60Sopenharmony_ci if [ "$PRODUCT_NAME" = "m40" ]; then 111f6603c60Sopenharmony_ci if [ "$USE_MUSL" = "false" ]; then 112f6603c60Sopenharmony_ci MUSL_ARGS="--gn-args use_musl=false --gn-args use_custom_libcxx=true --gn-args use_custom_clang=true" 113f6603c60Sopenharmony_ci fi 114f6603c60Sopenharmony_ci fi 115f6603c60Sopenharmony_ci CACHE_ARG="" 116f6603c60Sopenharmony_ci 117f6603c60Sopenharmony_ci if [ "$CACHE_TYPE" == "xcache" ];then 118f6603c60Sopenharmony_ci CACHE_ARG="--ccache false --xcache true" 119f6603c60Sopenharmony_ci fi 120f6603c60Sopenharmony_ci if [ "$PR_PARTH_LIST" != "" ]; then 121f6603c60Sopenharmony_ci system_build_params+=" pr_path_list=$PR_PARTH_LIST" 122f6603c60Sopenharmony_ci fi 123f6603c60Sopenharmony_ci ./build.sh --product-name $PRODUCT_NAME --gn-args $system_build_params --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 124f6603c60Sopenharmony_ci else 125f6603c60Sopenharmony_ci if [ "$BUILD_TARGET" = "acts acts_ivi acts_intellitv acts_wearable" ]; then 126f6603c60Sopenharmony_ci ./build.sh --product-name $PRODUCT_NAME --gn-args $system_build_params --build-target "acts" --build-target "acts_ivi" --build-target "acts_intellitv" --build-target "acts_wearable" --build-target "deploy_testtools" 127f6603c60Sopenharmony_ci else 128f6603c60Sopenharmony_ci ./build.sh --product-name $PRODUCT_NAME --gn-args $system_build_params --build-target $BUILD_TARGET --build-target "deploy_testtools" 129f6603c60Sopenharmony_ci fi 130f6603c60Sopenharmony_ci fi 131f6603c60Sopenharmony_ci ret=$? 132f6603c60Sopenharmony_ci 133f6603c60Sopenharmony_ci rm -rf "$BASE_HOME/test/xts/autogen_apiobjs" 134f6603c60Sopenharmony_ci if [ "$ret" != 0 ]; then 135f6603c60Sopenharmony_ci echo "build error" 136f6603c60Sopenharmony_ci exit 1 137f6603c60Sopenharmony_ci fi 138f6603c60Sopenharmony_ci} 139f6603c60Sopenharmony_ciparse_cmdline $@ 140f6603c60Sopenharmony_cido_make 141f6603c60Sopenharmony_ciexit 0