-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathMakefile
More file actions
80 lines (65 loc) · 2.59 KB
/
Copy pathMakefile
File metadata and controls
80 lines (65 loc) · 2.59 KB
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
SHELL := /bin/bash
.DEFAULT_GOAL := help
IOS_DESTINATION ?= $(shell scripts/default-ios-destination.sh)
PACKAGE_SCHEME := SwiftStreamingMarkdown
SAMPLE_DIR := Examples/SwiftStreamingMarkdownSample
SAMPLE_SPEC := $(SAMPLE_DIR)/project.yml
SAMPLE_PROJECT := $(SAMPLE_DIR)/SwiftStreamingMarkdownSample.xcodeproj
SAMPLE_SCHEME := SwiftStreamingMarkdownSample
XCODEGEN ?= xcodegen
SWIFTPM_GIT_ENV := GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=safe.bareRepository GIT_CONFIG_VALUE_0=all
.PHONY: help
help: ## Show available targets.
@color=0; \
if [ -t 1 ] && [ -z "$${NO_COLOR:-}" ] && [ "$${TERM:-}" != "dumb" ]; then color=1; fi; \
COLOR="$$color" awk 'BEGIN { \
FS = ":.*## "; \
if (ENVIRON["COLOR"] == "1") { bold = "\033[1m"; cyan = "\033[36m"; reset = "\033[0m" } \
printf "%sAvailable targets:%s\n", bold, reset \
} /^[a-zA-Z0-9_.-]+:.*## / {printf " %s%-24s%s %s\n", cyan, $$1, reset, $$2}' $(MAKEFILE_LIST)
.PHONY: setup
setup: dev-setup ## Alias for dev-setup.
.PHONY: dev-setup
dev-setup: ## Verify local development tools.
@bash scripts/dev-setup.sh
.PHONY: resolve
resolve: ## Resolve Swift package dependencies.
@$(SWIFTPM_GIT_ENV) swift package resolve
.PHONY: project
project: resolve ## Open the Swift Package in Xcode.
@xed .
.PHONY: generate-sample-project
generate-sample-project: ## Generate the sample app Xcode project.
@command -v "$(XCODEGEN)" >/dev/null || { echo "error: xcodegen not found. Install it with 'brew install xcodegen' or run 'make dev-setup'."; exit 1; }
@"$(XCODEGEN)" generate --spec "$(SAMPLE_SPEC)" --project "$(SAMPLE_DIR)"
.PHONY: sample-project
sample-project: generate-sample-project ## Generate and open the sample app Xcode project.
@xed "$(SAMPLE_PROJECT)"
.PHONY: lint
lint: ## Run SwiftLint in strict mode.
@swiftlint --strict
.PHONY: test
test: ## Run package unit tests.
@$(SWIFTPM_GIT_ENV) xcodebuild test \
-scheme "$(PACKAGE_SCHEME)" \
-destination "$(IOS_DESTINATION)" \
-skipMacroValidation
.PHONY: build-sample
build-sample: generate-sample-project ## Generate and build the sample app.
@$(SWIFTPM_GIT_ENV) xcodebuild build \
-project "$(SAMPLE_PROJECT)" \
-scheme "$(SAMPLE_SCHEME)" \
-configuration Debug \
-destination "$(IOS_DESTINATION)" \
-skipMacroValidation \
CODE_SIGNING_ALLOWED=NO
.PHONY: ci
ci: lint test build-sample ## Run the same checks as CI.
.PHONY: cloc
cloc: ## Count code for Git-tracked files.
@command -v cloc >/dev/null || { echo "error: cloc not found. Install it with 'brew install cloc'."; exit 1; }
@cloc --vcs=git
.PHONY: clean
clean: ## Remove local SwiftPM build products.
@rm -rf .build
@rm -rf "$(SAMPLE_PROJECT)"