forked from nahitheper/SQLite.swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
76 lines (64 loc) · 1.98 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
XCODEBUILD = xcodebuild
BUILD_SCHEME = SQLite Mac
IOS_SIMULATOR = iPhone 14
IOS_VERSION = 16.4
# tool settings
SWIFTLINT_VERSION=0.52.2
SWIFTLINT=bin/swiftlint-$(SWIFTLINT_VERSION)
SWIFTLINT_URL=https://github.com/realm/SwiftLint/releases/download/$(SWIFTLINT_VERSION)/portable_swiftlint.zip
XCBEAUTIFY_VERSION=0.20.0
XCBEAUTIFY=bin/xcbeautify-$(XCBEAUTIFY_VERSION)
ifeq ($(shell uname), Linux)
XCBEAUTIFY_PLATFORM=x86_64-unknown-linux-gnu.tar.xz
else
XCBEAUTIFY_PLATFORM=universal-apple-macosx.zip
endif
XCBEAUTIFY_URL=https://github.com/tuist/xcbeautify/releases/download/$(XCBEAUTIFY_VERSION)/xcbeautify-$(XCBEAUTIFY_VERSION)-$(XCBEAUTIFY_PLATFORM)
CURL_OPTS=--fail --silent -L --retry 3
ifeq ($(BUILD_SCHEME),SQLite iOS)
BUILD_ARGUMENTS = -scheme "$(BUILD_SCHEME)" -destination "platform=iOS Simulator,name=$(IOS_SIMULATOR),OS=$(IOS_VERSION)"
else
BUILD_ARGUMENTS = -scheme "$(BUILD_SCHEME)"
endif
test: $(XCBEAUTIFY)
set -o pipefail; \
$(XCODEBUILD) $(BUILD_ARGUMENTS) test | $(XCBEAUTIFY)
build: $(XCBEAUTIFY)
set -o pipefail; \
$(XCODEBUILD) $(BUILD_ARGUMENTS) | $(XCBEAUTIFY)
lint: $(SWIFTLINT)
$< --strict
lint-fix: $(SWIFTLINT)
$< lint fix
clean:
$(XCODEBUILD) $(BUILD_ARGUMENTS) clean
repl:
@$(XCODEBUILD) $(BUILD_ARGUMENTS) -derivedDataPath $(TMPDIR)/SQLite.swift > /dev/null && \
swift repl -F '$(TMPDIR)/SQLite.swift/Build/Products/Debug'
sloc:
@zsh -c "grep -vE '^ *//|^$$' Sources/**/*.{swift,h} | wc -l"
$(SWIFTLINT):
set -e ; \
curl $(CURL_OPTS) $(SWIFTLINT_URL) -o swiftlint.zip; \
unzip -o swiftlint.zip swiftlint; \
mkdir -p bin; \
mv swiftlint $@ && rm -f swiftlint.zip
$(XCBEAUTIFY):
set -e; \
FILE=$(XCBEAUTIFY_PLATFORM); \
curl $(CURL_OPTS) $(XCBEAUTIFY_URL) -o $$FILE; \
case "$${FILE#*.}" in \
"zip") \
unzip -o $$FILE xcbeautify; \
;; \
"tar.xz") \
tar -xvf $$FILE xcbeautify; \
;; \
*) \
echo "unknown extension $${FILE#*.}!"; \
exit 1; \
;; \
esac; \
mkdir -p bin; \
mv xcbeautify $@ && rm -f $$FILE;
.PHONY: test clean repl sloc