]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
wireguard-go-bridge: use system go installation
authorJason A. Donenfeld <Jason@zx2c4.com>
Fri, 8 Mar 2019 04:56:00 +0000 (05:56 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Fri, 8 Mar 2019 04:56:00 +0000 (05:56 +0100)
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
README.md
wireguard-go-bridge/Makefile
wireguard-go-bridge/go.mod
wireguard-go-bridge/go.sum

index ba8b5d048956213066413b7aeb14f145f37642d1..0a57be8f3e774b1cf2f2c695dd4d339c6108d68e 100644 (file)
--- a/README.md
+++ b/README.md
@@ -16,10 +16,10 @@ $ cp WireGuard/WireGuard/Config/Developer.xcconfig.template WireGuard/WireGuard/
 $ vim WireGuard/WireGuard/Config/Developer.xcconfig
 ```
 
-- Install swiftlint:
+- Install swiftlint and go:
 
 ```
-$ brew install swiftlint
+$ brew install swiftlint go
 ```
 
 - Open project in Xcode:
index d957e0c5b13220b5363e634244a113f26fde0170..ae9fa097b9ee416fd77fb4e7445a9047f78b09e4 100644 (file)
@@ -26,34 +26,31 @@ export CGO_ENABLED := 1
 build: $(DESTDIR)/libwg-go.a
 version-header: $(DESTDIR)/wireguard-go-version.h
 
-GOBUILDARCH := $(GOARCH_$(shell uname -m))
-GOBUILDOS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
-GOBUILDVERSION := 1.12
-GOBUILDTARBALL := go$(GOBUILDVERSION).$(GOBUILDOS)-$(GOBUILDARCH).tar.gz
-GOBUILDTARBALLURL := https://dl.google.com/go/$(GOBUILDTARBALL)
-GOBUILDVERSION_NEEDED := go version go$(GOBUILDVERSION) $(GOBUILDOS)/$(GOBUILDARCH)
+GOBUILDVERSION_NEEDED := go version go1.12 darwin/amd64
+GOBUILDVERSION_CURRENT := $(shell go version 2>/dev/null)
+export REAL_GOROOT := $(shell go env GOROOT 2>/dev/null)
 export GOROOT := $(BUILDDIR)/goroot
 export GOPATH := $(BUILDDIR)/gopath
-export PATH := $(GOROOT)/bin:$(PATH)
-GOBUILDVERSION_CURRENT := $(shell $(GOROOT)/bin/go version 2>/dev/null)
+export PATH := $(GOPATH)/bin:$(PATH)
+GOBUILDVERSION_FAKE := $(shell $(GOROOT)/bin/go version 2>/dev/null)
 ifneq ($(GOBUILDVERSION_NEEDED),$(GOBUILDVERSION_CURRENT))
-$(shell rm -f $(GOROOT)/bin/go)
+$(error This requires $(GOBUILDVERSION_NEEDED))
+endif
+ifneq ($(GOBUILDVERSION_NEEDED),$(GOBUILDVERSION_FAKE))
+$(shell rm -f $(GOROOT)/.prepared)
 endif
-.cache/$(GOBUILDTARBALL):
-       mkdir -p $(dir $@)
-       curl -o $@ $(GOBUILDTARBALLURL) || { rm -f $@; exit 1; }
 
-$(GOROOT)/bin/go: .cache/$(GOBUILDTARBALL)
-       rm -rf "$(GOROOT)"
+$(GOROOT)/.prepared:
+       [ -n "$(REAL_GOROOT)" ]
        mkdir -p "$(GOROOT)"
-       tar -C "$(GOROOT)" --strip-components=1 -xzf - < .cache/$(GOBUILDTARBALL) || { rm -rf "$(GOROOT)"; exit 1; }
-       patch -p1 -f -N -r- -d "$(GOROOT)" < goruntime-boottime-over-monotonic.diff || { rm -rf "$(GOROOT)"; exit 1; }
-       touch $@
+       rsync -a --delete --exclude=pkg/obj/go-build "$(REAL_GOROOT)/" "$(GOROOT)/"
+       patch -p1 -f -N -r- -d "$(GOROOT)" < goruntime-boottime-over-monotonic.diff
+       touch "$@"
 
 $(shell test "$$(cat "$(BUILDDIR)/.gobuildversion" 2>/dev/null)" = "$(GOBUILDVERSION_CURRENT)" || rm -f "$(DESTDIR)/libwg-go.a")
 
 define libwg-go-a
-$(BUILDDIR)/libwg-go-$(1).a: $(GOROOT)/bin/go
+$(BUILDDIR)/libwg-go-$(1).a: $(GOROOT)/.prepared
        CGO_CFLAGS="$(CFLAGS_PREFIX) $(ARCH)" \
        CGO_LDFLAGS="$(CFLAGS_PREFIX) $(ARCH)" \
        GOARCH="$(GOARCH_$(1))" \
@@ -65,7 +62,7 @@ $(BUILDDIR)/libwg-go-$(1).a: $(GOROOT)/bin/go
 endef
 $(foreach ARCH,$(ARCHS),$(eval $(call libwg-go-a,$(ARCH))))
 
-$(DESTDIR)/wireguard-go-version.h: go.mod $(GOROOT)/bin/go
+$(DESTDIR)/wireguard-go-version.h: go.mod $(GOROOT)/.prepared
        go get -d -tags ios; chmod -fR +w "$(GOPATH)/pkg/mod"
        wggo="$(GOPATH)/pkg/mod/$$(sed -n 's/.*\(golang\.zx2c4\.com\/wireguard\) \(.*\)$$/\1@\2/p' go.mod)"; \
        sed -n 's/.*WireGuardGoVersion = "\(.*\)"/#define WIREGUARD_GO_VERSION "\1"/p' "$$wggo/device/version.go" > "$@"
@@ -77,9 +74,6 @@ $(DESTDIR)/libwg-go.a: $(foreach ARCH,$(ARCHS),$(BUILDDIR)/libwg-go-$(ARCH).a)
 clean:
        rm -rf "$(BUILDDIR)" "$(DESTDIR)/libwg-go.a" "$(DESTDIR)/wireguard-go-version.h"
 
-distclean: clean
-       rm -rf .cache
-
 install: build
 
-.PHONY: distclean clean build version-header install
+.PHONY: clean build version-header install
index 82d41289b97aed858bfd5e2808c8aad00747d957..8812765befab46a56c2eca6ed534b55b65c2033c 100644 (file)
@@ -3,6 +3,6 @@ module golang.zx2c4.com/wireguard/ios
 go 1.12
 
 require (
-       golang.org/x/sys v0.0.0-20190302025703-b6889370fb10
-       golang.zx2c4.com/wireguard v0.0.0-20190303043202-244a98e380fa
+       golang.org/x/sys v0.0.0-20190308023053-584f3b12f43e
+       golang.zx2c4.com/wireguard v0.0.0-20190308004054-5c7cc256e39a
 )
index dc7825067bad810fe62473b3db40d96673e60013..804f5c6d36b2958f7035074e92f6c39c05b42f09 100644 (file)
@@ -6,5 +6,9 @@ golang.org/x/net v0.0.0-20190301231341-16b79f2e4e95/go.mod h1:mL1N/T3taQHkDXs73r
 golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20190302025703-b6889370fb10 h1:xQJI9OEiErEQ++DoXOHqEpzsGMrAv2Q2jyCpi7DmfpQ=
 golang.org/x/sys v0.0.0-20190302025703-b6889370fb10/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190308023053-584f3b12f43e h1:K7CV15oJ823+HLXQ+M7MSMrUg8LjfqY7O3naO+8Pp/I=
+golang.org/x/sys v0.0.0-20190308023053-584f3b12f43e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.zx2c4.com/wireguard v0.0.0-20190303043202-244a98e380fa h1:t/IV/5G9uPXXDoaOrk+Lx2VsFhbqWGYFE+GEl160Yzc=
 golang.zx2c4.com/wireguard v0.0.0-20190303043202-244a98e380fa/go.mod h1:Koyxt99ZAZcr8lJuisBNX9vnaqKVNGcITeWOI1Zkmsw=
+golang.zx2c4.com/wireguard v0.0.0-20190308004054-5c7cc256e39a h1:RvrH0NQcXaN9h2JoBDAI3BWcTTJL3vH9L1gHQY0T76w=
+golang.zx2c4.com/wireguard v0.0.0-20190308004054-5c7cc256e39a/go.mod h1:Koyxt99ZAZcr8lJuisBNX9vnaqKVNGcITeWOI1Zkmsw=