-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
128 lines (91 loc) · 3.21 KB
/
Makefile
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
.SILENT:
.SUFFIXES:
SHELL = /bin/sh
MODULES = Futures FuturesSync
FOLDERS = Sources Tests
SWIFTFORMAT := $(shell command -v swiftformat 2>/dev/null)
SWIFTLINT := $(shell command -v swiftlint 2>/dev/null)
JAZZY := $(shell command -v jazzy 2>/dev/null)
DOCKER := $(shell command -v docker 2>/dev/null)
override TOOLCHAIN = swiftlang/swift:nightly-bionic
build:
swift build --configuration debug
build-release:
swift build --configuration release
test:
swift test --enable-test-discovery --configuration debug --sanitize thread $(TESTFLAGS)
test-nosanitize:
swift test --enable-test-discovery --configuration debug $(TESTFLAGS)
test-release:
swift test --enable-test-discovery --configuration release $(TESTFLAGS)
repl:
swift run --repl --configuration debug
clean:
swift package clean
precommit: gyb format lint
pretest: gyb format pristine lint
.PHONY: build build-release test test-nosanitize test-release repl clean precommit pretest
xcodeproj:
swift package generate-xcodeproj --enable-code-coverage
gyb:
for folder in $(FOLDERS); do \
for file in $$(find ./$${folder} -type f -name '*.gyb'); do \
echo "Generating '$${file%.*}'"; \
Scripts/gyb.py --line-directive '' -o "$${file%.*}" "$${file}"; \
done; \
done
format:
ifndef SWIFTFORMAT
$(error "swiftformat not found; install with `brew install swiftformat`")
endif
$(SWIFTFORMAT) .
lint:
ifndef SWIFTLINT
$(error "swiftlint not found; install with `brew install swiftlint`")
endif
$(SWIFTLINT) lint --quiet --strict .
pristine:
Scripts/ensure-pristine.sh
.PHONY: xcodeproj gyb format lint pristine
docs: xcodeproj
ifndef JAZZY
$(error "jazzy not found; install with `[sudo] gem install --no-document jazzy`")
endif
Scripts/make-docs.sh
.PHONY: docs
_docker:
ifndef DOCKER
$(error "docker not found")
endif
LINUX_IMAGE_NAME := 'swift-futures:latest'
linuximage: _docker
$(DOCKER) build --tag '$(LINUX_IMAGE_NAME)' --build-arg TOOLCHAIN="$(TOOLCHAIN)" .
linuxshell: _docker
$(DOCKER) run -it --rm --privileged --volume "$$(pwd):/src" --entrypoint '' '$(LINUX_IMAGE_NAME)' /bin/bash
linuxbuild: _docker
$(DOCKER) run -it --rm --privileged --volume "$$(pwd):/src" '$(LINUX_IMAGE_NAME)' build --configuration debug
linuxrepl: _docker
$(DOCKER) run -it --rm --privileged --volume "$$(pwd):/src" '$(LINUX_IMAGE_NAME)' run --repl --configuration debug
linuxtest: _docker
$(DOCKER) run -it --rm --privileged --volume "$$(pwd):/src" '$(LINUX_IMAGE_NAME)' test --enable-test-discovery --configuration debug --sanitize thread $(TESTFLAGS)
.PHONY: _docker linuximage linuxshell linuxbuild linuxrepl linuxtest
digests: build
digestpath=.digests/$$(date +%s); \
mkdir -p $${digestpath}; \
for module in $(MODULES); do \
xcrun swift-api-digester -dump-sdk -avoid-location -I .build/debug \
-module $${module} -o $${digestpath}/$${module}.json ; \
done
listdigests:
ls .digests 2>/dev/null | cat # it's okay.
apidiagnose:
digestpathA=".digests/$A"; \
digestpathB=".digests/$B"; \
for module in $(MODULES); do \
echo "/* == $${module} == */"; \
xcrun swift-api-digester -diagnose-sdk \
-input-paths $${digestpathA}/$${module}.json \
-input-paths $${digestpathB}/$${module}.json \
2>&1 | sed '/^\s*$$/d' ; \
done
.PHONY: digests listdigests apidiagnose