1#!/bin/bash 2# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15set -e 16 17BASE_HOME=$(dirname $(dirname $(dirname $(dirname $(cd $(dirname $0); pwd))))) 18PRODUCT="" 19XTS="" 20WIFIIOT_OUTFILE=Hi3861_wifiiot_app_allinone.bin 21DIST_DIR=$BASE_HOME/dist 22WIFIIOT_ACTS_MODULES="${WIFIIOT_ACTS_MODULES},//test/xts/acts/communication_lite/lwip_hal:ActsLwipTest" 23#WIFIIOT_ACTS_MODULES="${WIFIIOT_ACTS_MODULES},//test/xts/acts/communication_lite/wifiservice_hal:ActsWifiServiceTest" 24WIFIIOT_ACTS_MODULES="${WIFIIOT_ACTS_MODULES},//test/xts/acts/commonlibrary_lite/file_hal:ActsUtilsFileTest" 25WIFIIOT_ACTS_MODULES="${WIFIIOT_ACTS_MODULES},//test/xts/acts/startup_lite/syspara_hal:ActsParameterTest" 26WIFIIOT_ACTS_MODULES="${WIFIIOT_ACTS_MODULES},//test/xts/acts/iothardware_lite/peripheral_hal:ActsWifiIotTest" 27WIFIIOT_ACTS_MODULES="${WIFIIOT_ACTS_MODULES},//test/xts/acts/distributeddatamgr_lite/kv_store_hal:ActsKvStoreTest" 28WIFIIOT_ACTS_MODULES="${WIFIIOT_ACTS_MODULES},//test/xts/acts/security_lite/huks/liteos_m_adapter:ActsHuksHalFunctionTest" 29WIFIIOT_ACTS_MODULES="${WIFIIOT_ACTS_MODULES},//test/xts/acts/hiviewdfx_lite/hilog_hal:ActsDfxFuncTest" 30WIFIIOT_ACTS_MODULES="${WIFIIOT_ACTS_MODULES},//test/xts/acts/hiviewdfx_lite/hievent_hal:ActsHieventLiteTest" 31WIFIIOT_ACTS_MODULES="${WIFIIOT_ACTS_MODULES},//test/xts/acts/distributed_schedule_lite/system_ability_manager_hal:ActsSamgrTest" 32WIFIIOT_ACTS_MODULES="${WIFIIOT_ACTS_MODULES},//test/xts/acts/update_lite/dupdate_hal:ActsUpdaterFuncTest" 33WIFIIOT_ACTS_MODULES="${WIFIIOT_ACTS_MODULES},//test/xts/acts/startup_lite/bootstrap_hal:ActsBootstrapTest" 34 35error_report() { 36 echo "Error on line $1" 37} 38trap 'error_report $LINENO' ERR 39 40 41usage() 42{ 43 echo 44 echo "USAGE" 45 echo " ./build.sh product=PRODUCT [platform=PLATFORM] [target=TARGET] xts=XTS" 46 echo 47 echo " product : PRODUCT product name, such as ipcamera or wifiiot" 48 echo " platform : PLATFORM the platform of device" 49 echo " target : TARGET the target for build, such as //xts/acts/communication_lite/wifiaware_test." 50 echo " xts : XTS the name of xts, such as acts/hits etc." 51 echo 52 exit 1 53} 54 55check_python() 56{ 57 python_cmd="" 58 ver=$(python -c 'import platform; major, minor, patch = platform.python_version_tuple(); print(major);') 59 if [ "$ver" = "3" ];then 60 python_cmd=python 61 else 62 ver=$(python3 -c 'import platform; major, minor, patch = platform.python_version_tuple(); print(major);') 63 if [ "$ver" = "3" ];then 64 python_cmd=python3 65 fi 66 fi 67 if [ -z "$python_cmd" ];then 68 echo "Enviroment variable 'python3' is required, and python verion must be greater than 3.7" 69 exit 1 70 fi 71} 72 73parse_cmdline() 74{ 75 PLATFORM="" 76 TARGET="" 77 TARGET_PARAM="" 78 while [ -n "$1" ] 79 do 80 var="$1" 81 OPTIONS=$(echo ${var%%=*}) 82 PARAM=$(echo ${var#*=}) 83 case "$OPTIONS" in 84 product) PRODUCT="$PARAM" 85 ;; 86 platform) PLATFORM="$PARAM" 87 ;; 88 target) TARGET="$PARAM" 89 ;; 90 xts) XTS="$PARAM" 91 ;; 92 *) usage 93 break;; 94 esac 95 shift 96 done 97 if [ "$PRODUCT" = "" ] || [ "$XTS" = "" ];then 98 usage 99 fi 100 if [ "$PRODUCT" = "wifiiot" ];then 101 PLATFORM="hi3861v100_liteos_riscv" 102 if [ "$TARGET" = "" ];then 103 if [ "$XTS" = "acts" ];then 104 TARGET=$WIFIIOT_ACTS_MODULES 105 elif [ "$XTS" = "hits" ];then 106 TARGET=$WIFIIOT_HITS_MODULES 107 fi 108 fi 109 elif [ "$PLATFORM" = "" ];then 110 echo "platform is required, for product $PRODUCT" 111 usage 112 fi 113 if [ "$TARGET" != "" ];then 114 TARGET_PARAM=" --target $TARGET" 115 fi 116} 117 118 119 120build() 121{ 122 out_dir="${BASE_HOME}/out/hispark_pegasus/wifiiot_hispark_pegasus" 123 suite_root_dir="${out_dir}/suites" 124 cd $BASE_HOME 125 if [ "$PRODUCT" = "wifiiot" ]; then 126 if [ "$XTS" = "all" ];then 127 build_wifiiot "acts" $WIFIIOT_ACTS_MODULES 128 build_wifiiot "hits" $WIFIIOT_HITS_MODULES 129 cp -rf ${DIST_DIR}/acts ${suite_root_dir} 130 cd $suite_root_dir 131 zip -rv acts.zip acts 132 if [ -n "${DIST_DIR}" ]; then 133 rm -rf $DIST_DIR 134 fi 135 else 136 build_wifiiot $XTS $TARGET 137 if [ -n "${DIST_DIR}" ]; then 138 rm -rf $DIST_DIR 139 fi 140 fi 141 else 142 python build.py ${PRODUCT}_${PLATFORM} -b debug --test xts $TARGET 143 fi 144} 145 146build_wifiiot() 147{ 148 current_xts=$1 149 current_target=$2 150 xts_root_dir="${suite_root_dir}/${current_xts}" 151 suite_out_dir="${xts_root_dir}/testcases" 152 suite_out_zip="${xts_root_dir}.zip" 153 mkdir -p $DIST_DIR 154 IFS=',' read -r -a array <<< "${current_target}" 155 echo "--------------------------------------------${array[@]}" 156 set -e 157 mkdir -p ${DIST_DIR}/json 158 for element in ${array[*]} 159 do 160 python build.py -p wifiiot_hispark_pegasus@hisilicon -f --test xts ${element} --gn-args build_xts=true 161 suite_build_target=$(echo "${element}" | awk -F "[/:]" '{print $NF}') 162 module_list_file=$suite_out_dir/module_info.json 163 suite_module_name=$(python test/xts/tools/lite/build/utils.py --method_name get_modulename_by_buildtarget --arguments module_list_file=${module_list_file}#build_target=${suite_build_target}) 164 subsystem_name=$(python test/xts/tools/lite/build/utils.py --method_name get_subsystem_name --arguments path=${element}) 165 166 python test/xts/tools/lite/build/utils.py --method_name record_testmodule_info --arguments build_target_name=${suite_module_name}#module_name=${suite_module_name}#subsystem_name=${subsystem_name}#suite_out_dir=${DIST_DIR}/json#same_file=True 167 168 mkdir -p ${suite_out_dir}/${subsystem_name} 169 cp -f ${BASE_HOME}/out/hispark_pegasus/wifiiot_hispark_pegasus/${WIFIIOT_OUTFILE} ${suite_out_dir}/${subsystem_name}/${suite_module_name}.bin 170 rm -f ${suite_out_dir}/${subsystem_name}/*.a 171 cp -rf ${xts_root_dir} ${DIST_DIR} 172 done 173 174 cp -rf ${DIST_DIR}/${current_xts} ${suite_root_dir} 175 rm -f ${suite_out_dir}/.bin 176 cp -rf ${DIST_DIR}/json/module_info.json ${suite_out_dir} 177 cd $suite_root_dir 178 rm -f ${suite_out_zip} 179 zip -rv ${suite_out_zip} ${current_xts} 180 cd $BASE_HOME 181 182} 183 184echo $BASE_HOME 185check_python 186parse_cmdline $@ 187build 188