Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
95 lines (74 loc) · 2.58 KB
/
Copy pathMakefile
File metadata and controls
95 lines (74 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
.PHONY: ci ci-go ci-macos fmt fmt-check mod-tidy mod-tidy-check vet build test test-race swift-check swift-test scanner scanner-ci release verify-embedded-helper example clean
APP := WifiScanner.app
GO ?= go
SWIFTC ?= swiftc
# Pin to match scanner/Info.plist LSMinimumSystemVersion and the shipped
# helper target in scripts/build-wifi-scanner-app.sh.
SWIFT_TARGET ?= arm64-apple-macos13.0
GO_FILES := $(shell find . -name '*.go' -not -path './.git/*')
SWIFT_FILES := $(shell find scanner/Sources -name '*.swift' -type f | sort)
SWIFT_LIBRARY_FILES := $(shell find scanner/Sources -name '*.swift' -type f -not -name 'main.swift' | sort)
SWIFT_TEST_FILES := $(shell find scanner/Tests -name '*.swift' -type f | sort)
ci: ci-go
ci-go: fmt-check mod-tidy-check vet test-race build
ci-macos: ci-go swift-check swift-test scanner-ci
fmt:
gofmt -w $(GO_FILES)
fmt-check:
@files="$$(gofmt -l $(GO_FILES))"; \
if [ -n "$$files" ]; then \
printf '%s\n' "$$files"; \
exit 1; \
fi
mod-tidy:
$(GO) mod tidy
mod-tidy-check:
$(GO) mod tidy
git diff --exit-code -- go.mod go.sum
vet:
$(GO) vet ./...
build:
$(GO) build ./...
test:
$(GO) test ./...
test-race:
$(GO) test -race ./...
swift-check:
$(SWIFTC) -typecheck \
-target $(SWIFT_TARGET) \
-framework CoreWLAN \
-framework CoreLocation \
-framework Security \
$(SWIFT_FILES)
swift-test:
@set -e; \
tmp="$$(mktemp -d)"; \
trap 'rm -rf "$$tmp"' EXIT; \
$(SWIFTC) -D TESTING -parse-as-library -Onone \
-target $(SWIFT_TARGET) \
-framework CoreWLAN \
-framework CoreLocation \
-framework Security \
-o "$$tmp/WifiScannerTests" \
$(SWIFT_LIBRARY_FILES) \
$(SWIFT_TEST_FILES); \
"$$tmp/WifiScannerTests"
# Local build: compile + sign with whatever cert is available.
# Output stays at the repo root, used via $MACWIFI_APP for dev iteration.
scanner: $(APP)
$(APP): $(SWIFT_FILES) scanner/Info.plist scanner/entitlements.plist scripts/build-wifi-scanner-app.sh scripts/wifi-scanner-source-digest.sh
"$(CURDIR)/scripts/build-wifi-scanner-app.sh" --repo-root "$(CURDIR)" --bundle "$(CURDIR)/$(APP)"
scanner-ci:
rm -rf $(APP)
SIGN_IDENTITY=- $(MAKE) scanner
# Release build: sign with Developer ID, notarize, staple, stage for embed.
# Run this before cutting a new version of the Go module.
# Prereqs (one-time): `xcrun notarytool store-credentials macwifi-notary ...`
release:
"$(CURDIR)/scripts/release-wifi-scanner-app.sh" --repo-root "$(CURDIR)"
verify-embedded-helper:
"$(CURDIR)/scripts/verify-wifi-scanner-app.sh" --repo-root "$(CURDIR)"
example: scanner
MACWIFI_APP=$(PWD)/$(APP) go run ./examples/scan
clean:
rm -rf $(APP)