-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
139 lines (104 loc) · 4.26 KB
/
Copy pathMakefile
File metadata and controls
139 lines (104 loc) · 4.26 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# TBox developer tasks.
#
# Conventions:
# - `make help` list available targets
# - `make dev` start Tauri in development mode
# - `make build` build a release Tauri bundle
# - `make check` fast Rust type-check + Vue type-check
# - `make lint` clippy + cargo fmt --check
# - `make test` run the Rust test suite
# - `make clean` remove build artifacts (target/, dist/, node_modules/)
SHELL := /bin/zsh
.SHELLFLAGS := -eu -o pipefail -c
# ---- Toolchain --------------------------------------------------------------
PNPM ?= pnpm
CARGO ?= cargo
TAURI ?= $(PNPM) tauri
NODE ?= node
BACKEND_DIR := src-tauri
FRONTEND := .
# Colored output (no-op when stdout is not a TTY).
BOLD := \033[1m
DIM := \033[2m
RESET := \033[0m
# ---- Default goal -----------------------------------------------------------
.DEFAULT_GOAL := help
.PHONY: help
help: ## list available targets
@printf "$(BOLD)TBox$(RESET) developer tasks\n\n"
@printf "$(DIM)Usage:$(RESET) make <target>\n\n"
@awk 'BEGIN {FS = ":.*?## "} \
/^[a-zA-Z0-9_.-]+:.*?## / \
{printf " $(BOLD)%-18s$(RESET) %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@printf "\n$(DIM)Variables:$(RESET) PNPM=$(PNPM), CARGO=$(CARGO), TAURI=$(TAURI)\n"
# ---- Setup ------------------------------------------------------------------
.PHONY: install
install: ## install frontend dependencies (pnpm install)
$(PNPM) install
.PHONY: install-frozen
install-frozen: ## install frontend dependencies using the lockfile verbatim
$(PNPM) install --frozen-lockfile
.PHONY: deps
deps: install ## alias for install
# ---- Development ------------------------------------------------------------
.PHONY: dev
dev: ## start Tauri in development mode
$(TAURI) dev
.PHONY: frontend-dev
frontend-dev: ## start only the Vite dev server (no Rust shell)
$(PNPM) dev
.PHONY: preview
preview: ## preview the production frontend bundle
$(PNPM) preview
# ---- Build ------------------------------------------------------------------
.PHONY: build
build: ## build a release Tauri bundle for the current platform
$(TAURI) build
.PHONY: frontend-build
frontend-build: ## type-check and build the frontend bundle (no Rust bundle)
$(PNPM) build
.PHONY: backend-build
backend-build: ## release-build the Rust binary (no installer)
$(CARGO) build --release --manifest-path $(BACKEND_DIR)/Cargo.toml
# ---- Quality ----------------------------------------------------------------
.PHONY: check
check: ## run all fast type-checks (Rust + Vue)
$(CARGO) check --manifest-path $(BACKEND_DIR)/Cargo.toml --all-targets
$(PNPM) exec vue-tsc --noEmit
.PHONY: backend-check
backend-check: ## cargo check the Rust backend
$(CARGO) check --manifest-path $(BACKEND_DIR)/Cargo.toml --all-targets
.PHONY: frontend-check
frontend-check: ## vue-tsc type-check the frontend
$(PNPM) exec vue-tsc --noEmit
.PHONY: test
test: ## run the Rust test suite
$(CARGO) test --manifest-path $(BACKEND_DIR)/Cargo.toml --all-targets
.PHONY: lint
lint: fmt-check clippy ## run cargo fmt --check and clippy
.PHONY: fmt
fmt: ## format Rust sources in place
$(CARGO) fmt --manifest-path $(BACKEND_DIR)/Cargo.toml --all
.PHONY: fmt-check
fmt-check: ## verify Rust formatting without rewriting files
$(CARGO) fmt --manifest-path $(BACKEND_DIR)/Cargo.toml --all -- --check
.PHONY: clippy
clippy: ## run clippy with warnings as errors
$(CARGO) clippy --manifest-path $(BACKEND_DIR)/Cargo.toml --all-targets -- -D warnings
# ---- Cleanup ----------------------------------------------------------------
.PHONY: clean
clean: ## remove build artifacts (target/, dist/)
$(CARGO) clean --manifest-path $(BACKEND_DIR)/Cargo.toml
rm -rf dist
.PHONY: clean-all
clean-all: clean ## also remove node_modules
rm -rf node_modules
.PHONY: reset
reset: clean-all install ## nuke build artifacts and reinstall everything
# ---- Diagnostics ------------------------------------------------------------
.PHONY: doctor
doctor: ## print toolchain versions
@printf "$(BOLD)Toolchain$(RESET)\n"
@printf " node %s\n" "$$($(NODE) --version 2>/dev/null || echo 'not installed')"
@printf " pnpm %s\n" "$$($(PNPM) --version 2>/dev/null || echo 'not installed')"
@printf " cargo %s\n" "$$($(CARGO) --version 2>/dev/null || echo 'not installed')"