-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathrunsim.sh
executable file
·40 lines (39 loc) · 1.06 KB
/
runsim.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
function need_make(){
local CUR_DIR="$(pwd)"
cd $1
make -q
local RESULT=$?
(cd $CUR_DIR)
echo $RESULT
}
if [[ -f /.dockerenv ]]; then
NEED_MAKE=$(need_make /code/riscv-sim )
EXEC_FILE="/code/riscv-sim/bin/riscv-console-sim"
if [ $NEED_MAKE -ne "0" ]; then
CUR_DIR="$(pwd)"
MAKE_CMD="cd /code/riscv-sim && make clean && make && cd $CUR_DIR"
echo $MAKE_CMD
( cd /code/riscv-sim && make clean && make && cd $CUR_DIR )
if [ $? -ne 0 ]; then
exit
fi
fi
SIM_RUN_CMD="runuser -u docker $EXEC_FILE -- $@"
echo $SIM_RUN_CMD
$SIM_RUN_CMD
else
NEED_MAKE=$(need_make ./riscv-sim )
EXEC_FILE="./riscv-sim/bin/riscv-console-sim"
if [ $NEED_MAKE -ne "0" ]; then
CUR_DIR="$(pwd)"
MAKE_CMD="cd ./riscv-sim && make clean && make && cd $CUR_DIR"
echo $MAKE_CMD
(cd ./riscv-sim && make clean && make && cd $CUR_DIR)
if [ $? -ne 0 ]; then
exit
fi
fi
echo "$EXEC_FILE" "$@"
$EXEC_FILE "$@"
fi