Makefile, build: remove unused xgo (#1812)

This commit is contained in:
Daniel Liu 2025-12-08 15:28:22 +08:00 committed by GitHub
parent 67df2bcb29
commit 8c42c02bde
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 1 additions and 126 deletions

View file

@ -2,9 +2,7 @@
# with Go source code. If you know what GOPATH is then you probably
# don't need to bother with make.
.PHONY: XDC XDC-cross evm all test clean
.PHONY: XDC-linux XDC-linux-386 XDC-linux-amd64 XDC-linux-mips64 XDC-linux-mips64le
.PHONY: XDC-darwin XDC-darwin-386 XDC-darwin-amd64
.PHONY: XDC evm all test clean
GOBIN = $(shell pwd)/build/bin
GO ?= 1.25.1
@ -94,62 +92,3 @@ help: Makefile
@echo ''
@echo 'Targets:'
@sed -n 's/^#?//p' $< | column -t -s ':' | sort | sed -e 's/^/ /'
# Cross Compilation Targets (xgo)
XDC-cross: XDC-windows-amd64 XDC-darwin-amd64 XDC-linux
@echo "Full cross compilation done:"
@ls -ld $(GOBIN)/XDC-*
XDC-linux: XDC-linux-386 XDC-linux-amd64 XDC-linux-mips64 XDC-linux-mips64le
@echo "Linux cross compilation done:"
@ls -ld $(GOBIN)/XDC-linux-*
XDC-linux-386:
go run build/ci.go xgo -- --go=$(GO) --targets=linux/386 -v ./cmd/XDC
@echo "Linux 386 cross compilation done:"
@ls -ld $(GOBIN)/XDC-linux-* | grep 386
XDC-linux-amd64:
go run build/ci.go xgo -- --go=$(GO) --targets=linux/amd64 -v ./cmd/XDC
@echo "Linux amd64 cross compilation done:"
@ls -ld $(GOBIN)/XDC-linux-* | grep amd64
XDC-linux-mips:
go run build/ci.go xgo -- --go=$(GO) --targets=linux/mips --ldflags '-extldflags "-static"' -v ./cmd/XDC
@echo "Linux MIPS cross compilation done:"
@ls -ld $(GOBIN)/XDC-linux-* | grep mips
XDC-linux-mipsle:
go run build/ci.go xgo -- --go=$(GO) --targets=linux/mipsle --ldflags '-extldflags "-static"' -v ./cmd/XDC
@echo "Linux MIPSle cross compilation done:"
@ls -ld $(GOBIN)/XDC-linux-* | grep mipsle
XDC-linux-mips64:
go run build/ci.go xgo -- --go=$(GO) --targets=linux/mips64 --ldflags '-extldflags "-static"' -v ./cmd/XDC
@echo "Linux MIPS64 cross compilation done:"
@ls -ld $(GOBIN)/XDC-linux-* | grep mips64
XDC-linux-mips64le:
go run build/ci.go xgo -- --go=$(GO) --targets=linux/mips64le --ldflags '-extldflags "-static"' -v ./cmd/XDC
@echo "Linux MIPS64le cross compilation done:"
@ls -ld $(GOBIN)/XDC-linux-* | grep mips64le
XDC-darwin: XDC-darwin-386 XDC-darwin-amd64
@echo "Darwin cross compilation done:"
@ls -ld $(GOBIN)/XDC-darwin-*
XDC-darwin-386:
go run build/ci.go xgo -- --go=$(GO) --targets=darwin/386 -v ./cmd/XDC
@echo "Darwin 386 cross compilation done:"
@ls -ld $(GOBIN)/XDC-darwin-* | grep 386
XDC-darwin-amd64:
go run build/ci.go xgo -- --go=$(GO) --targets=darwin/amd64 -v ./cmd/XDC
@echo "Darwin amd64 cross compilation done:"
@ls -ld $(GOBIN)/XDC-darwin-* | grep amd64
XDC-windows-amd64:
go run build/ci.go xgo -- --go=$(GO) -buildmode=mode -x --targets=windows/amd64 -v ./cmd/XDC
@echo "Windows amd64 cross compilation done:"
@ls -ld $(GOBIN)/XDC-windows-* | grep amd64

View file

@ -105,8 +105,6 @@ func main() {
doGenerate()
case "baddeps":
doBadDeps()
case "xgo":
doXgo(os.Args[2:])
default:
log.Fatal("unknown command ", os.Args[1])
}
@ -529,55 +527,3 @@ func downloadProtoc(cachedir string) string {
}
return extractDest
}
// Cross compilation
func doXgo(cmdline []string) {
var (
alltools = flag.Bool("alltools", false, `Flag whether we're building all known tools, or only on in particular`)
)
flag.CommandLine.Parse(cmdline)
env := build.Env()
// Make sure xgo is available for cross compilation
tc := build.GoToolchain{}
gogetxgo := tc.Go("get", "github.com/karalabe/xgo")
build.MustRun(gogetxgo)
// If all tools building is requested, build everything the builder wants
args := append(buildFlags(env, false, nil), flag.Args()...)
if *alltools {
args = append(args, []string{"--dest", GOBIN}...)
for _, res := range allToolsArchiveFiles {
if strings.HasPrefix(res, GOBIN) {
// Binary tool found, cross build it explicitly
args = append(args, "./"+filepath.Join("cmd", filepath.Base(res)))
xgo := xgoTool(args)
build.MustRun(xgo)
args = args[:len(args)-1]
}
}
return
}
// Otherwise xxecute the explicit cross compilation
path := args[len(args)-1]
args = append(args[:len(args)-1], []string{"--dest", GOBIN, path}...)
xgo := xgoTool(args)
build.MustRun(xgo)
}
func xgoTool(args []string) *exec.Cmd {
cmd := exec.Command(filepath.Join(GOBIN, "xgo"), args...)
cmd.Env = []string{
"GOPATH=" + build.GOPATH(),
"GOBIN=" + GOBIN,
}
for _, e := range os.Environ() {
if strings.HasPrefix(e, "GOPATH=") || strings.HasPrefix(e, "GOBIN=") {
continue
}
cmd.Env = append(cmd.Env, e)
}
return cmd
}

View file

@ -249,13 +249,3 @@ func FindAllPackages(tc *GoToolchain) []string {
}
return result
}
// GOPATH returns the value that the GOPATH environment
// variable should be set to.
func GOPATH() string {
gopath := os.Getenv("GOPATH")
if gopath == "" {
log.Fatal("GOPATH is not set")
}
return gopath
}