diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-03-29 02:28:41 -0600 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-03-29 02:28:41 -0600 |
commit | 0fa3fe3d435e694c7818ddaca8f755a47d9745cd (patch) | |
tree | 1797e64638f5dd4e5b6872ceb524481cb1b21e44 /tunnel/tools/libwg-go/Makefile | |
parent | ed090f7ecb66eacdfdc655ad26eacfa648920096 (diff) |
tunnel: libwg-go: stick go tarball in gradle cache
This way we don't have to build over and over.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'tunnel/tools/libwg-go/Makefile')
-rw-r--r-- | tunnel/tools/libwg-go/Makefile | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/tunnel/tools/libwg-go/Makefile b/tunnel/tools/libwg-go/Makefile index 6c2d25b5..f4abca5f 100644 --- a/tunnel/tools/libwg-go/Makefile +++ b/tunnel/tools/libwg-go/Makefile @@ -20,18 +20,28 @@ export GOARCH := $(NDK_GO_ARCH_MAP_$(ANDROID_ARCH_NAME)) export GOOS := android export CGO_ENABLED := 1 -DESIRED_GO_VERSION := 1.14.1 +GO_VERSION := 1.14.1 +GO_TARBALL := go$(GO_VERSION).$(shell uname -s | tr '[:upper:]' '[:lower:]')-$(NDK_GO_ARCH_MAP_$(shell uname -m)).tar.gz default: $(DESTDIR)/libwg-go.so -$(BUILDDIR)/go-$(DESIRED_GO_VERSION)/.prepared: +$(GRADLE_USER_HOME)/caches/golang/$(GO_TARBALL): mkdir -p "$(dir $@)" flock -x "$@.lock" -c ' \ [ -f "$@" ] && exit 0; \ - 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 - && \ + curl -o "$@.tmp" "https://dl.google.com/go/$(GO_TARBALL)" && \ + mv "$@.tmp" "$@"' + +$(BUILDDIR)/go-$(GO_VERSION)/.prepared: $(GRADLE_USER_HOME)/caches/golang/$(GO_TARBALL) + mkdir -p "$(dir $@)" + flock -x "$@.lock" -c ' \ + [ -f "$@" ] && exit 0; \ + tar -C "$(dir $@)" --strip-components=1 -xzf "$^" && \ patch -p1 -f -N -r- -d "$(dir $@)" < goruntime-boottime-over-monotonic.diff && \ touch "$@"' -$(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 +$(DESTDIR)/libwg-go.so: export PATH := $(BUILDDIR)/go-$(GO_VERSION)/bin/:$(PATH) +$(DESTDIR)/libwg-go.so: $(BUILDDIR)/go-$(GO_VERSION)/.prepared go.mod go build -tags linux -ldflags="-X golang.zx2c4.com/wireguard/ipc.socketDirectory=/data/data/$(ANDROID_PACKAGE_NAME)/cache/wireguard" -v -trimpath -o "$@" -buildmode c-shared + +.DELETE_ON_ERROR: |