1#!/bin/bash 2 3# Copyright (C) 2021 Huawei Device Co., Ltd. 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16set -e 17 18parse_target_subsystem() 19{ 20 XTS_HOME=$(dirname $(cd $(dirname $0); pwd)) 21 BASE_HOME=${XTS_HOME}/../.. 22 target_subsystem_config=${XTS_HOME}/tools/config/precise_compilation.json 23 xts_enter_config=${BASE_HOME}/.repo/manifests/matrix_product.csv 24 xts_targets="" 25 repositorys=$1 26 match_status=true 27 repo_lst=($(echo $repositorys | tr "," "\n")) 28 row=dayu200_xts 29 row_number=$(awk -F',' -v target="$row" 'NR==1{for(i=1;i<=NF;i++){if($i==target){print i;exit}}}' "$xts_enter_config") 30 for repo in "${repo_lst[@]}" 31 do 32 echo $repo 33 # 是否配置xts门禁,若无,跳过 34 line_number=$(awk -F',' -v target="$repo" '$1 == target {print NR}' "$xts_enter_config") 35 content=$(awk -F',' -v c=$row_number -v r=$line_number 'NR==r {print $c}' "$xts_enter_config") 36 echo $content 37 if [ ! "$content" = "Y" ]||[ -z "$content" ]; then 38 continue 39 fi 40 # 仓名映射target名 41 jq_cmd="cat $target_subsystem_config | jq -r '.[] | select( .name == \"${repo}\") | .buildTarget'" 42 xts_target=$(eval $jq_cmd) 43 if [[ -z "${xts_target}" ]];then 44 match_status=false 45 fi 46 # precise_compilation.json匹配到的才添加,数组中不存在才添加(去重) 47 if [[ -n "${xts_target}" && !("$xts_targets" =~ "$xts_target") ]];then 48 xts_targets+="$xts_target," 49 fi 50 done 51 # 去掉末尾, 52 xts_targets=$(echo "$xts_targets" | sed 's/,$//') 53 echo "xts_targets: $xts_targets" 54} 55 56define_cache_type() { 57 echo $CACHE_TYPE 58} 59define_cache_type 60 61parse_args() 62{ 63 while [ -n "$1" ] 64 do 65 var="$1" 66 OPTIONS=${var%%=*} 67 PARAM=${var#*=} 68 if [[ "$OPTIONS" == "cache_type" && "$PARAM" != "$OPTIONS" ]]; then 69 CACHE_TYPE="$PARAM" 70 fi 71 shift 72 done 73} 74 75pr_list=$1 76shift 77remaining_params=$@ 78 79do_make() 80{ 81 cd $BASE_HOME 82 if [[ "${match_status}" == false || "$xts_targets" =~ "xts_acts" ]];then 83 if [ -z "$CACHE_TYPE" ]; then 84 ./test/xts/acts/build.sh product_name=rk3568 system_size=standard $remaining_params 85 else 86 ./test/xts/acts/build.sh product_name=rk3568 system_size=standard $remaining_params cache_type=$CACHE_TYPE 87 fi 88 else 89 if [ -z "$CACHE_TYPE" ]; then 90 ./test/xts/acts/build.sh product_name=rk3568 system_size=standard suite=${xts_targets} $remaining_params 91 else 92 ./test/xts/acts/build.sh product_name=rk3568 system_size=standard suite=${xts_targets} $remaining_params cache_type=$CACHE_TYPE 93 fi 94 fi 95} 96echo $@ 97parse_target_subsystem $pr_list 98if [ $# -eq 0 ];then 99 echo "no args; pass cache deal" 100else 101 parse_args $@ 102fi 103do_make 104exit 0 105