-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
120 lines (84 loc) · 5.75 KB
/
Copy pathMakefile
File metadata and controls
120 lines (84 loc) · 5.75 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
# focal-lens Makefile
# Requires: cargo, protoc (≥ 3.21), protoc-gen-prost, node (≥ 20), npm, uniffi-bindgen-cli
.PHONY: help setup build build-core build-proxy build-ffi \
bindings-ios bindings-android \
dashboard-install dashboard-dev dashboard-build \
test lint fmt clean check-deps
# ── Default ────────────────────────────────────────────────────────────────────
help: ## Show this help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-26s\033[0m %s\n", $$1, $$2}'
# ── Prerequisites ──────────────────────────────────────────────────────────────
check-deps: ## Verify required tools are installed
@echo "Checking dependencies..."
@command -v cargo >/dev/null 2>&1 || { echo "ERROR: cargo not found — install Rust via rustup"; exit 1; }
@command -v protoc >/dev/null 2>&1 || { echo "ERROR: protoc not found — brew install protobuf"; exit 1; }
@command -v node >/dev/null 2>&1 || { echo "ERROR: node not found — install via nvm or brew"; exit 1; }
@command -v npm >/dev/null 2>&1 || { echo "ERROR: npm not found — bundled with node"; exit 1; }
@echo "All required tools present."
# ── Setup ──────────────────────────────────────────────────────────────────────
setup: check-deps dashboard-install ## Install all dependencies (Rust + Node)
@cargo fetch
@echo "Setup complete."
# ── Rust builds ───────────────────────────────────────────────────────────────
build-core: ## Build focal-core (proto codegen + lib)
cargo build -p focal-core
build-proxy: ## Build the focal-proxy binary
cargo build -p focal-proxy
build-ffi: ## Build focal-ffi (cdylib + staticlib) in debug mode
cargo build -p focal-ffi
build: build-core build-proxy build-ffi ## Build all Rust crates
release: ## Build all Rust crates in release mode
cargo build --workspace --profile release
# ── Mobile bindings ───────────────────────────────────────────────────────────
UNIFFI_BINDGEN := cargo run --bin uniffi-bindgen --
bindings-swift: build-ffi ## Generate Swift bindings into mobile/ios/FocalLens/Generated/
@mkdir -p mobile/ios/FocalLens/Generated
$(UNIFFI_BINDGEN) generate \
--library target/debug/libfocal_ffi.dylib \
--language swift \
--out-dir mobile/ios/FocalLens/Generated
bindings-kotlin: build-ffi ## Generate Kotlin bindings into mobile/android/focal-lens/src/main/kotlin/
@mkdir -p mobile/android/focal-lens/src/main/kotlin/io/focallens/sdk/generated
$(UNIFFI_BINDGEN) generate \
--library target/debug/libfocal_ffi.so \
--language kotlin \
--out-dir mobile/android/focal-lens/src/main/kotlin/io/focallens/sdk/generated
bindings: bindings-swift bindings-kotlin ## Generate Swift + Kotlin bindings
# ── Dashboard ─────────────────────────────────────────────────────────────────
dashboard-install: ## Install Node dependencies for the dashboard
cd dashboard && npm install
dashboard-dev: ## Start the Next.js dev server (hot-reload)
cd dashboard && npm run dev
dashboard-build: ## Build the Next.js app for production
cd dashboard && npm run build
dashboard-lint: ## Lint the dashboard TypeScript / TSX
cd dashboard && npm run lint
dashboard-type-check: ## Run TypeScript type-checking on the dashboard
cd dashboard && npm run type-check
# ── Development servers ───────────────────────────────────────────────────────
run-proxy: build-proxy ## Start the focal-proxy server locally
RUST_LOG=focal_proxy=debug,tower_http=debug \
cargo run -p focal-proxy
# ── Testing ───────────────────────────────────────────────────────────────────
test: ## Run all Rust unit + integration tests
cargo test --workspace
test-core: ## Run tests for focal-core only
cargo test -p focal-core
test-proxy: ## Run tests for focal-proxy only
cargo test -p focal-proxy
# ── Code quality ──────────────────────────────────────────────────────────────
lint: ## Run clippy on all Rust crates (warnings = errors in CI)
cargo clippy --workspace --all-targets --all-features -- -D warnings
fmt: ## Format all Rust source code
cargo fmt --all
cd dashboard && npm run format
fmt-check: ## Check formatting without modifying files (CI)
cargo fmt --all -- --check
cd dashboard && npx prettier --check "src/**/*.{ts,tsx,css}"
# ── Clean ─────────────────────────────────────────────────────────────────────
clean: ## Remove all build artefacts
cargo clean
rm -rf dashboard/.next dashboard/node_modules
rm -rf mobile/ios/FocalLens/Generated
rm -rf mobile/android/focal-lens/src/main/kotlin/io/focallens/sdk/generated