From 9f5612f93f2661a0369c8662394b8f8a35341e27 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 31 Oct 2018 04:02:36 +0100 Subject: wireguard-go-bridge: extract version for consumption by network extension Signed-off-by: Jason A. Donenfeld --- WireGuard/WireGuard.xcodeproj/project.pbxproj | 27 +++++++++++++++++++--- .../UI/iOS/SettingsTableViewController.swift | 2 +- WireGuard/WireGuard/WireGuard-Bridging-Header.h | 5 +--- .../WireGuardNetworkExtension-Bridging-Header.h | 6 +---- wireguard-go-bridge/Makefile | 10 ++++++-- 5 files changed, 35 insertions(+), 15 deletions(-) diff --git a/WireGuard/WireGuard.xcodeproj/project.pbxproj b/WireGuard/WireGuard.xcodeproj/project.pbxproj index efdf1dd..cdcdef6 100644 --- a/WireGuard/WireGuard.xcodeproj/project.pbxproj +++ b/WireGuard/WireGuard.xcodeproj/project.pbxproj @@ -38,7 +38,6 @@ 6FDEF8082187442100D8FBF6 /* WgQuickConfigFileWriter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FDEF8072187442100D8FBF6 /* WgQuickConfigFileWriter.swift */; }; 6FF4AC1F211EC472002C96EB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6FF4AC1E211EC472002C96EB /* Assets.xcassets */; }; 6FF4AC22211EC472002C96EB /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6FF4AC20211EC472002C96EB /* LaunchScreen.storyboard */; }; - 6FF4AC472120B9E0002C96EB /* NetworkExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6FF4AC462120B9E0002C96EB /* NetworkExtension.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -98,7 +97,7 @@ 6F7774E9217229DB006A79B3 /* IPAddressRange.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IPAddressRange.swift; sourceTree = ""; }; 6F7774EE21722D97006A79B3 /* TunnelsManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TunnelsManager.swift; sourceTree = ""; }; 6F7774F221774263006A79B3 /* TunnelEditTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TunnelEditTableViewController.swift; sourceTree = ""; }; - 6FDEF7E321846C1A00D8FBF6 /* libwg-go.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = "libwg-go.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 6FDEF7E321846C1A00D8FBF6 /* libwg-go.a */ = {isa = PBXFileReference; explicitFileType = "archive.ar"; path = "libwg-go.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 6FDEF7E52185EFAF00D8FBF6 /* QRScanViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QRScanViewController.swift; sourceTree = ""; }; 6FDEF7F621863B6100D8FBF6 /* unzip.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = unzip.c; sourceTree = ""; }; 6FDEF7F721863B6100D8FBF6 /* zip.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = zip.c; sourceTree = ""; }; @@ -131,7 +130,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 6FF4AC472120B9E0002C96EB /* NetworkExtension.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -341,6 +339,7 @@ isa = PBXNativeTarget; buildConfigurationList = 6FF4AC26211EC472002C96EB /* Build configuration list for PBXNativeTarget "WireGuard" */; buildPhases = ( + 6B87860E2189532500C099FB /* Extract wireguard-go Version */, 6FF4AC10211EC46F002C96EB /* Sources */, 6FF4AC11211EC46F002C96EB /* Frameworks */, 6FF4AC12211EC46F002C96EB /* Resources */, @@ -423,6 +422,28 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 6B87860E2189532500C099FB /* Extract wireguard-go Version */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Extract wireguard-go Version"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "exec make -C \"$PROJECT_DIR/../wireguard-go-bridge\" version-header\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 6F5D0C16218352EF000F85AD /* Sources */ = { isa = PBXSourcesBuildPhase; diff --git a/WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift b/WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift index 027286e..edb3a60 100644 --- a/WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift @@ -134,7 +134,7 @@ extension SettingsTableViewController { let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "Unknown version" cell.value = appVersion } else if (field == .goBackendVersion) { - cell.value = "TODO" + cell.value = WIREGUARD_GO_VERSION } return cell } else { diff --git a/WireGuard/WireGuard/WireGuard-Bridging-Header.h b/WireGuard/WireGuard/WireGuard-Bridging-Header.h index 61ddc07..4fe53a7 100644 --- a/WireGuard/WireGuard/WireGuard-Bridging-Header.h +++ b/WireGuard/WireGuard/WireGuard-Bridging-Header.h @@ -1,7 +1,4 @@ -// -// Use this file to import your target's public headers that you would like to expose to Swift. -// - #include "x25519.h" #include "unzip.h" #include "zip.h" +#include "wireguard-go-version.h" diff --git a/WireGuard/WireGuardNetworkExtension/WireGuardNetworkExtension-Bridging-Header.h b/WireGuard/WireGuardNetworkExtension/WireGuardNetworkExtension-Bridging-Header.h index 45d903a..8184ff0 100644 --- a/WireGuard/WireGuardNetworkExtension/WireGuardNetworkExtension-Bridging-Header.h +++ b/WireGuard/WireGuardNetworkExtension/WireGuardNetworkExtension-Bridging-Header.h @@ -1,5 +1 @@ -// -// Use this file to import your target's public headers that you would like to expose to Swift. -// - -#import "../../wireguard-go-bridge/wireguard.h" +#include "../../wireguard-go-bridge/wireguard.h" diff --git a/wireguard-go-bridge/Makefile b/wireguard-go-bridge/Makefile index 349977f..00c8e35 100644 --- a/wireguard-go-bridge/Makefile +++ b/wireguard-go-bridge/Makefile @@ -24,6 +24,7 @@ export GOOS := darwin export CGO_ENABLED := 1 build: $(DESTDIR)/libwg-go.a +version-header: $(DESTDIR)/wireguard-go-version.h define copy-src-to-build $(subst $(1),$(BUILDDIR)/,$(2)): $(2) @@ -55,6 +56,9 @@ $(BUILDDIR)/libwg-go-$(1).a: $(BUILDDIR)/.prepared endef $(foreach ARCH,$(ARCHS),$(eval $(call libwg-go-a,$(ARCH)))) +$(DESTDIR)/wireguard-go-version.h: ../wireguard-go/version.go + sed -n 's/.*WireGuardGoVersion = "\(.*\)"/#define WIREGUARD_GO_VERSION "\1"/p' "$^" > "$@" + $(DESTDIR)/libwg-go.a: $(foreach ARCH,$(ARCHS),$(BUILDDIR)/libwg-go-$(ARCH).a) @mkdir -vp "$(DESTDIR)" xcrun --sdk iphoneos lipo -create -output "$@" $^ @@ -62,7 +66,9 @@ $(DESTDIR)/libwg-go.a: $(foreach ARCH,$(ARCHS),$(BUILDDIR)/libwg-go-$(ARCH).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"$(DESTDIR)" -lwg-go -o "$@" "$<" +example: $(DESTDIR)/example + clean: - rm -rf "$(BUILDDIR)" "$(DESTDIR)/libwg-go.a" "$(DESTDIR)/example" + rm -rf "$(BUILDDIR)" "$(DESTDIR)/libwg-go.a" "$(DESTDIR)/example" "$(DESTDIR)/wireguard-go-version.h" -.PHONY: clean build +.PHONY: clean build example version-header -- cgit v1.2.3-59-g8ed1b