forked from twitter/TwitterTextEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
104 lines (83 loc) · 2.66 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
# Copyright 2021 Twitter, Inc.
# SPDX-License-Identifier: Apache-2.0
NAME = TwitterTextEditor
BUILD_PROJECT = $(NAME).xcodeproj
BUILD_SCHEME = $(NAME)-Package
BUILD_SDK = iphonesimulator
BUILD_DERIVED_DATA_PATH = .build/derived_data
# Use `use `xcodebuild -showdestinations -scheme ...` for the destinations.
# See also <https://github.com/actions/virtual-environments/blob/main/images/macos/macos-10.15-Readme.md>
# for commonly available destinations.
TEST_DESTINATION = platform=iOS Simulator,name=iPhone 11
DOCUMENTATION_SOURCE_FILES = Sources/*/*.swift
DOCUMENTATION_SUPPLIMENT_FILES = Resources/Documentation/*.md
DOCUMENTATION_OUTPUT_PATH = .build/documentation
GITHUB_PAGES_PATH ?= .gh-pages
GITHUB_PAGES_DOCUMENTATION_PATH = $(GITHUB_PAGES_PATH)/doc
XCODEBUILD = xcodebuild
SWIFT = swift
SWIFTLINT = swiftlint
RUBY_BIN_PATH = /usr/bin
RUBY = $(RUBY_BIN_PATH)/ruby
BUNDLE = $(RUBY_BIN_PATH)/bundle
.PHONY: all
all: correct test
.PHONY: clean
clean:
git clean -dfX
.bundle: Gemfile
$(BUNDLE) install --path "$@"
touch "$@"
.PHONY: bundle
bundle: .bundle
.PHONY: correct
correct: .bundle
$(SWIFTLINT) autocorrect
$(BUNDLE) exec rubocop --auto-correct-all
.PHONY: lint
lint: .bundle
$(SWIFTLINT)
$(BUNDLE) exec rubocop
$(BUILD_PROJECT): Package.swift Sources/**/* Tests/**/*
$(SWIFT) package generate-xcodeproj
touch "$@"
.PHONY: build
build: $(BUILD_PROJECT)
$(XCODEBUILD) \
-project "$<" \
-scheme "$(BUILD_SCHEME)" \
-derivedDataPath "$(BUILD_DERIVED_DATA_PATH)" \
-sdk "$(BUILD_SDK)" \
build
.PHONY: test
test: $(BUILD_PROJECT)
$(XCODEBUILD) \
-project "$<" \
-scheme "$(BUILD_SCHEME)" \
-derivedDataPath "$(BUILD_DERIVED_DATA_PATH)" \
-destination "$(TEST_DESTINATION)" \
test
# NOTE: Double quote for `--include` is important to let Jazzy exapand the wildcard.
$(DOCUMENTATION_OUTPUT_PATH): .bundle .jazzy.yaml $(BUILD_PROJECT) $(DOCUMENTATION_SUPPLIMENT_FILES) $(DOCUMENTATION_SOURCE_FILES)
mkdir -p "$@"
$(BUNDLE) exec jazzy \
--output "$@" \
--clean \
--module $(NAME) \
--use-safe-filenames \
--build-tool-arguments "-project,$(BUILD_PROJECT),-scheme,$(BUILD_SCHEME),-sdk,$(BUILD_SDK),-derivedDataPath,$(BUILD_DERIVED_DATA_PATH)" \
--include "$(DOCUMENTATION_SOURCE_FILES)"
.PHONY: doc
doc: $(DOCUMENTATION_OUTPUT_PATH)
.PHONY: doc-server
doc-server: .bundle doc
@$(BUNDLE) exec $(RUBY) Scripts/docserver.rb \
-d "$(DOCUMENTATION_OUTPUT_PATH)" \
-c "make doc" \
$(DOCUMENTATION_SUPPLIMENT_FILES) \
$(DOCUMENTATION_SOURCE_FILES)
$(GITHUB_PAGES_DOCUMENTATION_PATH): $(DOCUMENTATION_OUTPUT_PATH)
mkdir -p "$@"
rsync -av8 --exclude .git --exclude docsets --delete "$<"/ "$@"/
.PHONY: ghpages
ghpages: $(GITHUB_PAGES_DOCUMENTATION_PATH)