1#!/usr/bin/env sh 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 15BASE_HOME=$(dirname $(dirname $(dirname $(dirname $(cd `dirname $0`; pwd))))) 16PRODUCT= 17PLATFORM= 18TARGET= 19TARGET_PARAM= 20XTS= 21WIFIIOT_OUTFILE=Hi3861_wifiiot_app_allinone.bin 22DIST_DIR=$BASE_HOME/dist 23WIFIIOT_ACTS_MODULES="${WIFIIOT_ACTS_MODULES},//test/xts/acts/communication_lite/lwip_hal:ActsLwipTest" 24WIFIIOT_ACTS_MODULES="${WIFIIOT_ACTS_MODULES},//test/xts/acts/communication_lite/wifiservice_hal:ActsWifiServiceTest" 25WIFIIOT_ACTS_MODULES="${WIFIIOT_ACTS_MODULES},//test/xts/acts/utils_lite/file_hal:ActsUtilsFileTest" 26WIFIIOT_ACTS_MODULES="${WIFIIOT_ACTS_MODULES},//test/xts/acts/startup_lite/syspara_hal:ActsParameterTest" 27WIFIIOT_ACTS_MODULES="${WIFIIOT_ACTS_MODULES},//test/xts/acts/iot_hardware_lite/iot_controller_hal:ActsWifiIotTest" 28WIFIIOT_ACTS_MODULES="${WIFIIOT_ACTS_MODULES},//test/xts/acts/utils_lite/kv_store_hal:ActsKvStoreTest" 29WIFIIOT_ACTS_MODULES="${WIFIIOT_ACTS_MODULES},//test/xts/acts/security_lite/huks/liteos_m_adapter:ActsHuksHalFunctionTest" 30WIFIIOT_ACTS_MODULES="${WIFIIOT_ACTS_MODULES},//test/xts/acts/hiviewdfx_lite/hilog_hal:ActsDfxFuncTest" 31WIFIIOT_ACTS_MODULES="${WIFIIOT_ACTS_MODULES},//test/xts/acts/hiviewdfx_lite/hievent_hal:ActsHieventLiteTest" 32WIFIIOT_ACTS_MODULES="${WIFIIOT_ACTS_MODULES},//test/xts/acts/distributed_schedule_lite/system_ability_manager_hal:ActsSamgrTest" 33WIFIIOT_ACTS_MODULES="${WIFIIOT_ACTS_MODULES},//test/xts/acts/update_lite/dupdate_hal:ActsUpdaterFuncTest" 34WIFIIOT_ACTS_MODULES="${WIFIIOT_ACTS_MODULES},//test/xts/acts/startup_lite/bootstrap_hal:ActsBootstrapTest" 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 while [ -n "$1" ] 77 do 78 var="$1" 79 OPTIONS=`echo ${var%%=*}` 80 PARAM=`echo ${var#*=}` 81 case "$OPTIONS" in 82 product) PRODUCT="$PARAM" 83 ;; 84 platform) PLATFORM="$PARAM" 85 ;; 86 target) TARGET="$PARAM" 87 ;; 88 xts) XTS="$PARAM" 89 ;; 90 *) usage 91 break;; 92 esac 93 shift 94 done 95 if [ "$PRODUCT" = "" ] || [ "$XTS" = "" ];then 96 usage 97 fi 98 if [ "$PRODUCT" = "wifiiot" ];then 99 PLATFORM="hi3861v100_liteos_riscv" 100 if [ "$TARGET" = "" ];then 101 if [ "$XTS" = "acts" ];then 102 TARGET=$WIFIIOT_ACTS_MODULES 103 elif [ "$XTS" = "hits" ];then 104 TARGET=$WIFIIOT_HITS_MODULES 105 fi 106 fi 107 elif [ "$PLATFORM" = "" ];then 108 echo "platform is required, for product $PRODUCT" 109 usage 110 fi 111 if [ "$TARGET" != "" ];then 112 TARGET_PARAM=" --target $TARGET" 113 fi 114} 115 116 117 118build() 119{ 120 out_dir="${BASE_HOME}/out/hispark_pegasus/wifiiot_hispark_pegasus" 121 suite_root_dir="${out_dir}/suites" 122 cd $BASE_HOME 123 if [ "$PRODUCT" = "wifiiot" ]; then 124 if [ "$XTS" = "all" ];then 125 build_wifiiot "acts" $WIFIIOT_ACTS_MODULES 126 build_wifiiot "hits" $WIFIIOT_HITS_MODULES 127 cp -rf ${DIST_DIR}/acts ${suite_root_dir} 128 cd $suite_root_dir 129 zip -rv acts.zip acts 130 rm -rf $DIST_DIR 131 else 132 build_wifiiot $XTS $TARGET 133 rm -rf $DIST_DIR 134 fi 135 else 136 python build.py ${PRODUCT}_${PLATFORM} -b debug --test xts $TARGET 137 fi 138} 139 140build_wifiiot() 141{ 142 current_xts=$1 143 current_target=$2 144 xts_root_dir="${suite_root_dir}/${current_xts}" 145 suite_out_dir="${xts_root_dir}/testcases" 146 suite_out_zip="${xts_root_dir}.zip" 147 mkdir -p $DIST_DIR 148 IFS=',' read -r -a array <<< "${current_target}" 149 echo "--------------------------------------------${array[@]}" 150 set -e 151 mkdir -p ${DIST_DIR}/json 152 for element in ${array[*]} 153 do 154 python build.py -p wifiiot_hispark_pegasus@hisilicon -f --test xts ${element} --gn-args build_xts=true 155 suite_build_target=`echo "${element}" | awk -F "[/:]" '{print $NF}'` 156 module_list_file=$suite_out_dir/module_info.json 157 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}` 158 subsystem_name=`python test/xts/tools/lite/build/utils.py --method_name get_subsystem_name --arguments path=${element}` 159 160 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 161 162 mkdir -p ${suite_out_dir}/${subsystem_name} 163 cp -f ${BASE_HOME}/out/hispark_pegasus/wifiiot_hispark_pegasus/${WIFIIOT_OUTFILE} ${suite_out_dir}/${subsystem_name}/${suite_module_name}.bin 164 rm -f ${suite_out_dir}/${subsystem_name}/*.a 165 cp -rf ${xts_root_dir} ${DIST_DIR} 166 done 167 168 cp -rf ${DIST_DIR}/${current_xts} ${suite_root_dir} 169 rm -f ${suite_out_dir}/.bin 170 cp -rf ${DIST_DIR}/json/module_info.json ${suite_out_dir} 171 cd $suite_root_dir 172 rm -f ${suite_out_zip} 173 zip -rv ${suite_out_zip} ${current_xts} 174 cd $BASE_HOME 175 176} 177 178echo $BASE_HOME 179check_python 180parse_cmdline $@ 181build 182