-
Notifications
You must be signed in to change notification settings - Fork 165
/
Makefile
91 lines (74 loc) · 2.62 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
# Copyright 2021 Twitter, Inc.
# SPDX-License-Identifier: Apache-2.0
NAME = TwitterTextEditor
BUILD_SCHEME = $(NAME)-Package
BUILD_DESTINATION = generic/platform=iOS
BUILD_CONFIGURATION = Debug
BUILD_DERIVED_DATA_PATH = .build/derived_data
# Use `xcodebuild -showdestinations -scheme ...` for the destinations.
# See also <https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md>
# for commonly available destinations.
TEST_DESTINATION = platform=iOS Simulator,name=iPhone 14
# This path depends on `BUILD_DESTINATION`.
DOCBUILD_DOCARCHIVE_PATH = $(BUILD_DERIVED_DATA_PATH)/Build/Products/$(BUILD_CONFIGURATION)-iphoneos/$(NAME).doccarchive
GITHUB_REPOSITORY_NAME = $(NAME)
GITHUB_PAGES_PATH ?= .gh-pages
DOCUMENTATION_SERVER_ROOT_PATH = .build/documentation
DOCUMENTATION_SERVER_PORT = 3000
# This is simulating how GitHub pages URL is represented, which is `https://$(USERNAME).github.io/$(REPOSITORY_NAME)/`.
DOCUMENTATION_OUTPUT_PATH = $(DOCUMENTATION_SERVER_ROOT_PATH)/$(GITHUB_REPOSITORY_NAME)
DOCUMENTATION_ROOT_TARGET_NAME = twittertexteditor
XCODEBUILD = xcodebuild
DOCC = xcrun docc
PYTHON3 = xcrun python3
SWIFT = swift
SWIFTLINT = swiftlint
.PHONY: all
all: fix test
.PHONY: clean
clean:
git clean -dfX
.PHONY: fix
fix:
$(SWIFTLINT) --fix
.PHONY: lint
lint:
$(SWIFTLINT) --strict
.PHONY: build
build:
$(XCODEBUILD) \
-scheme "$(BUILD_SCHEME)" \
-destination "$(BUILD_DESTINATION)" \
-configuration "$(BUILD_CONFIGURATION)" \
-derivedDataPath "$(BUILD_DERIVED_DATA_PATH)" \
build
.PHONY: test
test:
$(XCODEBUILD) \
-scheme "$(BUILD_SCHEME)" \
-destination "$(TEST_DESTINATION)" \
-configuration "$(BUILD_CONFIGURATION)" \
-derivedDataPath "$(BUILD_DERIVED_DATA_PATH)" \
test
.PHONY: docbuild
docbuild:
$(XCODEBUILD) \
-scheme "$(BUILD_SCHEME)" \
-destination "$(BUILD_DESTINATION)" \
-configuration "$(BUILD_CONFIGURATION)" \
-derivedDataPath "$(BUILD_DERIVED_DATA_PATH)" \
docbuild
.PHONY: doc
doc: docbuild
mkdir -p "$(DOCUMENTATION_OUTPUT_PATH)"
$(DOCC) process-archive transform-for-static-hosting "$(DOCBUILD_DOCARCHIVE_PATH)" \
--output-path "$(DOCUMENTATION_OUTPUT_PATH)" \
--hosting-base-path "/$(GITHUB_REPOSITORY_NAME)"
.PHONY: doc-server
doc-server: doc
@echo "Documentation is available at <http://localhost:$(DOCUMENTATION_SERVER_PORT)/$(GITHUB_REPOSITORY_NAME)/documentation/$(DOCUMENTATION_ROOT_TARGET_NAME)>"
$(PYTHON3) -m http.server --directory "$(DOCUMENTATION_SERVER_ROOT_PATH)" $(DOCUMENTATION_SERVER_PORT)
.PHONY: ghpages
ghpages: doc
mkdir -p "$(GITHUB_PAGES_PATH)"
rsync -av8 --exclude .git --delete "$(DOCUMENTATION_OUTPUT_PATH)"/ "$(GITHUB_PAGES_PATH)"/