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