This repository has been archived by the owner on Jul 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
/
run
executable file
·99 lines (88 loc) · 3.4 KB
/
run
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
#!/bin/bash
echo DONE WITH THIS
exit 0
set -e
eval $(go env)
export GOROOT
go install
rm -f c2go
rm -f $GOROOT/src/liblink/sched9.c # implement 'build ignore' comment
rm -f $GOROOT/src/cmd/gc/mkbuiltin1.c $GOROOT/src/cmd/gc/y.tab.c # implement 'build ignore' comment
dst=$GOROOT # !!!
cp $dst/src/cmd/internal/obj/zbootstrap.go /tmp
trap "mkdir -p $dst/src/cmd/internal/obj && cp /tmp/zbootstrap.go $dst/src/cmd/internal/obj && cd $dst/src/cmd/gc && git checkout HEAD mkbuiltin1.c y.tab.c" 0
rm -rf $dst/src/cmd/internal/obj $dst/src/cmd/internal/gc* $dst/src/cmd/new?g ## $dst/src/cmd/internal/ld* $dst/src/cmd/new?l
for i in 6 5 8 9
do
## rm -rf $dst/src/cmd/internal/obj $dst/src/cmd/internal/ld
## c2go -c c2go.cfg -dst $dst -I $GOROOT/include -I $GOROOT/src/cmd/${i}g $GOROOT/src/liblink/*.c $GOROOT/src/cmd/ld/*.c $GOROOT/src/cmd/${i}l/*.c
## mv $dst/src/cmd/internal/ld $dst/src/cmd/internal/ld.$i
rm -rf $dst/src/cmd/internal/obj $dst/src/cmd/internal/gc
c2go -c c2go.cfg -dst $dst -I $GOROOT/include -I $GOROOT/src/cmd/${i}g $GOROOT/src/liblink/*.c $GOROOT/src/cmd/gc/*.c $GOROOT/src/cmd/${i}g/*.c
mv $dst/src/cmd/internal/gc $dst/src/cmd/internal/gc.$i
done
mv $dst/src/cmd/internal/gc.6 $dst/src/cmd/internal/gc
## mv $dst/src/cmd/internal/ld.6 $dst/src/cmd/internal/ld
rm -rf $dst/src/cmd/internal/gc.? ## $dst/src/cmd/internal/ld.?
cp /tmp/zbootstrap.go $dst/src/cmd/internal/obj
for i in add/obj/*.go; do
base=$(echo $i | sed 's;.*/;;')
cat $i | grep -v 'build ignore' >$dst/src/cmd/internal/obj/$base
done
for i in add/obj/*/*.go; do
base=$(echo $i | sed 's;add/obj/;;')
cat $i | grep -v 'build ignore' >$dst/src/cmd/internal/obj/$base
done
for i in add/gc/*.*; do
base=$(echo $i | sed 's;.*/;;')
cat $i | grep -v 'build ignore' >$dst/src/cmd/internal/gc/$base
done
for i in add/new{5,6,8,9}g/*.go; do
base=$(echo $i | sed 's;add/;;')
cat $i | grep -v 'build ignore' >$dst/src/cmd/$base
done
##for i in add/new6{g,l}/*.go; do
## base=$(echo $i | sed 's;add/;;')
## cat $i | grep -v 'build ignore' >$dst/src/cmd/$base
##done
##for i in add/ld/*.go; do
## base=$(echo $i | sed 's;.*/;;')
## cat $i | grep -v 'build ignore' >$dst/src/cmd/internal/ld/$base
##done
rm $dst/src/cmd/internal/gc/{yerr.go,y.tab.go}
(cd $dst/src/cmd/internal/gc && go tool yacc go.y)
rm $dst/src/cmd/internal/obj/bio.go
gofmt -w $dst/src/cmd/internal/obj # check for syntax errors, mainly
rm -rf /tmp/c2gomain
mv $dst/src/main /tmp/c2gomain
export GOPATH=""
goimports -w $dst/src/cmd/new* $dst/src/cmd/internal
wc $(find $dst/src/cmd/{internal/obj,internal/gc,new?g,new?l} -type f -a -name '*.go')
go install -gcflags -e cmd/internal/obj... cmd/objwriter cmd/internal/gc cmd/new{5,6,8,9}{a,g} ## cmd/new{5,6,8,9}{a,g,l}
go tool new6g ~/g/go/test/helloworld.go
go tool 6l helloworld.6
./6.out
GOARCH=386 go tool new8g ~/g/go/test/helloworld.go
GOARCH=386 go tool 8l helloworld.8
./8.out
for i in 5g 6g 8g 9g
do
cp $(which new$i) $(toolstash -n $i)
done
exit 0
GOOBJ=2 go tool 6g ~/g/go/test/helloworld.go
GOOBJ=2 go build -work -a strings
go tool dist install cmd/{5,6,8,9}{a,g,l}
for arch in ppc64 ppc64le 386 amd64 amd64p32 arm
do
os=linux
if [ "$arch" = "amd64p32" ]; then
os=nacl
fi
echo $os/$arch
GOOS=$os GOARCH=$arch go tool dist install runtime
GOOBJ=2 GOOS=$os GOARCH=$arch go build -a std
done
# Edit ,s/(if\(.*\))\n(.*;)\n( *)else\n(.*;)/\1 {\n\2\n\3} else {\n\4\n\3}/g
# Edit ,s/( *)(if\(.*\))\n(.*;)\n/\1\2 {\n\3\n\1}\n/g
# Edit ,s/'\\0'/'\\x00'/g