-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
120 lines (96 loc) · 3.48 KB
/
Copy pathMakefile
File metadata and controls
120 lines (96 loc) · 3.48 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
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
# SPDX-License-Identifier: Apache-2.0
#
# Copyright 2026 Atelier Socle SAS
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Makefile — swift-rtmp-kit
#
# Targets for building, testing, linting, formatting, and installing
# the rtmp-cli CLI tool.
# ---------- Variables ----------
PREFIX ?= /usr/local/bin
BINARY_NAME = rtmp-cli
BUILD_DIR = .build/release
# ---------- Phony targets ----------
.PHONY: build build-release test lint format format-check \
install uninstall clean coverage all help
# ---------- Build ----------
## Build the project (debug)
build:
swift build
## Build the project (release, optimised)
build-release:
swift build -c release
# ---------- Quality ----------
## Run tests
test:
swift test
## Lint sources with SwiftLint
lint:
swiftlint lint --quiet
## Format sources in-place with swift-format
format:
swift-format format -r -i Sources/ Tests/
## Check formatting without modifying files
format-check:
swift-format lint -r Sources/ Tests/
# ---------- Coverage ----------
## Run tests with code coverage and display a summary report
coverage:
swift test --enable-code-coverage
@PROF_DATA=$$(find .build -name "default.profdata" -type f | head -1); \
TEST_BIN=$$(find .build/debug -name "swift-rtmp-kitPackageTests" -type f ! -name "*.o" -not -path "*.dSYM*" | head -1); \
if [ -n "$$PROF_DATA" ] && [ -n "$$TEST_BIN" ]; then \
xcrun llvm-cov report "$$TEST_BIN" \
-instr-profile="$$PROF_DATA" \
-ignore-filename-regex='\.build|Tests'; \
else \
echo "Coverage data not found."; \
fi
# ---------- Install / Uninstall ----------
## Build release and install the binary to PREFIX (/usr/local/bin)
install: build-release
@mkdir -p $(PREFIX)
install -m 755 $(BUILD_DIR)/$(BINARY_NAME) $(PREFIX)/$(BINARY_NAME)
@echo "$(BINARY_NAME) installed to $(PREFIX)/$(BINARY_NAME)"
## Remove the binary from PREFIX
uninstall:
rm -f $(PREFIX)/$(BINARY_NAME)
@echo "$(BINARY_NAME) removed from $(PREFIX)/$(BINARY_NAME)"
# ---------- Clean ----------
## Remove all build artifacts
clean:
swift package clean
# ---------- Aggregate ----------
## Run the full quality pipeline: lint + format-check + build + test
all: lint format-check build test
# ---------- Help ----------
## Display available targets
help:
@echo "swift-rtmp-kit — Makefile targets"
@echo ""
@echo " build Build the project (debug)"
@echo " build-release Build the project (release)"
@echo " test Run tests"
@echo " lint Lint sources with SwiftLint"
@echo " format Format sources in-place"
@echo " format-check Check formatting (no changes)"
@echo " coverage Run tests with code coverage report"
@echo " install Build release + install to PREFIX (default: /usr/local/bin)"
@echo " uninstall Remove the binary from PREFIX"
@echo " clean Remove all build artifacts"
@echo " all lint + format-check + build + test"
@echo " help Show this help"
@echo ""
@echo "Variables:"
@echo " PREFIX=$(PREFIX)"