Skip to content

Commit 9c61910

Browse files
committed
Makefile/swift: update Makefile and add support for iOS
updates tailscale/tailscale#13937 Adds a Makefile for building various targets. Adds support for building iOS compatible libtailscale_ios.a. Removes SOCKS5 support for iOS where it looks like the CFNetwork support is lacking.
1 parent 9d45e58 commit 9c61910

File tree

18 files changed

+701
-49
lines changed

18 files changed

+701
-49
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ libtailscale.so
22
libtailscale.a
33
libtailscale.h
44
libtailscale.tar*
5+
libtailscale_ios.a
6+
libtailscale_ios.h
57

68
/tstestcontrol/libtstestcontrol.a
79
/tstestcontrol/libtstestcontrol.h

Makefile

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Copyright (c) Tailscale Inc & AUTHORS
2+
# SPDX-License-Identifier: BSD-3-Clause
3+
4+
## Prettifies xcode output for xcode tests using xcpretty, if it is installed
5+
XCPRETTIFIER := xcpretty
6+
ifeq (, $(shell which $(XCPRETTIFIER)))
7+
XCPRETTIFIER := cat
8+
endif
9+
10+
OUTPUT_DIR=build
11+
12+
libtailscale.a:
13+
go build -buildmode=c-archive -o libtailscale.a
14+
15+
libtailscale_ios.a:
16+
GOOS=ios GOARCH=arm64 CGO_ENABLED=1 CC=$(PWD)/swift/script/clangwrap.sh go build -v -ldflags -w -tags ios -o libtailscale_ios.a -buildmode=c-archive
17+
18+
.PHONY: archive-ios
19+
archive-ios: libtailscale_ios.a
20+
21+
.PHONY: archive
22+
archive: libtailscale.a ## Builds libtailscale.a for the target platform
23+
24+
# Builds a shared library for use with Swift Package Manager
25+
.PHONY: shared
26+
shared: ## Builds libtailscale.dylib for the target platform
27+
go build -v -buildmode=c-shared
28+
29+
.PHONY: tailscalekit-macos
30+
tailscalekit-macos: libtailscale.a ## Builds TailscaleKit for macos to swift/build/Build/Products/Release
31+
cd swift && \
32+
mkdir -p build && \
33+
xcodebuild build -scheme "TailscaleKit (macOS)" -derivedDataPath build -configuration Release -destination 'platform=macOS,arch=arm64' | $(XCPRETTIFIER)
34+
35+
.PHONY: tailscalekit-ios
36+
tailscalekit-ios: libtailscale_ios.a ## Builds TailscaleKit for iOS to swift/build/Build/Products/Release
37+
cd swift && \
38+
mkdir -p build && \
39+
xcodebuild build -scheme "TailscaleKit (iOS)" -derivedDataPath build -configuration Release -destination 'generic/platform=iOS' | $(XCPRETTIFIER)
40+
41+
.PHONY: test-macos
42+
test-macos: libtailscale.a ## Run tests for macOS
43+
cd swift && \
44+
xcodebuild test -scheme TailscaleKitXCTests -derivedDataPath build -configuration Debug -destination 'platform=macOS,arch=arm64' | $(XCPRETTIFIER)
45+
46+
.PHONY: clean
47+
clean: ## Clean up build artifacts
48+
rm -f libtailscale.a
49+
rm -f libtailscale_ios.a
50+
rm -f libtailscale.dylib
51+
rm -rf swift/build
52+
53+
.PHONY: help
54+
help: ## Show this help
55+
@echo "\nSpecify a command. The choices are:\n"
56+
@grep -hE '^[0-9a-zA-Z_-]+:.*?## .*$$' ${MAKEFILE_LIST} | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[0;36m%-12s\033[m %s\n", $$1, $$2}'
57+
@echo ""
58+
59+
.DEFAULT_GOAL := help

swift/Makefile

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)