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" 34WIFIIOT_ACTS_MODULES="${WIFIIOT_ACTS_MODULES},//test/xts/acts/xts_lite/device_attest_lite/device_attestStart_hal:ActsDeviceAttestTest" 35 36error_report() { 37 echo "Error on line $1" 38} 39trap 'error_report $LINENO' ERR 40 41 42usage() 43{ 44 echo 45 echo "USAGE" 46 echo " ./build.sh product=PRODUCT [platform=PLATFORM] [target=TARGET] xts=XTS" 47 echo 48 echo " product : PRODUCT product name, such as ipcamera or wifiiot" 49 echo " platform : PLATFORM the platform of device" 50 echo " target : TARGET the target for build, such as //xts/acts/communication_lite/wifiaware_test." 51 echo " xts : XTS the name of xts, such as acts/hits etc." 52 echo 53 exit 1 54} 55 56check_python() 57{ 58 python_cmd="" 59 ver=$(python -c 'import platform; major, minor, patch = platform.python_version_tuple(); print(major);') 60 if [ "$ver" = "3" ];then 61 python_cmd=python 62 else 63 ver=$(python3 -c 'import platform; major, minor, patch = platform.python_version_tuple(); print(major);') 64 if [ "$ver" = "3" ];then 65 python_cmd=python3 66 fi 67 fi 68 if [ -z "$python_cmd" ];then 69 echo "Enviroment variable 'python3' is required, and python verion must be greater than 3.7" 70 exit 1 71 fi 72} 73 74parse_cmdline() 75{ 76 PLATFORM="" 77 TARGET="" 78 TARGET_PARAM="" 79 while [ -n "$1" ] 80 do 81 var="$1" 82 OPTIONS=$(echo ${var%%=*}) 83 PARAM=$(echo ${var#*=}) 84 case "$OPTIONS" in 85 product) PRODUCT="$PARAM" 86 ;; 87 platform) PLATFORM="$PARAM" 88 ;; 89 target) TARGET="$PARAM" 90 ;; 91 xts) XTS="$PARAM" 92 ;; 93 *) usage 94 break;; 95 esac 96 shift 97 done 98 if [ "$PRODUCT" = "" ] || [ "$XTS" = "" ];then 99 usage 100 fi 101 if [ "$PRODUCT" = "wifiiot" ];then 102 PLATFORM="hi3861v100_liteos_riscv" 103 if [ "$TARGET" = "" ];then 104 if [ "$XTS" = "acts" ];then 105 TARGET=$WIFIIOT_ACTS_MODULES 106 elif [ "$XTS" = "hits" ];then 107 TARGET=$WIFIIOT_HITS_MODULES 108 fi 109 fi 110 elif [ "$PLATFORM" = "" ];then 111 echo "platform is required, for product $PRODUCT" 112 usage 113 fi 114 if [ "$TARGET" != "" ];then 115 TARGET_PARAM=" --target $TARGET" 116 fi 117} 118 119 120 121build() 122{ 123 out_dir="${BASE_HOME}/out/hispark_pegasus/wifiiot_hispark_pegasus" 124 suite_root_dir="${out_dir}/suites" 125 cd $BASE_HOME 126 if [ "$PRODUCT" = "wifiiot" ]; then 127 if [ "$XTS" = "all" ];then 128 build_wifiiot "acts" $WIFIIOT_ACTS_MODULES 129 build_wifiiot "hits" $WIFIIOT_HITS_MODULES 130 cp -rf ${DIST_DIR}/acts ${suite_root_dir} 131 cd $suite_root_dir 132 zip -rv acts.zip acts 133 if [ -n "${DIST_DIR}" ]; then 134 rm -rf $DIST_DIR 135 fi 136 else 137 build_wifiiot $XTS $TARGET 138 if [ -n "${DIST_DIR}" ]; then 139 rm -rf $DIST_DIR 140 fi 141 fi 142 else 143 python build.py ${PRODUCT}_${PLATFORM} -b debug --test xts $TARGET 144 fi 145} 146 147build_wifiiot() 148{ 149 current_xts=$1 150 current_target=$2 151 xts_root_dir="${suite_root_dir}/${current_xts}" 152 suite_out_dir="${xts_root_dir}/testcases" 153 suite_out_zip="${xts_root_dir}.zip" 154 mkdir -p $DIST_DIR 155 IFS=',' read -r -a array <<< "${current_target}" 156 echo "--------------------------------------------${array[@]}" 157 set -e 158 mkdir -p ${DIST_DIR}/json 159 for element in ${array[*]} 160 do 161 python build.py -p wifiiot_hispark_pegasus@hisilicon -f --test xts ${element} --gn-args build_xts=true 162 suite_build_target=$(echo "${element}" | awk -F "[/:]" '{print $NF}') 163 module_list_file=$suite_out_dir/module_info.json 164 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}) 165 subsystem_name=$(python test/xts/tools/lite/build/utils.py --method_name get_subsystem_name --arguments path=${element}) 166 167 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 168 169 mkdir -p ${suite_out_dir}/${subsystem_name} 170 cp -f ${BASE_HOME}/out/hispark_pegasus/wifiiot_hispark_pegasus/${WIFIIOT_OUTFILE} ${suite_out_dir}/${subsystem_name}/${suite_module_name}.bin 171 rm -f ${suite_out_dir}/${subsystem_name}/*.a 172 cp -rf ${xts_root_dir} ${DIST_DIR} 173 done 174 175 cp -rf ${DIST_DIR}/${current_xts} ${suite_root_dir} 176 rm -f ${suite_out_dir}/.bin 177 cp -rf ${DIST_DIR}/json/module_info.json ${suite_out_dir} 178 cd $suite_root_dir 179 rm -f ${suite_out_zip} 180 zip -rv ${suite_out_zip} ${current_xts} 181 cd $BASE_HOME 182 183} 184 185echo $BASE_HOME 186check_python 187parse_cmdline $@ 188build 189