|
| 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 |
0 commit comments