diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-10-12 11:43:16 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-10-12 18:55:21 +0200 |
commit | 927b32c99f60966ca558053f13e37b2561c33cf9 (patch) | |
tree | de8074af26748ef904e079ad678b31b3341ad175 /app/tools/libwg-go/Makefile | |
parent | 27b691bef6b6566299a869ebc7dcaa2ad4836a93 (diff) |
libwg-go: update to go 1.13
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/tools/libwg-go/Makefile')
-rw-r--r-- | app/tools/libwg-go/Makefile | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/app/tools/libwg-go/Makefile b/app/tools/libwg-go/Makefile index 8dbf6f6a..88e7260c 100644 --- a/app/tools/libwg-go/Makefile +++ b/app/tools/libwg-go/Makefile @@ -20,30 +20,16 @@ export GOARCH := $(NDK_GO_ARCH_MAP_$(ANDROID_ARCH_NAME)) export GOOS := android export CGO_ENABLED := 1 -default: $(DESTDIR)/libwg-go.so +DESIRED_GO_VERSION := 1.13.1 -GOBUILDARCH := $(NDK_GO_ARCH_MAP_$(shell uname -m)) -GOBUILDOS := $(shell uname -s | tr '[:upper:]' '[:lower:]') -GOBUILDVERSION := 1.12.10 -GOBUILDTARBALL := https://dl.google.com/go/go$(GOBUILDVERSION).$(GOBUILDOS)-$(GOBUILDARCH).tar.gz -GOBUILDVERSION_NEEDED := go version go$(GOBUILDVERSION) $(GOBUILDOS)/$(GOBUILDARCH) -export GOROOT := $(BUILDDIR)/goroot -export GOPATH := $(BUILDDIR)/gopath -export PATH := $(GOROOT)/bin:$(PATH) -GOBUILDVERSION_CURRENT := $(shell $(GOROOT)/bin/go version 2>/dev/null) -ifneq ($(GOBUILDVERSION_NEEDED),$(GOBUILDVERSION_CURRENT)) -$(shell rm -f $(GOROOT)/bin/go) -endif -$(GOROOT)/bin/go: - rm -rf "$(GOROOT)" - mkdir -p "$(GOROOT)" - curl "$(GOBUILDTARBALL)" | tar -C "$(GOROOT)" --strip-components=1 -xzf - || { rm -rf "$(GOROOT)"; exit 1; } - patch -p1 -f -N -r- -d "$(GOROOT)" < goruntime-boottime-over-monotonic.diff || { rm -rf "$(GOROOT)"; exit 1; } +default: $(DESTDIR)/libwg-go.so -$(shell test "$$(cat $(BUILDDIR)/.gobuildversion 2>/dev/null)" = "$(GOBUILDVERSION_CURRENT)" || rm -f "$(DESTDIR)/libwg-go.so") +$(BUILDDIR)/go-$(DESIRED_GO_VERSION)/.prepared: + mkdir -p "$(dir $@)" + curl "https://dl.google.com/go/go$(DESIRED_GO_VERSION).$(shell uname -s | tr '[:upper:]' '[:lower:]')-$(NDK_GO_ARCH_MAP_$(shell uname -m)).tar.gz" | tar -C "$(dir $@)" --strip-components=1 -xzf - + patch -p1 -f -N -r- -d "$(dir $@)" < goruntime-boottime-over-monotonic.diff + touch "$@" -$(DESTDIR)/libwg-go.so: $(GOROOT)/bin/go - go get -tags linux || { chmod -fR +w "$(GOPATH)/pkg/mod"; rm -rf "$(GOPATH)/pkg/mod"; exit 1; } - chmod -fR +w "$(GOPATH)/pkg/mod" - go build -tags linux -ldflags="-X main.socketDirectory=/data/data/$(ANDROID_PACKAGE_NAME)/cache/wireguard" -v -o "$@" -buildmode c-shared - go version > $(BUILDDIR)/.gobuildversion +$(DESTDIR)/libwg-go.so: export PATH := $(BUILDDIR)/go-$(DESIRED_GO_VERSION)/bin/:$(PATH) +$(DESTDIR)/libwg-go.so: $(BUILDDIR)/go-$(DESIRED_GO_VERSION)/.prepared go.mod + go build -tags linux -ldflags="-X main.socketDirectory=/data/data/$(ANDROID_PACKAGE_NAME)/cache/wireguard" -v -trimpath -o "$@" -buildmode c-shared |