Rewrite bridge build system

This commit is contained in:
Jason A. Donenfeld 2018-10-02 18:12:30 +02:00
parent 41e0459521
commit 9d01829a98
8 changed files with 45 additions and 76 deletions

View File

@ -103,7 +103,7 @@
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
0CE52E030FAA93F3BF5747B2 /* Pods-WireGuard.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WireGuard.release.xcconfig"; path = "Pods/Target Support Files/Pods-WireGuard/Pods-WireGuard.release.xcconfig"; sourceTree = "<group>"; }; 0CE52E030FAA93F3BF5747B2 /* Pods-WireGuard.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WireGuard.release.xcconfig"; path = "Pods/Target Support Files/Pods-WireGuard/Pods-WireGuard.release.xcconfig"; sourceTree = "<group>"; };
25E2BE31A33C8CCE6E79B6EF /* Pods-WireGuard.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WireGuard.debug.xcconfig"; path = "Pods/Target Support Files/Pods-WireGuard/Pods-WireGuard.debug.xcconfig"; sourceTree = "<group>"; }; 25E2BE31A33C8CCE6E79B6EF /* Pods-WireGuard.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WireGuard.debug.xcconfig"; path = "Pods/Target Support Files/Pods-WireGuard/Pods-WireGuard.debug.xcconfig"; sourceTree = "<group>"; };
4A0F8694215C0726002AEE4B /* libwg-go.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = "libwg-go.a"; sourceTree = "<group>"; }; 4A0F8694215C0726002AEE4B /* libwg-go.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = "libwg-go.a"; sourceTree = BUILT_PRODUCTS_DIR; };
4A430E7F2139DC8F0078172C /* icon_20pt@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_20pt@3x.png"; sourceTree = "<group>"; }; 4A430E7F2139DC8F0078172C /* icon_20pt@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_20pt@3x.png"; sourceTree = "<group>"; };
4A430E812139DCCB0078172C /* icon_20pt.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = icon_20pt.png; sourceTree = "<group>"; }; 4A430E812139DCCB0078172C /* icon_20pt.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = icon_20pt.png; sourceTree = "<group>"; };
4A430E832139DCFB0078172C /* icon_60pt@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "icon_60pt@3x.png"; path = "WireGuard/Assets.xcassets/AppIcon.appiconset/icon_60pt@3x.png"; sourceTree = SOURCE_ROOT; }; 4A430E832139DCFB0078172C /* icon_60pt@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "icon_60pt@3x.png"; path = "WireGuard/Assets.xcassets/AppIcon.appiconset/icon_60pt@3x.png"; sourceTree = SOURCE_ROOT; };
@ -144,7 +144,6 @@
4A8A229D215B793C00736141 /* AppCoordinator+TunnelInfoTableViewControllerDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppCoordinator+TunnelInfoTableViewControllerDelegate.swift"; sourceTree = "<group>"; }; 4A8A229D215B793C00736141 /* AppCoordinator+TunnelInfoTableViewControllerDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppCoordinator+TunnelInfoTableViewControllerDelegate.swift"; sourceTree = "<group>"; };
4A8A229F215B821A00736141 /* ExtensionMessage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExtensionMessage.swift; sourceTree = "<group>"; }; 4A8A229F215B821A00736141 /* ExtensionMessage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExtensionMessage.swift; sourceTree = "<group>"; };
4A8A22A7215BC6A800736141 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = "<group>"; }; 4A8A22A7215BC6A800736141 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = "<group>"; };
4A8A22AC215BCFB000736141 /* xcode-build-helper.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "xcode-build-helper.sh"; sourceTree = "<group>"; };
4A8AABD720B6A79100B6D8C1 /* UITableView+WireGuard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITableView+WireGuard.swift"; sourceTree = "<group>"; }; 4A8AABD720B6A79100B6D8C1 /* UITableView+WireGuard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITableView+WireGuard.swift"; sourceTree = "<group>"; };
4ABF718D214D8B0300A1E0BF /* TunnelInfoTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TunnelInfoTableViewController.swift; sourceTree = "<group>"; }; 4ABF718D214D8B0300A1E0BF /* TunnelInfoTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TunnelInfoTableViewController.swift; sourceTree = "<group>"; };
4ABFFE9D212D399F00107136 /* WireGuard-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "WireGuard-Bridging-Header.h"; sourceTree = "<group>"; }; 4ABFFE9D212D399F00107136 /* WireGuard-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "WireGuard-Bridging-Header.h"; sourceTree = "<group>"; };
@ -343,7 +342,6 @@
4AD08FFE20DC4171000E9CF5 /* wireguard-go-bridge */ = { 4AD08FFE20DC4171000E9CF5 /* wireguard-go-bridge */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
4A8A22AC215BCFB000736141 /* xcode-build-helper.sh */,
4A8A22A7215BC6A800736141 /* Makefile */, 4A8A22A7215BC6A800736141 /* Makefile */,
4A0F8694215C0726002AEE4B /* libwg-go.a */, 4A0F8694215C0726002AEE4B /* libwg-go.a */,
4AD0900720DC4171000E9CF5 /* wireguard.h */, 4AD0900720DC4171000E9CF5 /* wireguard.h */,
@ -388,7 +386,7 @@
buildConfigurationList = 4A8A22A9215BC9B200736141 /* Build configuration list for PBXLegacyTarget "WireGuardGoBridge" */; buildConfigurationList = 4A8A22A9215BC9B200736141 /* Build configuration list for PBXLegacyTarget "WireGuardGoBridge" */;
buildPhases = ( buildPhases = (
); );
buildToolPath = "$(PROJECT_DIR)/wireguard-go-bridge/xcode-build-helper.sh"; buildToolPath = make;
buildWorkingDirectory = "$(PROJECT_DIR)/wireguard-go-bridge"; buildWorkingDirectory = "$(PROJECT_DIR)/wireguard-go-bridge";
dependencies = ( dependencies = (
); );
@ -470,6 +468,7 @@
TargetAttributes = { TargetAttributes = {
4A4BACE120B5F1BF00F12B28 = { 4A4BACE120B5F1BF00F12B28 = {
CreatedOnToolsVersion = 9.3.1; CreatedOnToolsVersion = 9.3.1;
LastSwiftMigration = 1000;
SystemCapabilities = { SystemCapabilities = {
com.apple.ApplicationGroups.iOS = { com.apple.ApplicationGroups.iOS = {
enabled = 1; enabled = 1;
@ -484,6 +483,7 @@
}; };
4A4BACF520B5F1C100F12B28 = { 4A4BACF520B5F1C100F12B28 = {
CreatedOnToolsVersion = 9.3.1; CreatedOnToolsVersion = 9.3.1;
LastSwiftMigration = 1000;
TestTargetID = 4A4BACE120B5F1BF00F12B28; TestTargetID = 4A4BACE120B5F1BF00F12B28;
}; };
4A61D82520D98CE1006C7A76 = { 4A61D82520D98CE1006C7A76 = {
@ -790,6 +790,7 @@
SDKROOT = iphoneos; SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2";
}; };
name = Debug; name = Debug;
}; };
@ -843,6 +844,7 @@
SDKROOT = iphoneos; SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule; SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O"; SWIFT_OPTIMIZATION_LEVEL = "-O";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES; VALIDATE_PRODUCT = YES;
}; };
name = Release; name = Release;
@ -859,7 +861,6 @@
CODE_SIGN_STYLE = Manual; CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = L82V4Y2P3C; DEVELOPMENT_TEAM = L82V4Y2P3C;
INFOPLIST_FILE = WireGuard/Info.plist; INFOPLIST_FILE = WireGuard/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.3;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
@ -873,8 +874,7 @@
PROVISIONING_PROFILE_SPECIFIER = "WireGuard Development"; PROVISIONING_PROFILE_SPECIFIER = "WireGuard Development";
SWIFT_OBJC_BRIDGING_HEADER = "WireGuard/WireGuard-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "WireGuard/WireGuard-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0; SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
}; };
name = Debug; name = Debug;
}; };
@ -890,7 +890,6 @@
CODE_SIGN_STYLE = Manual; CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = L82V4Y2P3C; DEVELOPMENT_TEAM = L82V4Y2P3C;
INFOPLIST_FILE = WireGuard/Info.plist; INFOPLIST_FILE = WireGuard/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.3;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
@ -903,8 +902,7 @@
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "WireGuard Development"; PROVISIONING_PROFILE_SPECIFIER = "WireGuard Development";
SWIFT_OBJC_BRIDGING_HEADER = "WireGuard/WireGuard-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "WireGuard/WireGuard-Bridging-Header.h";
SWIFT_VERSION = 4.0; SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
}; };
name = Release; name = Release;
}; };
@ -923,8 +921,7 @@
); );
PRODUCT_BUNDLE_IDENTIFIER = com.wireguard.ios.WireGuardTests; PRODUCT_BUNDLE_IDENTIFIER = com.wireguard.ios.WireGuardTests;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0; SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WireGuard.app/WireGuard"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WireGuard.app/WireGuard";
}; };
name = Debug; name = Debug;
@ -944,8 +941,7 @@
); );
PRODUCT_BUNDLE_IDENTIFIER = com.wireguard.ios.WireGuardTests; PRODUCT_BUNDLE_IDENTIFIER = com.wireguard.ios.WireGuardTests;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0; SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WireGuard.app/WireGuard"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WireGuard.app/WireGuard";
}; };
name = Release; name = Release;
@ -960,24 +956,18 @@
DEVELOPMENT_TEAM = L82V4Y2P3C; DEVELOPMENT_TEAM = L82V4Y2P3C;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = WireGuardNetworkExtension/Info.plist; INFOPLIST_FILE = WireGuardNetworkExtension/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.4;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
"@executable_path/../../Frameworks", "@executable_path/../../Frameworks",
); );
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/wireguard-go-bridge",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.wireguard.ios.network-extension"; PRODUCT_BUNDLE_IDENTIFIER = "com.wireguard.ios.network-extension";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "WireGuard Network Extension Development"; PROVISIONING_PROFILE_SPECIFIER = "WireGuard Network Extension Development";
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
SWIFT_OBJC_BRIDGING_HEADER = "WireGuardNetworkExtension/WireGuardNetworkExtension-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "WireGuardNetworkExtension/WireGuardNetworkExtension-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0; SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
}; };
name = Debug; name = Debug;
}; };
@ -991,23 +981,17 @@
DEVELOPMENT_TEAM = L82V4Y2P3C; DEVELOPMENT_TEAM = L82V4Y2P3C;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = WireGuardNetworkExtension/Info.plist; INFOPLIST_FILE = WireGuardNetworkExtension/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.4;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
"@executable_path/../../Frameworks", "@executable_path/../../Frameworks",
); );
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/wireguard-go-bridge",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.wireguard.ios.network-extension"; PRODUCT_BUNDLE_IDENTIFIER = "com.wireguard.ios.network-extension";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "WireGuard Network Extension Development"; PROVISIONING_PROFILE_SPECIFIER = "WireGuard Network Extension Development";
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
SWIFT_OBJC_BRIDGING_HEADER = "WireGuardNetworkExtension/WireGuardNetworkExtension-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "WireGuardNetworkExtension/WireGuardNetworkExtension-Bridging-Header.h";
SWIFT_VERSION = 4.0; SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
}; };
name = Release; name = Release;
}; };

View File

@ -11,7 +11,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow? var window: UIWindow?
var appCoordinator: AppCoordinator! var appCoordinator: AppCoordinator!
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
self.window = UIWindow(frame: UIScreen.main.bounds) self.window = UIWindow(frame: UIScreen.main.bounds)
appCoordinator = AppCoordinator(window: self.window!) appCoordinator = AppCoordinator(window: self.window!)
@ -22,7 +22,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return true return true
} }
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any] = [:]) -> Bool { func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
defer { defer {
do { do {
try FileManager.default.removeItem(at: url) try FileManager.default.removeItem(at: url)

View File

@ -151,7 +151,7 @@ class TunnelsTableViewController: UITableViewController {
return true return true
} }
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) { override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete { if editingStyle == .delete {
guard let sections = fetchedResultsController.sections else { guard let sections = fetchedResultsController.sections else {

View File

@ -2,50 +2,58 @@
# #
# Copyright (C) 2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. # 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_arm64 := arm64
GOARCH_armv7 := arm GOARCH_armv7 := arm
GOARCH_x86_64 := amd64 GOARCH_x86_64 := amd64
CGO_FLAGS_x86_64 := -arch x86_64 -isysroot $(shell xcrun --sdk iphonesimulator --show-sdk-path) DEPLOYMENT_CFLAGS := $(DEPLOYMENT_TARGET_CLANG_FLAG_PREFIX)$($(DEPLOYMENT_TARGET_CLANG_ENV_NAME))
CGO_FLAGS_arm64 := -arch arm64 -isysroot $(shell xcrun --sdk iphoneos --show-sdk-path) CGO_FLAGS_x86_64 := -arch x86_64 -isysroot $(shell xcrun --sdk iphonesimulator --show-sdk-path) $(DEPLOYMENT_CFLAGS)
CGO_FLAGS_armv7 := -arch armv7 -isysroot $(shell xcrun --sdk iphoneos --show-sdk-path) 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_x86_64 := $(shell xcrun --sdk iphonesimulator --find clang)
CC_arm64 := $(shell xcrun --sdk iphoneos --find clang) CC_arm64 := $(shell xcrun --sdk iphoneos --find clang)
CC_armv7 := $(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 GOOS := darwin
export CGO_ENABLED := 1 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 $(GOBUILDDIR)/src/.prepared: $(UPSTREAM_FILES) $(DOWNSTREAM_FILES)
find . -name '*.go' -type l -delete rm -rf $(GOBUILDDIR)/src
find . -type d -empty -delete mkdir -p $(subst ../wireguard-go/,$(GOBUILDDIR)/src/git.zx2c4.com/wireguard-go/,$(dir $(UPSTREAM_FILES)))
mkdir -p $(subst ../wireguard-go/,./src/git.zx2c4.com/wireguard-go/,$(dir $(FILES))) mkdir -p $(subst src/,$(GOBUILDDIR)/src/git.zx2c4.com/wireguard-go/,$(dir $(DOWNSTREAM_FILES)))
$(foreach FILE,$(FILES),ln -sf $(abspath $(FILE)) $(subst ../wireguard-go/,./src/git.zx2c4.com/wireguard-go/,$(dir $(FILE)))$(notdir $(FILE));) $(foreach FILE,$(UPSTREAM_FILES),ln -sf $(abspath $(FILE)) $(subst ../wireguard-go/,$(GOBUILDDIR)/src/git.zx2c4.com/wireguard-go/,$(dir $(FILE)))$(notdir $(FILE));)
GOPATH=$(CURDIR) go get -v -d git.zx2c4.com/wireguard-go $(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 $@ touch $@
define libwg-go-a 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))" \ CC="$(CC_$(1))" \
CGO_CFLAGS="$(CGO_FLAGS_$(1))" \ CGO_CFLAGS="$(CGO_FLAGS_$(1))" \
CGO_LDFLAGS="$(CGO_FLAGS_$(1))" \ CGO_LDFLAGS="$(CGO_FLAGS_$(1))" \
GOARCH=$(GOARCH_$(1)) \ GOARCH=$(GOARCH_$(1)) \
GOPATH=$(CURDIR) \ GOPATH=$(GOBUILDDIR) \
go build -tags ios -v -o libwg-go-$(1).a -buildmode c-archive git.zx2c4.com/wireguard-go go build -tags ios -v -o $(GOBUILDDIR)/libwg-go-$(1).a -buildmode c-archive git.zx2c4.com/wireguard-go
@rm -f libwg-go-$(1).h @rm -f $(GOBUILDDIR)/libwg-go-$(1).h
endef 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 $@ $^ xcrun --sdk iphoneos lipo -create -output $@ $^
example: example.c libwg-go.a $(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. -lwg-go -o example example.c xcrun --sdk iphoneos clang -framework CoreFoundation -isysroot $(shell xcrun --sdk iphoneos --show-sdk-path) -arch arm64 -arch armv7 -L$(DESTDIR) -lwg-go -o $@ $<
clean: 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

View File

@ -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