1#!/bin/bash 2# Copyright (c) 2021-2022 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 16TOP=$(pwd) 17CMD=${TOP}/panda/isa/gen.rb 18ISA_DATA=${TOP}/panda/isa/isa.yaml 19ISA_REQUIRE=${TOP}/panda/isa/isapi.rb 20 21# generated file with multiple template files 22# getopts: 23# -O: output directory 24# -D: date file 25# -R: require files 26# -I: use ISA_DATA, ISA_REQUIRE as default 27 28if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi 29 30while getopts "O:D:R:I" arg 31do 32 case "$arg" in 33 O) 34 OUTPUT=${OPTARG} 35 ;; 36 D) 37 DATA=${OPTARG} 38 ;; 39 R) 40 REQUIRE=${OPTARG} 41 ;; 42 I) 43 HAS_ISA=true 44 ;; 45 *) 46 echo "unkonw argument" 47 exit 1 48 ;; 49 esac 50done 51shift $(($OPTIND - 1)) 52 53if [ "${HAS_ISA}" ];then 54 DATA=${ISA_DATA} 55 REQUIRE=${ISA_REQUIRE},${REQUIRE} 56fi 57 58for TEMPLATE_ARG in "$@" 59do 60 TARGET_FILE=$(basename $TEMPLATE_ARG .erb) 61 ${CMD} --template ${TEMPLATE_ARG} --data ${DATA} --output ${OUTPUT}/${TARGET_FILE} --require ${REQUIRE} 62done 63