diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-10-09 18:26:21 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-10-09 19:46:48 +0200 |
commit | 33fd5b4634a946073930bdfcfd3189bf870e9748 (patch) | |
tree | 8c1c807fe8e051ad723019ed1a8f648304fcd568 /app | |
parent | 91647978e69000e223c5f1daef89ad3d8e4ce66e (diff) |
Update to go modules
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app')
-rw-r--r-- | app/tools/CMakeLists.txt | 1 | ||||
-rw-r--r-- | app/tools/libwg-go/.gitignore | 2 | ||||
-rw-r--r-- | app/tools/libwg-go/Makefile | 38 | ||||
-rw-r--r-- | app/tools/libwg-go/src/api-android.go (renamed from app/tools/libwg-go/src/git.zx2c4.com/wireguard-go/api-android.go) | 0 | ||||
-rw-r--r-- | app/tools/libwg-go/src/jni.c (renamed from app/tools/libwg-go/src/git.zx2c4.com/wireguard-go/jni.c) | 0 | ||||
-rw-r--r-- | app/tools/libwg-go/src/queueconstants.go (renamed from app/tools/libwg-go/src/git.zx2c4.com/wireguard-go/queueconstants.go) | 0 | ||||
-rw-r--r-- | app/tools/libwg-go/src/tun/api-android.go (renamed from app/tools/libwg-go/src/git.zx2c4.com/wireguard-go/tun/api-android.go) | 0 | ||||
m--------- | app/tools/wireguard-go | 0 |
8 files changed, 28 insertions, 13 deletions
diff --git a/app/tools/CMakeLists.txt b/app/tools/CMakeLists.txt index fa8d3814..e4fda41e 100644 --- a/app/tools/CMakeLists.txt +++ b/app/tools/CMakeLists.txt @@ -25,6 +25,7 @@ add_custom_target(libwg-go.so WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/lib CFLAGS=${CMAKE_C_FLAGS}\ -Wno-unused-command-line-argument LDFLAGS=${CMAKE_SHARED_LINKER_FLAGS}\ -fuse-ld=gold DESTDIR=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} + BUILDDIR=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/../generated-src ) # Hack to make it actually build as part of the default target add_dependencies(libwg.so libwg-go.so) diff --git a/app/tools/libwg-go/.gitignore b/app/tools/libwg-go/.gitignore index c464c736..1454fe8b 100644 --- a/app/tools/libwg-go/.gitignore +++ b/app/tools/libwg-go/.gitignore @@ -1,2 +1,2 @@ -src/ +build/ .gobuildversion diff --git a/app/tools/libwg-go/Makefile b/app/tools/libwg-go/Makefile index 86e6d571..a3c118c2 100644 --- a/app/tools/libwg-go/Makefile +++ b/app/tools/libwg-go/Makefile @@ -2,7 +2,11 @@ # # Copyright © 2017-2018 WireGuard LLC. All Rights Reserved. -FILES := $(filter-out %/main.go %/queueconstants.go,$(wildcard ../wireguard-go/*/*.go) $(wildcard ../wireguard-go/*.go)) +UPSTREAM_FILES := $(filter-out %/main.go %/queueconstants.go,$(wildcard ../wireguard-go/*/*.go) $(wildcard ../wireguard-go/*.go)) ../wireguard-go/go.mod ../wireguard-go/go.sum +DOWNSTREAM_FILES := $(wildcard src/*.go) $(wildcard src/*/*.go) + +BUILDDIR ?= $(CURDIR)/build +DESTDIR ?= $(CURDIR)/out NDK_GO_ARCH_MAP_x86 := 386 NDK_GO_ARCH_MAP_x86_64 := amd64 @@ -28,10 +32,11 @@ GOBUILDTARBALL := https://dl.google.com/go/go$(GOBUILDVERSION).$(GOBUILDOS)-$(GO GOBUILDVERSION_NEEDED := go version go$(GOBUILDVERSION) $(GOBUILDOS)/$(GOBUILDARCH) GOBUILDVERSION_CURRENT := $(shell go version 2>/dev/null) -ifeq ($(GOBUILDVERSION_NEEDED),$(GOBUILDVERSION_CURRENT)) +HAVE_PATCHED_GO := $(shell patch -p1 -f -R -s --dry-run -d "$$(go env GOROOT)" < $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/goruntime-boottime-over-monotonic.diff >/dev/null 2>&1 && echo yes) +ifeq ($(GOBUILDVERSION_NEEDED)|$(HAVE_PATCHED_GO),$(GOBUILDVERSION_CURRENT)|yes) $(info Using system Go) else -export GOROOT := $(CURDIR)/goroot +export GOROOT := $(BUILDDIR)/goroot export PATH := $(GOROOT)/bin:$(PATH) GOBUILDVERSION_CURRENT := $(shell $(GOROOT)/bin/go version 2>/dev/null) ifneq ($(GOBUILDVERSION_NEEDED),$(GOBUILDVERSION_CURRENT)) @@ -42,17 +47,26 @@ $(GOROOT)/bin/go: 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; } -$(DESTDIR)/libwg-go.so: $(GOROOT)/bin/go +$(BUILDDIR)/.prepared: $(GOROOT)/bin/go endif $(shell test "$$(cat .gobuildversion 2>/dev/null)" = "$(GOBUILDVERSION_CURRENT)" || rm -f "$(DESTDIR)/libwg-go.so") -$(DESTDIR)/libwg-go.so: $(FILES) src/git.zx2c4.com/wireguard-go/api-android.go src/git.zx2c4.com/wireguard-go/tun/api-android.go src/git.zx2c4.com/wireguard-go/jni.c - @goroot="$$(go env GOROOT)" || exit 1; patch -p1 -f -R -s --dry-run -d "$$goroot" < goruntime-boottime-over-monotonic.diff >/dev/null 2>&1 || { echo "ERROR: Your system's Go is not patched to use the suspend-aware monotonic clock. Please try again after having run: \`patch -p1 -d \"$$goroot\" < \"$(CURDIR)/goruntime-boottime-over-monotonic.diff\"\`."; exit 1; } - find . -name '*.go' -type l -delete - find . -type d -empty -delete - mkdir -p $(subst ../wireguard-go/,./src/git.zx2c4.com/wireguard-go/,$(dir $(FILES))) - $(foreach FILE,$(FILES),ln -sfrt $(subst ../wireguard-go/,./src/git.zx2c4.com/wireguard-go/,$(dir $(FILE))) $(FILE);) - GOPATH=$(PWD) go get -v -d git.zx2c4.com/wireguard-go - GOPATH=$(PWD) go build -ldflags="-X main.socketDirectory=/data/data/$(ANDROID_PACKAGE_NAME)/cache/wireguard" -v -o $(DESTDIR)/libwg-go.so -buildmode c-shared git.zx2c4.com/wireguard-go +define copy-src-to-build +$(subst $(1),$(BUILDDIR)/,$(2)): $(2) + @mkdir -vp "$$(dir $$@)" + @cp -vp "$$<" "$$@" +$(BUILDDIR)/.prepared: $(subst $(1),$(BUILDDIR)/,$(2)) +endef + +$(foreach FILE,$(UPSTREAM_FILES),$(eval $(call copy-src-to-build,../wireguard-go/,$(FILE)))) +$(foreach FILE,$(DOWNSTREAM_FILES),$(eval $(call copy-src-to-build,src/,$(FILE)))) + +$(BUILDDIR)/.prepared: + cd "$(BUILDDIR)" && if ! GOPATH="$(BUILDDIR)/gopath" go get; then chmod -fR +w "$(BUILDDIR)/gopath/pkg/mod"; rm -rf "$(BUILDDIR)/gopath/pkg/mod"; exit 1; fi + chmod -fR +w "$(BUILDDIR)/gopath/pkg/mod" + touch "$@" + +$(DESTDIR)/libwg-go.so: $(BUILDDIR)/.prepared + cd "$(BUILDDIR)" && GOPATH="$(BUILDDIR)/gopath" go build -ldflags="-X main.socketDirectory=/data/data/$(ANDROID_PACKAGE_NAME)/cache/wireguard" -v -o "$@" -buildmode c-shared go version > .gobuildversion diff --git a/app/tools/libwg-go/src/git.zx2c4.com/wireguard-go/api-android.go b/app/tools/libwg-go/src/api-android.go index e57da84f..e57da84f 100644 --- a/app/tools/libwg-go/src/git.zx2c4.com/wireguard-go/api-android.go +++ b/app/tools/libwg-go/src/api-android.go diff --git a/app/tools/libwg-go/src/git.zx2c4.com/wireguard-go/jni.c b/app/tools/libwg-go/src/jni.c index 3c4dce5a..3c4dce5a 100644 --- a/app/tools/libwg-go/src/git.zx2c4.com/wireguard-go/jni.c +++ b/app/tools/libwg-go/src/jni.c diff --git a/app/tools/libwg-go/src/git.zx2c4.com/wireguard-go/queueconstants.go b/app/tools/libwg-go/src/queueconstants.go index b31dcfa5..b31dcfa5 100644 --- a/app/tools/libwg-go/src/git.zx2c4.com/wireguard-go/queueconstants.go +++ b/app/tools/libwg-go/src/queueconstants.go diff --git a/app/tools/libwg-go/src/git.zx2c4.com/wireguard-go/tun/api-android.go b/app/tools/libwg-go/src/tun/api-android.go index 90986c4d..90986c4d 100644 --- a/app/tools/libwg-go/src/git.zx2c4.com/wireguard-go/tun/api-android.go +++ b/app/tools/libwg-go/src/tun/api-android.go diff --git a/app/tools/wireguard-go b/app/tools/wireguard-go -Subproject dbb72402f2f4f5c972be98ad0c9602eb74e9f13 +Subproject 5d6083df7e0399d9cbb47a9dc0b227fd86ccffb |