aboutsummaryrefslogtreecommitdiffstats
path: root/wireguard-go-bridge
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-10-02 18:12:30 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-10-02 19:15:03 +0200
commitcd86ba92eca722812ee592001e9b566bf50183b6 (patch)
tree5e6f1b3b674b16f60bb0799fc87e031c432aa5e6 /wireguard-go-bridge
parentDon't crash on failure to obtain version info and inform user on what is needed to be able to retrieve version info from the Go client. (diff)
downloadwireguard-apple-cd86ba92eca722812ee592001e9b566bf50183b6.tar.xz
wireguard-apple-cd86ba92eca722812ee592001e9b566bf50183b6.zip
Rewrite bridge build system
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'wireguard-go-bridge')
-rw-r--r--wireguard-go-bridge/Makefile52
-rw-r--r--wireguard-go-bridge/src/api-ios.go (renamed from wireguard-go-bridge/src/git.zx2c4.com/wireguard-go/api-ios.go)0
-rw-r--r--wireguard-go-bridge/src/queueconstants.go (renamed from wireguard-go-bridge/src/git.zx2c4.com/wireguard-go/queueconstants.go)0
-rw-r--r--wireguard-go-bridge/src/tun/tun_ios.go (renamed from wireguard-go-bridge/src/git.zx2c4.com/wireguard-go/tun/tun_ios.go)0
-rwxr-xr-xwireguard-go-bridge/xcode-build-helper.sh23
5 files changed, 30 insertions, 45 deletions
diff --git a/wireguard-go-bridge/Makefile b/wireguard-go-bridge/Makefile
index 9cc98c73..7b98c928 100644
--- a/wireguard-go-bridge/Makefile
+++ b/wireguard-go-bridge/Makefile
@@ -2,50 +2,58 @@
#
# Copyright (C) 2018 Jason A. Donenfeld <Jason@zx2c4.com>. 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))
+DOWNSTREAM_FILES := $(wildcard src/*.go) $(wildcard src/*/*.go)
-ARCHES := arm64 armv7 x86_64
+ARCHS ?= arm64 armv7 x86_64
GOARCH_arm64 := arm64
GOARCH_armv7 := arm
GOARCH_x86_64 := amd64
-CGO_FLAGS_x86_64 := -arch x86_64 -isysroot $(shell xcrun --sdk iphonesimulator --show-sdk-path)
-CGO_FLAGS_arm64 := -arch arm64 -isysroot $(shell xcrun --sdk iphoneos --show-sdk-path)
-CGO_FLAGS_armv7 := -arch armv7 -isysroot $(shell xcrun --sdk iphoneos --show-sdk-path)
+DEPLOYMENT_CFLAGS := $(DEPLOYMENT_TARGET_CLANG_FLAG_PREFIX)$($(DEPLOYMENT_TARGET_CLANG_ENV_NAME))
+CGO_FLAGS_x86_64 := -arch x86_64 -isysroot $(shell xcrun --sdk iphonesimulator --show-sdk-path) $(DEPLOYMENT_CFLAGS)
+CGO_FLAGS_arm64 := -arch arm64 -isysroot $(shell xcrun --sdk iphoneos --show-sdk-path) $(DEPLOYMENT_CFLAGS)
+CGO_FLAGS_armv7 := -arch armv7 -isysroot $(shell xcrun --sdk iphoneos --show-sdk-path) $(DEPLOYMENT_CFLAGS)
CC_x86_64 := $(shell xcrun --sdk iphonesimulator --find clang)
CC_arm64 := $(shell xcrun --sdk iphoneos --find clang)
CC_armv7 := $(shell xcrun --sdk iphoneos --find clang)
+CONFIGURATION_BUILD_DIR ?= $(CURDIR)/out
+CONFIGURATION_TEMP_DIR ?= $(CURDIR)/.tmp
+DESTDIR ?= $(CONFIGURATION_BUILD_DIR)
+GOBUILDDIR ?= $(CONFIGURATION_TEMP_DIR)/wireguard-go-bridge
export GOOS := darwin
export CGO_ENABLED := 1
-default: libwg-go.a
+build: $(DESTDIR)/libwg-go.a
-src/.prepared: $(FILES) src/git.zx2c4.com/wireguard-go/api-ios.go src/git.zx2c4.com/wireguard-go/tun/tun_ios.go
- 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 -sf $(abspath $(FILE)) $(subst ../wireguard-go/,./src/git.zx2c4.com/wireguard-go/,$(dir $(FILE)))$(notdir $(FILE));)
- GOPATH=$(CURDIR) go get -v -d git.zx2c4.com/wireguard-go
+$(GOBUILDDIR)/src/.prepared: $(UPSTREAM_FILES) $(DOWNSTREAM_FILES)
+ rm -rf $(GOBUILDDIR)/src
+ mkdir -p $(subst ../wireguard-go/,$(GOBUILDDIR)/src/git.zx2c4.com/wireguard-go/,$(dir $(UPSTREAM_FILES)))
+ mkdir -p $(subst src/,$(GOBUILDDIR)/src/git.zx2c4.com/wireguard-go/,$(dir $(DOWNSTREAM_FILES)))
+ $(foreach FILE,$(UPSTREAM_FILES),ln -sf $(abspath $(FILE)) $(subst ../wireguard-go/,$(GOBUILDDIR)/src/git.zx2c4.com/wireguard-go/,$(dir $(FILE)))$(notdir $(FILE));)
+ $(foreach FILE,$(DOWNSTREAM_FILES),ln -sf $(abspath $(FILE)) $(subst src/,$(GOBUILDDIR)/src/git.zx2c4.com/wireguard-go/,$(dir $(FILE)))$(notdir $(FILE));)
+ GOPATH=$(GOBUILDDIR) go get -v -d git.zx2c4.com/wireguard-go
touch $@
define libwg-go-a
-libwg-go-$(1).a: $(FILES) src/git.zx2c4.com/wireguard-go/api-ios.go src/git.zx2c4.com/wireguard-go/tun/tun_ios.go src/.prepared
+$(GOBUILDDIR)/libwg-go-$(1).a: $(UPSTREAM_FILES) $(DOWNSTREAM_FILES) $(GOBUILDDIR)/src/.prepared
CC="$(CC_$(1))" \
CGO_CFLAGS="$(CGO_FLAGS_$(1))" \
CGO_LDFLAGS="$(CGO_FLAGS_$(1))" \
GOARCH=$(GOARCH_$(1)) \
- GOPATH=$(CURDIR) \
- go build -tags ios -v -o libwg-go-$(1).a -buildmode c-archive git.zx2c4.com/wireguard-go
- @rm -f libwg-go-$(1).h
+ GOPATH=$(GOBUILDDIR) \
+ go build -tags ios -v -o $(GOBUILDDIR)/libwg-go-$(1).a -buildmode c-archive git.zx2c4.com/wireguard-go
+ @rm -f $(GOBUILDDIR)/libwg-go-$(1).h
endef
-$(foreach ARCH,$(ARCHES),$(eval $(call libwg-go-a,$(ARCH))))
+$(foreach ARCH,$(ARCHS),$(eval $(call libwg-go-a,$(ARCH))))
-libwg-go.a: $(foreach ARCH,$(ARCHES),libwg-go-$(ARCH).a)
+$(DESTDIR)/libwg-go.a: $(foreach ARCH,$(ARCHS),$(GOBUILDDIR)/libwg-go-$(ARCH).a)
+ mkdir -p $(DESTDIR)
xcrun --sdk iphoneos lipo -create -output $@ $^
-example: example.c libwg-go.a
- xcrun --sdk iphoneos clang -framework CoreFoundation -isysroot $(shell xcrun --sdk iphoneos --show-sdk-path) -arch arm64 -arch armv7 -L. -lwg-go -o example example.c
+$(DESTDIR)/example: example.c $(DESTDIR)/libwg-go.a
+ xcrun --sdk iphoneos clang -framework CoreFoundation -isysroot $(shell xcrun --sdk iphoneos --show-sdk-path) -arch arm64 -arch armv7 -L$(DESTDIR) -lwg-go -o $@ $<
clean:
- rm -f libwg-go.a $(foreach ARCH,$(ARCHES),libwg-go-$(ARCH).a) example
+ rm -rf $(GOBUILDDIR) $(DESTDIR)/libwg-go.a $(DESTDIR)/example
-.PHONY: clean default
+.PHONY: clean build
diff --git a/wireguard-go-bridge/src/git.zx2c4.com/wireguard-go/api-ios.go b/wireguard-go-bridge/src/api-ios.go
index dcc588fd..dcc588fd 100644
--- a/wireguard-go-bridge/src/git.zx2c4.com/wireguard-go/api-ios.go
+++ b/wireguard-go-bridge/src/api-ios.go
diff --git a/wireguard-go-bridge/src/git.zx2c4.com/wireguard-go/queueconstants.go b/wireguard-go-bridge/src/queueconstants.go
index 410af14b..410af14b 100644
--- a/wireguard-go-bridge/src/git.zx2c4.com/wireguard-go/queueconstants.go
+++ b/wireguard-go-bridge/src/queueconstants.go
diff --git a/wireguard-go-bridge/src/git.zx2c4.com/wireguard-go/tun/tun_ios.go b/wireguard-go-bridge/src/tun/tun_ios.go
index 93a0503f..93a0503f 100644
--- a/wireguard-go-bridge/src/git.zx2c4.com/wireguard-go/tun/tun_ios.go
+++ b/wireguard-go-bridge/src/tun/tun_ios.go
diff --git a/wireguard-go-bridge/xcode-build-helper.sh b/wireguard-go-bridge/xcode-build-helper.sh
deleted file mode 100755
index b5b467dd..00000000
--- a/wireguard-go-bridge/xcode-build-helper.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/sh
-cd "$PROJECT_DIR"/wireguard-go-bridge
-case $1 in
- clean)
- make clean
- ;;
- *)
- if [ -e "$DERIVED_FILE_DIR/libwg-go.a" ]
- then
- echo "Clean before building"
- else
- make
- fi
-
- ;;
-esac
-
-if [ -f "libwg-go.a" ]
-then
- mkdir -p "$DERIVED_FILE_DIR"
- mv *.a "$DERIVED_FILE_DIR"
- ln -sf "$DERIVED_FILE_DIR/libwg-go.a" libwg-go.a
-fi