|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +get_id() { |
| 4 | + # Get id and name |
| 5 | + ID=`sed '/^ID=/!d;s/.*=//' $MYINFO_FILE` |
| 6 | + NAME=`sed '/^Name=/!d;s/.*=//' $MYINFO_FILE` |
| 7 | + if [[ ${#ID} -le 7 ]]; then |
| 8 | + echo "Please fill your information in myinfo.txt!!!" |
| 9 | + exit 1 |
| 10 | + fi |
| 11 | + ID="${ID##*\r}" |
| 12 | +} |
| 13 | + |
| 14 | +copy_v_file() { |
| 15 | + if [[ ! -f $OSCPU_PATH/projects/soc/vsrc/${1} ]]; then |
| 16 | + printf "Please place \e[1;31m%s\e[0m in \e[1;31m%s\e[0m.\n" ${1} $OSCPU_PATH/projects/soc/vsrc/ |
| 17 | + exit 1 |
| 18 | + fi |
| 19 | + cp $OSCPU_PATH/projects/soc/vsrc/${1} $SUBMIT_FLODER/ |
| 20 | +} |
| 21 | + |
| 22 | +check_file() { |
| 23 | + if [[ ! -f $SUBMIT_HOME/${1} ]]; then |
| 24 | + printf "Please place \e[1;31m%s\e[0m in \e[1;31m%s\e[0m.\n" ${1} $OSCPU_PATH/$SUBMIT_FLODER |
| 25 | + exit 1 |
| 26 | + fi |
| 27 | +} |
| 28 | + |
| 29 | +cpu_check() { |
| 30 | + cd $SUBMIT_HOME |
| 31 | + OUTPUT=$(echo ${ID:0-4} | python3 $OSCPU_PATH/libraries/ysyxSoC/ysyx/soc/cpu-check.py) |
| 32 | + if [[ ! $OUTPUT =~ "Your core is fine in module name and signal interface" ]]; then |
| 33 | + printf "Failed to check your module name and signal interface!!! Please modify your code according to the requirements in \e[1;31mhttps://github.com/OSCPU/ysyxSoC\e[0m.\n" |
| 34 | + exit 1 |
| 35 | + fi |
| 36 | + rm cpu-check.log |
| 37 | + cd $OSCPU_PATH |
| 38 | +} |
| 39 | + |
| 40 | +get_default_url() { |
| 41 | + git remote -v | while read line; do |
| 42 | + if [[ $line =~ "origin" ]] && [[ $line =~ "push" ]]; then |
| 43 | + echo $1 |
| 44 | + echo $line | grep -o '\ .*\ ' |
| 45 | + return |
| 46 | + fi |
| 47 | + done |
| 48 | +} |
| 49 | + |
| 50 | +push_repo() { |
| 51 | + URL="$(get_default_url $1)" |
| 52 | + |
| 53 | + printf "Enter a new URL to replace the default push URL(\e[1;34m%s\e[0m) or leave a blank to skip.\n" $URL |
| 54 | + read -p "Enter your new push URL: " -e INPUT |
| 55 | + if [[ -n "$INPUT" ]] && [[ ! $INPUT == $URL ]]; then |
| 56 | + git remote set-url --push origin $INPUT |
| 57 | + else |
| 58 | + INPUT=$URL |
| 59 | + fi |
| 60 | + |
| 61 | + git commit -m "dc & vcs" --no-verify --allow-empty 1>/dev/null 2>&1 |
| 62 | + |
| 63 | + git push origin |
| 64 | + if [ $? -ne 0 ]; then |
| 65 | + printf "\e[1;31mFailed to push!!!\e[0m\n" |
| 66 | + exit 1 |
| 67 | + fi |
| 68 | + |
| 69 | + printf "You repo has been pushed to \e[1;32m%s\e[0m.\n" $INPUT |
| 70 | +} |
| 71 | + |
| 72 | + |
| 73 | +OSCPU_PATH=$(dirname $(readlink -f "$0")) |
| 74 | +SUBMIT_FLODER="submit" |
| 75 | +SUBMIT_HOME=$OSCPU_PATH/$SUBMIT_FLODER |
| 76 | +WARNGING_FILE="Verilator中Warning无法清理说明.xlsx" |
| 77 | +MYINFO_FILE=$OSCPU_PATH"/myinfo.txt" |
| 78 | + |
| 79 | +get_id |
| 80 | +printf "Read ID \e[1;32m%s\e[0m from myinfo.txt\n" $ID |
| 81 | + |
| 82 | +PREFIX="ysyx_${ID:0-6}" |
| 83 | +V_FILE=$PREFIX".v" |
| 84 | +PDF_FILE=$PREFIX".pdf" |
| 85 | + |
| 86 | +check_file $WARNGING_FILE |
| 87 | +check_file $PREFIX".pdf" |
| 88 | +copy_v_file $PREFIX".v" |
| 89 | + |
| 90 | +cpu_check |
| 91 | +push_repo |
0 commit comments