-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
127 lines (106 loc) · 3.01 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
print-%: ; @echo $* = $($*)
PROJECT_NAME = HttpX
COPYRIGHT = "Ruiyang Sun. All Rights Reserved."
SOURCE_FOLDERS = Sources Tests
SHELL = /bin/bash
HOME = $(shell echo $$HOME)
SWIFT_VERSION = 5.10
# Swift Installation
install-brew:
$(SHELL) -c "$$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
install-swiftenv:
brew install kylef/formulae/swiftenv
install-Swift:
if command -v swiftenv >/dev/null; then \
swiftenv install $(SWIFT_VERSION); \
swiftenv local $(SWIFT_VERSION); \
else \
echo "swiftenv not found"; \
echo "install swiftenv by brew first"; \
if command -v brew >/dev/null; then \
make install-swiftenv; \
else \
echo "brew not found"; \
echo "install brew first"; \
make install-brew; \
make install-swiftenv; \
fi; \
swiftenv install $(SWIFT_VERSION); \
swiftenv local $(SWIFT_VERSION); \
fi
# Init Swift Environment
init-swift:
swiftenv install $(SWIFT_VERSION)
swiftenv local $(SWIFT_VERSION)
# Build
build:
swift build
build-verbose:
swift build --vv
# Test
test: build
swift test
# Clean
clean:
swift package clean
clean-dist:
rm -rf .build
make clean
# Tools Installation
pre-commit-install:
if ! command -v pre-commit >/dev/null; then \
if ! command -v brew >/dev/null; then \
echo "brew not found"; \
echo "install brew first"; \
make install-brew; \
fi; \
brew install pre-commit; \
fi
swiftlint-install:
if ! command -v swiftlint >/dev/null; then \
if ! command -v brew >/dev/null; then \
echo "brew not found"; \
echo "install brew first"; \
make install-brew; \
fi; \
brew install swiftlint; \
fi
go-install:
# requires go >= 1.16
if ! command -v go >/dev/null; then \
if ! command -v brew >/dev/null; then \
echo "brew not found"; \
echo "install brew first"; \
make install-brew; \
fi; \
brew install go; \
fi
swiftformat-install:
if ! command -v swiftformat >/dev/null; then \
if ! command -v brew >/dev/null; then \
echo "brew not found"; \
echo "install brew first"; \
make install-brew; \
fi; \
brew install swiftformat; \
fi
addlicense-install: go-install
command -v $(HOME)/go/bin/addlicense || go get -u github.com/google/addlicense
# Tools
pre-commit: pre-commit-install
pre-commit --version
pre-commit run --all-files
swiftlint: swiftlint-install
swiftlint --version
swiftlint --fix --config .swiftlint.yaml
swiftformat: swiftformat-install
swiftformat --version
swiftformat . --verbose
addlicense: addlicense-install
$(HOME)/go/bin/addlicense -c $(COPYRIGHT) -l apache -y 2024-$(shell date +"%Y") $(SOURCE_FOLDERS)
$(HOME)/go/bin/addlicense -c $(COPYRIGHT) -l apache -y 2024-$(shell date +"%Y") -c $(SOURCE_FOLDERS)
addlicense-directly:
brew install go
command -v $(HOME)/go/bin/addlicense || go install github.com/google/addlicense@latest
$(HOME)/go/bin/addlicense -c $(COPYRIGHT) -l apache -y 2024-$(shell date +"%Y") $(SOURCE_FOLDERS)
$(HOME)/go/bin/addlicense -c $(COPYRIGHT) -l apache -y 2024-$(shell date +"%Y") -c $(SOURCE_FOLDERS)