Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
107 lines (91 loc) · 4.06 KB
/
Copy pathMakefile
File metadata and controls
107 lines (91 loc) · 4.06 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
# Top-level Makefile for TSI (Rust)
PREFIX ?= $(HOME)/.tsi
export PATH := $(HOME)/.cargo/bin:$(PATH)
.PHONY: help test check build clean install uninstall lint fmt deps dev run dev-packages validate
help:
@echo "TSI Makefile"
@echo ""
@echo "Targets:"
@echo " deps - Install/verify dependencies (Rust toolchain, crates)"
@echo " dev - Development build (fast, debug)"
@echo " dev-packages - Sync package definitions from in-repo tsi-packages to PREFIX (requires submodule init)"
@echo " build - Build TSI (release)"
@echo " run - Run TSI (development)"
@echo " test - Run tests"
@echo " check - Everything CI checks: fmt + clippy + tests"
@echo " validate - Smoke-test named packages in Linux containers (PKGS=\"a b\")"
@echo " lint - Run clippy"
@echo " fmt - Check code formatting"
@echo " clean - Clean build artifacts"
@echo " install - Install TSI to PREFIX (default: ~/.tsi)"
@echo " uninstall - Remove TSI from PREFIX (default: ~/.tsi)"
@echo ""
@echo "Usage:"
@echo " make deps # First-time: install Rust, fetch crates"
@echo " make dev # Development build"
@echo " make dev-packages # After git submodule update --init tsi-packages"
@echo " make validate PKGS=\"zlib bzip2\" # smoke-test on linux/arm64 + linux/amd64"
@echo " make install PREFIX=/opt/tsi"
@echo " make uninstall PREFIX=/opt/tsi"
deps:
@if command -v cargo >/dev/null 2>&1; then \
echo "Fetching crate dependencies..."; \
cargo fetch; \
else \
echo "Installing Rust toolchain..."; \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y -q; \
. "$$HOME/.cargo/env" && echo "Fetching crate dependencies..." && cargo fetch; \
fi
dev: deps
@echo "Building TSI (development)..."
cargo build
run: dev
cargo run -- $(ARGS)
# Sync package definitions from in-repo tsi-packages (requires submodule init)
dev-packages:
@test -d tsi-packages/packages || (echo "Run: git submodule update --init tsi-packages"; exit 1)
cargo run -- update --local tsi-packages/packages --prefix $(PREFIX)
build: deps
@echo "Building TSI..."
cargo build --release
test:
@echo "Running tests..."
cargo test
# Same gates as the rust-lint job in .github/workflows/ci.yml — run this before pushing.
check: fmt lint test
# Smoke-test one or two packages in Linux containers (needs docker).
#
# Building the catalogue is CI's job, not a laptop's: test-build-packages.yml
# builds changed packages on three platforms per PR, and validate-all-packages.yml
# rebuilds everything weekly. Use this to sanity-check a definition you are
# editing, and let CI produce the results that count.
PKGS ?=
validate:
@if [ -z "$(PKGS)" ]; then echo "Name the package(s) to smoke-test, e.g.:"; echo " make validate PKGS=\"zlib bzip2\""; echo ""; echo "Full-catalogue runs belong in CI (validate-all-packages.yml),"; echo "not here — they take hours and tens of GB per architecture."; exit 2; fi
./docker/validate-packages.sh $(PKGS)
lint:
@echo "Running clippy..."
cargo clippy --all-targets -- -D warnings
fmt:
@echo "Checking formatting..."
cargo fmt --check
clean:
@echo "Cleaning build artifacts..."
cargo clean
rm -rf docker/bin artifacts 2>/dev/null || true
install: build
@echo "Installing TSI to $(PREFIX)..."
@mkdir -p $(PREFIX)/bin
@cp target/release/tsi $(PREFIX)/bin/tsi 2>/dev/null || cp target/release/tsi.exe $(PREFIX)/bin/tsi.exe
@chmod +x $(PREFIX)/bin/tsi 2>/dev/null || true
@mkdir -p $(PREFIX)/share/completions
@test -f completions/tsi.bash && cp completions/tsi.bash $(PREFIX)/share/completions/ || true
@test -f completions/tsi.zsh && cp completions/tsi.zsh $(PREFIX)/share/completions/ || true
@echo "Installed. Add to PATH: export PATH=\"$(PREFIX)/bin:\$$PATH\""
uninstall:
@echo "Uninstalling TSI from $(PREFIX)..."
@rm -f $(PREFIX)/bin/tsi $(PREFIX)/bin/tsi.exe
@rm -rf $(PREFIX)/share/completions
@-rmdir $(PREFIX)/share 2>/dev/null || true
@-rmdir $(PREFIX)/bin 2>/dev/null || true
@echo "TSI uninstalled. Remove $(PREFIX)/bin from your PATH if present."