Skip to content

Commit feda78e

Browse files
fjlkaralabe
authored andcommitted
build: remove env.sh (#20541)
* build: remove env.sh This removes the dirty symlink-to-self hack we've had for years. The script was added to enable building without GOPATH and did that job reliably for all this time. We can remove the workaround because modern Go supports building without GOPATH natively. * Makefile: add GO111MODULE=on to environment
1 parent 8592a57 commit feda78e

File tree

5 files changed

+25
-73
lines changed

5 files changed

+25
-73
lines changed

Makefile

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,34 @@
1010

1111
GOBIN = ./build/bin
1212
GO ?= latest
13+
GORUN = env GO111MODULE=on go run
1314

1415
geth:
15-
build/env.sh go run build/ci.go install ./cmd/geth
16+
$(GORUN) build/ci.go install ./cmd/geth
1617
@echo "Done building."
1718
@echo "Run \"$(GOBIN)/geth\" to launch geth."
1819

1920
all:
20-
build/env.sh go run build/ci.go install
21+
$(GORUN) build/ci.go install
2122

2223
android:
23-
build/env.sh go run build/ci.go aar --local
24+
$(GORUN) build/ci.go aar --local
2425
@echo "Done building."
2526
@echo "Import \"$(GOBIN)/geth.aar\" to use the library."
2627

2728
ios:
28-
build/env.sh go run build/ci.go xcode --local
29+
$(GORUN) build/ci.go xcode --local
2930
@echo "Done building."
3031
@echo "Import \"$(GOBIN)/Geth.framework\" to use the library."
3132

3233
test: all
33-
build/env.sh go run build/ci.go test
34+
$(GORUN) build/ci.go test
3435

3536
lint: ## Run linters.
36-
build/env.sh go run build/ci.go lint
37+
$(GORUN) build/ci.go lint
3738

3839
clean:
39-
go clean -cache
40+
env GO111MODULE=on go clean -cache
4041
rm -fr build/_workspace/pkg/ $(GOBIN)/*
4142

4243
# The devtools target installs tools required for 'go generate'.
@@ -63,12 +64,12 @@ geth-linux: geth-linux-386 geth-linux-amd64 geth-linux-arm geth-linux-mips64 get
6364
@ls -ld $(GOBIN)/geth-linux-*
6465

6566
geth-linux-386:
66-
build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/386 -v ./cmd/geth
67+
$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=linux/386 -v ./cmd/geth
6768
@echo "Linux 386 cross compilation done:"
6869
@ls -ld $(GOBIN)/geth-linux-* | grep 386
6970

7071
geth-linux-amd64:
71-
build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/amd64 -v ./cmd/geth
72+
$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=linux/amd64 -v ./cmd/geth
7273
@echo "Linux amd64 cross compilation done:"
7374
@ls -ld $(GOBIN)/geth-linux-* | grep amd64
7475

@@ -77,42 +78,42 @@ geth-linux-arm: geth-linux-arm-5 geth-linux-arm-6 geth-linux-arm-7 geth-linux-ar
7778
@ls -ld $(GOBIN)/geth-linux-* | grep arm
7879

7980
geth-linux-arm-5:
80-
build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/arm-5 -v ./cmd/geth
81+
$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=linux/arm-5 -v ./cmd/geth
8182
@echo "Linux ARMv5 cross compilation done:"
8283
@ls -ld $(GOBIN)/geth-linux-* | grep arm-5
8384

8485
geth-linux-arm-6:
85-
build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/arm-6 -v ./cmd/geth
86+
$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=linux/arm-6 -v ./cmd/geth
8687
@echo "Linux ARMv6 cross compilation done:"
8788
@ls -ld $(GOBIN)/geth-linux-* | grep arm-6
8889

8990
geth-linux-arm-7:
90-
build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/arm-7 -v ./cmd/geth
91+
$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=linux/arm-7 -v ./cmd/geth
9192
@echo "Linux ARMv7 cross compilation done:"
9293
@ls -ld $(GOBIN)/geth-linux-* | grep arm-7
9394

9495
geth-linux-arm64:
95-
build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/arm64 -v ./cmd/geth
96+
$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=linux/arm64 -v ./cmd/geth
9697
@echo "Linux ARM64 cross compilation done:"
9798
@ls -ld $(GOBIN)/geth-linux-* | grep arm64
9899

99100
geth-linux-mips:
100-
build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/mips --ldflags '-extldflags "-static"' -v ./cmd/geth
101+
$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=linux/mips --ldflags '-extldflags "-static"' -v ./cmd/geth
101102
@echo "Linux MIPS cross compilation done:"
102103
@ls -ld $(GOBIN)/geth-linux-* | grep mips
103104

104105
geth-linux-mipsle:
105-
build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/mipsle --ldflags '-extldflags "-static"' -v ./cmd/geth
106+
$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=linux/mipsle --ldflags '-extldflags "-static"' -v ./cmd/geth
106107
@echo "Linux MIPSle cross compilation done:"
107108
@ls -ld $(GOBIN)/geth-linux-* | grep mipsle
108109

109110
geth-linux-mips64:
110-
build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/mips64 --ldflags '-extldflags "-static"' -v ./cmd/geth
111+
$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=linux/mips64 --ldflags '-extldflags "-static"' -v ./cmd/geth
111112
@echo "Linux MIPS64 cross compilation done:"
112113
@ls -ld $(GOBIN)/geth-linux-* | grep mips64
113114

114115
geth-linux-mips64le:
115-
build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/mips64le --ldflags '-extldflags "-static"' -v ./cmd/geth
116+
$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=linux/mips64le --ldflags '-extldflags "-static"' -v ./cmd/geth
116117
@echo "Linux MIPS64le cross compilation done:"
117118
@ls -ld $(GOBIN)/geth-linux-* | grep mips64le
118119

@@ -121,12 +122,12 @@ geth-darwin: geth-darwin-386 geth-darwin-amd64
121122
@ls -ld $(GOBIN)/geth-darwin-*
122123

123124
geth-darwin-386:
124-
build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=darwin/386 -v ./cmd/geth
125+
$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=darwin/386 -v ./cmd/geth
125126
@echo "Darwin 386 cross compilation done:"
126127
@ls -ld $(GOBIN)/geth-darwin-* | grep 386
127128

128129
geth-darwin-amd64:
129-
build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=darwin/amd64 -v ./cmd/geth
130+
$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=darwin/amd64 -v ./cmd/geth
130131
@echo "Darwin amd64 cross compilation done:"
131132
@ls -ld $(GOBIN)/geth-darwin-* | grep amd64
132133

@@ -135,11 +136,11 @@ geth-windows: geth-windows-386 geth-windows-amd64
135136
@ls -ld $(GOBIN)/geth-windows-*
136137

137138
geth-windows-386:
138-
build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=windows/386 -v ./cmd/geth
139+
$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=windows/386 -v ./cmd/geth
139140
@echo "Windows 386 cross compilation done:"
140141
@ls -ld $(GOBIN)/geth-windows-* | grep 386
141142

142143
geth-windows-amd64:
143-
build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=windows/amd64 -v ./cmd/geth
144+
$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=windows/amd64 -v ./cmd/geth
144145
@echo "Windows amd64 cross compilation done:"
145146
@ls -ld $(GOBIN)/geth-windows-* | grep amd64

build/ci.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,9 @@ func doInstall(cmdline []string) {
214214
var minor int
215215
fmt.Sscanf(strings.TrimPrefix(runtime.Version(), "go1."), "%d", &minor)
216216

217-
if minor < 9 {
217+
if minor < 11 {
218218
log.Println("You have Go version", runtime.Version())
219-
log.Println("go-ethereum requires at least Go version 1.9 and cannot")
219+
log.Println("go-ethereum requires at least Go version 1.11 and cannot")
220220
log.Println("be compiled with an earlier version. Please upgrade your Go installation.")
221221
os.Exit(1)
222222
}
@@ -237,13 +237,6 @@ func doInstall(cmdline []string) {
237237
build.MustRun(goinstall)
238238
return
239239
}
240-
// If we are cross compiling to ARMv5 ARMv6 or ARMv7, clean any previous builds
241-
if *arch == "arm" {
242-
os.RemoveAll(filepath.Join(runtime.GOROOT(), "pkg", runtime.GOOS+"_arm"))
243-
for _, path := range filepath.SplitList(build.GOPATH()) {
244-
os.RemoveAll(filepath.Join(path, "pkg", runtime.GOOS+"_arm"))
245-
}
246-
}
247240

248241
// Seems we are cross compiling, work around forbidden GOBIN
249242
goinstall := goToolArch(*arch, *cc, "install", buildFlags(env)...)
@@ -294,7 +287,6 @@ func goTool(subcmd string, args ...string) *exec.Cmd {
294287

295288
func goToolArch(arch string, cc string, subcmd string, args ...string) *exec.Cmd {
296289
cmd := build.GoTool(subcmd, args...)
297-
cmd.Env = []string{"GOPATH=" + build.GOPATH()}
298290
if arch == "" || arch == runtime.GOARCH {
299291
cmd.Env = append(cmd.Env, "GOBIN="+GOBIN)
300292
} else {
@@ -888,7 +880,6 @@ func gomobileTool(subcmd string, args ...string) *exec.Cmd {
888880
cmd := exec.Command(filepath.Join(GOBIN, "gomobile"), subcmd)
889881
cmd.Args = append(cmd.Args, args...)
890882
cmd.Env = []string{
891-
"GOPATH=" + build.GOPATH(),
892883
"PATH=" + GOBIN + string(os.PathListSeparator) + os.Getenv("PATH"),
893884
}
894885
for _, e := range os.Environ() {
@@ -1078,7 +1069,6 @@ func xgoTool(args []string) *exec.Cmd {
10781069
cmd := exec.Command(filepath.Join(GOBIN, "xgo"), args...)
10791070
cmd.Env = os.Environ()
10801071
cmd.Env = append(cmd.Env, []string{
1081-
"GOPATH=" + build.GOPATH(),
10821072
"GOBIN=" + GOBIN,
10831073
}...)
10841074
return cmd

build/deb/ethereum/deb.rules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ override_dh_auto_build:
2222
(mkdir -p build/_workspace/pkg/mod && mv .mod/* build/_workspace/pkg/mod)
2323

2424
# A fresh Go was built, all dependency downloads faked, hope build works now
25-
build/env.sh ../.go/bin/go run build/ci.go install -git-commit={{.Env.Commit}} -git-branch={{.Env.Branch}} -git-tag={{.Env.Tag}} -buildnum={{.Env.Buildnum}} -pull-request={{.Env.IsPullRequest}}
25+
../.go/bin/go run build/ci.go install -git-commit={{.Env.Commit}} -git-branch={{.Env.Branch}} -git-tag={{.Env.Tag}} -buildnum={{.Env.Buildnum}} -pull-request={{.Env.IsPullRequest}}
2626

2727
override_dh_auto_test:
2828

build/env.sh

Lines changed: 0 additions & 30 deletions
This file was deleted.

internal/build/util.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,6 @@ func MustRunCommand(cmd string, args ...string) {
5151
MustRun(exec.Command(cmd, args...))
5252
}
5353

54-
// GOPATH returns the value that the GOPATH environment
55-
// variable should be set to.
56-
func GOPATH() string {
57-
if os.Getenv("GOPATH") == "" {
58-
log.Fatal("GOPATH is not set")
59-
}
60-
return os.Getenv("GOPATH")
61-
}
62-
6354
var warnedAboutGit bool
6455

6556
// RunGit runs a git subcommand and returns its output.

0 commit comments

Comments
 (0)