1+ #! /bin/bash
2+
3+ # to print the color in terminal
4+ INFO=" \033[0;33m"
5+ ERROR=" \033[0;31m"
6+ RIGHT=" \033[0;32m"
7+ END=" \033[0m"
8+
9+ # if not have content, create, otherwise check
10+ configContent () {
11+ cd $1
12+ # pwd
13+ echo -e " ${INFO} check Makefile...${END} "
14+ if [[ -f " Makefile" ]]; then
15+ echo -e " ${RIGHT} Makefile exist!${END} "
16+ else
17+ echo -e " ${INFO} no exist${END} "
18+ echo " start config Makefile..."
19+ echo " sim-verilog:" > Makefile
20+ echo -e " ${RIGHT} config[SUCCESSFUL]${END} "
21+ fi
22+
23+ echo -e " ${INFO} check source dir...${END} "
24+ if [[ -d " src" ]]; then
25+ echo -e " ${RIGHT} src exist!${END} "
26+ else
27+ echo -e " ${INFO} no exist${END} "
28+ echo " start generate dir..."
29+ mkdir -p src/main/csrc
30+ mkdir -p src/main/scala/axi4
31+ mkdir -p src/main/scala/common
32+ mkdir -p src/main/scala/core
33+ mkdir -p src/main/scala/port
34+ mkdir -p src/main/scala/top
35+ mkdir -p src/main/scala/utils
36+ echo -e " ${RIGHT} generate src dir[SUCCESSFUL]${END} "
37+ fi
38+
39+ echo -e " ${INFO} check difftest file...${END} "
40+ if [[ -f " src/main/scala/utils/Difftest.scala" ]]; then
41+ echo -e " ${RIGHT} Difftest.scala exist!${END} "
42+ else
43+ echo -e " ${INFO} no exist${END} "
44+ echo " start generate Difftest.scala..."
45+ cp ../dependency/difftest/src/main/scala/Difftest.scala src/main/scala/utils/Difftest.scala
46+ echo -e " ${RIGHT} generate Difftest.scala[SUCCESSFUL]${END} "
47+ fi
48+
49+ echo -e " ${INFO} check module prefix file...${END} "
50+ if [[ -f " src/main/scala/utils/AddModulePrefix.scala" ]]; then
51+ echo -e " ${RIGHT} AddModulePrefix.scala exist!${END} "
52+ else
53+ echo -e " ${INFO} no exist${END} "
54+ echo " start generate AddModulePrefix.scala..."
55+ cp ../tc_l2/src/main/scala/utils/AddModulePrefix.scala src/main/scala/utils/AddModulePrefix.scala
56+ echo -e " ${RIGHT} generate AddModulePrefix.scala[SUCCESSFUL]${END} "
57+ fi
58+ }
59+
60+ configTemplate () {
61+ if [[ -d $1 ]]; then
62+ echo -e " ${RIGHT} $1 exist!${END} "
63+ else
64+ mkdir $1
65+ echo -e " ${INFO} [no exist]: config project...${END} "
66+ fi
67+
68+ configContent $1
69+ }
70+
71+ configTarget () {
72+ # HACK: need to make one check statement
73+ if [[ -n $1 && $1 == " tc_l3" ]]; then
74+ configTemplate $1
75+ elif [[ -n $1 && $1 == " tc_l4" ]]; then
76+ configTemplate $1
77+ else
78+ configTemplate " tc_l1" # include other error parameters condition
79+ fi
80+ }
81+
82+ helpInfo () {
83+ echo -e " ${INFO} Usage: setup.sh [-t target][-h]${END} "
84+ echo -e " Description - set up the template dir env of the treecore riscv processor"
85+ echo -e " "
86+ echo -e " ${RIGHT} -t: config specific target directory structure${END} "
87+ echo -e " sample: ./setup.sh -t [target](default: tc_l1) ${INFO} [target]: [tc_l1, tc_l2, tc_l3, ...]${END} "
88+ echo -e " ${RIGHT} -h: help information${END} "
89+ }
90+
91+ while getopts ' t:h' OPT; do
92+ case $OPT in
93+ t) configTarget $OPTARG ;;
94+ h) helpInfo;;
95+ ? )
96+ echo -e " ${ERROR} invalid parameters!!!${END} "
97+ helpInfo
98+ ;;
99+ esac
100+ done
0 commit comments