forked from fabriziosalmi/l0-cache
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
77 lines (60 loc) · 3.25 KB
/
Copy pathMakefile
File metadata and controls
77 lines (60 loc) · 3.25 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
# l0-cache — Cross-platform build targets
# Usage:
# make build # Build for current platform (release)
# make build-linux # Cross-compile for Linux x86_64 (glibc)
# make build-alpine # Cross-compile for Alpine/musl (fully static)
# make build-all # Build all targets
# make install # Install to /usr/local/bin
# make test # Run all tests
# make lint # Clippy + format check
.PHONY: build build-linux build-alpine build-all install test lint clean
# ── Current platform ────────────────────────────────────────────────
build:
cargo build --release
@echo "Built: target/release/l0-cache ($$(du -h target/release/l0-cache | cut -f1))"
test:
cargo test
lint:
cargo clippy -- -D warnings
cargo fmt -- --check
# ── Cross-compilation ───────────────────────────────────────────────
# Prerequisites:
# brew install filosottile/musl-cross/musl-cross # for musl target
# rustup target add x86_64-unknown-linux-gnu
# rustup target add x86_64-unknown-linux-musl
build-linux:
@echo "Building for Linux x86_64 (glibc, dynamic)..."
cargo build --release --target x86_64-unknown-linux-gnu
@echo "Built: target/x86_64-unknown-linux-gnu/release/l0-cache"
build-alpine:
@echo "Building for Alpine/musl (fully static)..."
CC_x86_64_unknown_linux_musl=x86_64-linux-musl-gcc \
cargo build --release --target x86_64-unknown-linux-musl
@echo "Built: target/x86_64-unknown-linux-musl/release/l0-cache"
build-all: build build-linux build-alpine
@echo ""
@echo "All targets built:"
@ls -la target/release/l0-cache 2>/dev/null || true
@ls -la target/x86_64-unknown-linux-gnu/release/l0-cache 2>/dev/null || true
@ls -la target/x86_64-unknown-linux-musl/release/l0-cache 2>/dev/null || true
# ── Install ─────────────────────────────────────────────────────────
install: build
cp target/release/l0-cache /usr/local/bin/l0-cache
@echo "Installed to /usr/local/bin/l0-cache"
@l0-cache --version
# ── Deploy to remote (via scp) ──────────────────────────────────────
# Usage: make deploy HOST=myserver
# Assumes the binary is already built for the target architecture.
HOST ?= ""
REMOTE_BIN ?= /usr/local/bin/l0-cache
deploy-linux: build-linux
@test -n "$(HOST)" || (echo "Usage: make deploy-linux HOST=user@host" && exit 1)
scp target/x86_64-unknown-linux-gnu/release/l0-cache $(HOST):$(REMOTE_BIN)
ssh $(HOST) "chmod +x $(REMOTE_BIN) && l0-cache --version"
deploy-alpine: build-alpine
@test -n "$(HOST)" || (echo "Usage: make deploy-alpine HOST=user@host" && exit 1)
scp target/x86_64-unknown-linux-musl/release/l0-cache $(HOST):$(REMOTE_BIN)
ssh $(HOST) "chmod +x $(REMOTE_BIN) && l0-cache --version"
# ── Clean ───────────────────────────────────────────────────────────
clean:
cargo clean