-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.sh
executable file
·143 lines (128 loc) · 2.32 KB
/
demo.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/sh
# Do not compile Go;
NO_GO=
NO_RE=
NO_TEST=
# Get current directory;
CURRENT=`pwd`
# Packages that needed to be partly recompiled;
BUILD_PKG="runtime\
sync/atomic\
sync\
syscall\
os\
io\
unicode\
utf8\
bytes\
math\
strings\
strconv\
reflect\
fmt\
sort\
container/heap\
path/filepath\
io/ioutil\
time\
flag\
bufio\
container/ring\
container/vector\
template\
rand\
cmath"
while
test $1
do
case $1 in
--help)
echo "parameters:"
echo " -ng: Do not compile the entire Go"
echo " -nre: Do not recompile packages of Go"
echo " -ntest: Do not compile test cases"
exit
;;
-ng)
NO_GO=1
;;
-nre)
NO_RE=1
;;
-ntest)
NO_TEST=1
;;
*)
echo "'$1' not recognized."
exit
;;
esac
shift
done
if ! test $NO_GO
then
# Compile Go;
cd "$CURRENT/src/go/src/"
./all.bash
fi
# Set necessary environment;
export GOOS=ucore
export GOROOT=$CURRENT/src/go
export PATH=$PATH:$GOROOT/bin
if ! test $NO_RE
then
# Recompile packages partly for each one;
# Patch Go with our work;
cp "$CURRENT/patch/src/" "$CURRENT/src/go/" -R
for i in $BUILD_PKG
do
echo "[Building "$i"]"
cd "$GOROOT/src/pkg/$i"
make clean
make install
done
# Recompile linker for a ucore target;
cd "$CURRENT/src/go/src/cmd/8l/"
make clean
make install
fi
if ! test $NO_TEST
then
# Compile test cases;
# Copy to disk0;
rm -f -r "$CURRENT/src/ucore/disk0/testsuit/"
cp "$CURRENT/testsuit/" "$CURRENT/src/ucore/disk0/" -R
# Get all directories;
cd "$CURRENT/src/ucore/disk0/testsuit/"
rm -f -r *.out *.8 *.s testall.sh
TEST_DIRS=`find -type d`
# Get all test cases;
for i in $TEST_DIRS
do
# Enter one directory;
CURRENT_TEST_DIR=`readlink -f "$CURRENT/src/ucore/disk0/testsuit/$i"`
cd "$CURRENT_TEST_DIR"
if test -e Makefile
then
# Makefile exists, compile with it;
make all
make clean
else
# Makefile missing, compile each by default;
# Get cases in current directory;
TEST_SUIT=`ls *.go 2>/dev/null | sed s'/.go//g'`
for j in $TEST_SUIT
do
echo "[Testsuit] $j.go"
echo "./$j.out" >> testall.sh
8g "$j.go"
8l -o "$j.out" "$j.8"
rm "$j.8" "$j.go"
done
fi
rm -f "$CURRENT/src/ucore/bin/fs.img"
done
fi
# Now start ucore;
cd "$CURRENT/src/ucore/"
make qemu