Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
450 lines (391 loc) · 21.2 KB
/
Copy pathMakefile
File metadata and controls
450 lines (391 loc) · 21.2 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
.DEFAULT_GOAL := help
APP_BIN := elph
CARGO := $$(which cargo)
UNAME_S := $(shell uname -s)
UNAME_M := $(shell uname -m)
# On Apple Silicon macOS, default to Metal GPU acceleration for local embeddings
# (memory). The `metal` feature only compiles there; other platforms
# stay on the CPU backend. Override with `make build ELPH_METAL=`.
ifeq ($(UNAME_S),Darwin)
ifeq ($(UNAME_M),arm64)
ELPH_METAL_FEATURE ?= --features metal
endif
endif
ELPH_METAL_FEATURE ?=
_ELPH_PKGS := elph elph-agent elph-ai
ELPH_VERSION := $(shell grep '^version' crates/coding-agent/Cargo.toml | head -1 | sed 's/.*= *"\(.*\)"/\1/')
BUILD_HASH := $(shell git rev-parse --short HEAD 2>/dev/null || echo "dev")
APP_BINS := $(APP_BIN)
INSTALL_DIR := $(HOME)/.local/bin
APP ?= elph
CHANNEL ?= stable
OUTPUT_DIR ?= release
WEB_DIR ?= website
# ─── Compiler cache ───────────────────────────────────────────────────────────
# Use sccache when installed AND its daemon is responsive; otherwise disable it
# for this build. A stale daemon socket/lock (e.g. after a crashed build) causes
# "Timed out waiting for server startup" — --start-server recovers when it can.
# Override: SCCACHE_DISABLE=1 make build (skip sccache entirely).
ifneq ($(SCCACHE_DISABLE),1)
SCCACHE_BIN := $(shell command -v sccache 2>/dev/null)
ifneq ($(SCCACHE_BIN),)
SCCACHE_TMPDIR := $(or $(TMPDIR),$(TEMP),$(TMP),/tmp)
SCCACHE_TMPDIR_OK := $(shell test -d "$(SCCACHE_TMPDIR)" && test -w "$(SCCACHE_TMPDIR)" && echo 1 || echo 0)
ifeq ($(SCCACHE_TMPDIR_OK),1)
# Probe daemon health via --show-stats (no storage re-init). --start-server
# fails if remote cache (S3/R2) credentials are unreachable, even when the
# local daemon is already running fine.
SCCACHE_OK := $(shell "$(SCCACHE_BIN)" --show-stats >/dev/null 2>&1 && echo 1 || echo 0)
else
$(warning sccache disabled: temporary directory '$(SCCACHE_TMPDIR)' does not exist or is not writable)
endif
endif
endif
ifneq ($(SCCACHE_OK),)
ifeq ($(SCCACHE_OK),1)
export AWS_PROFILE := r2-sccache
export RUSTC_WRAPPER := sccache
# Direct mode is only supported by the local cache backend. The GitHub Actions
# cache backend (SCCACHE_GHA_ENABLED=true) routes through the sccache server,
# so leave direct mode off there to avoid "direct mode unsupported" errors.
ifneq ($(SCCACHE_GHA_ENABLED),true)
export SCCACHE_DIRECT := true
endif
# Cap remote cache at 50 GB so it never eclipses local disk. The bucket is shared
# across sessions — anything beyond this size is unlikely to be re-used soon.
export SCCACHE_MAXSIZE := 20G
endif
endif
# ─── Args ───────────────────────────────────────────────────────────────────
# Named args: make run ARGS="-- --nocapture" / make test PKG=foo
# catalog: make generate-models ARGS="--skip-scripts"
# Catalog source path is fixed in generate-models
# (../../earendil-works/pi/packages/ai from workspace root).
ARGS :=
_RESIDUAL_ := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
$(foreach a,$(_RESIDUAL_),$(eval .PHONY: $a))
$(foreach a,$(_RESIDUAL_),$(eval $a: ; @true))
# Forwarded cargo args after `--`: drop Make-level profile flags (--debug/--release/
# --dist) so they don't leak to cargo; keep -p/--features/--all-targets etc.
_FWD_ARGS := $(filter-out --debug --release --dist,$(_RESIDUAL_)) $(ARGS)
# Default to building the elph binary unless the caller selected a package/bin.
_BUILD_BIN := $(if $(filter -p --bin --lib --all-targets --examples --tests --benches --bins,$(_RESIDUAL_)),,--bin $(APP_BIN))
# _after <list> <needle> — returns the words following the first occurrence of
# <needle> (pure make, used to extract `--features <name>` residual values).
define _after
$(if $(filter $(2),$(firstword $(1))),$(wordlist 2,$(words $(1)),$(1)),$(if $(wordlist 2,$(words $(1)),$(1)),$(call _after,$(wordlist 2,$(words $(1)),$(1)),$(2))))
endef
# Build profile (last residual flag wins):
# make build -- --features metal --debug
# make build -- --features metal --release
# make build -- --features metal --dist
# Same flags work on `make install`.
# Env still works: RELEASE=1, PROFILE=debug|release|dist
# Note: CI=1 no longer selects a special profile — CI builds use debug.
# Note: `make install --release` is rejected by GNU make. Use `-- --release`.
_PROFILE_FLAGS := $(filter --debug --release --dist,$(MAKECMDGOALS) $(_RESIDUAL_))
_PROFILE_FLAG := $(lastword $(_PROFILE_FLAGS))
# Explicit `--features <name>` residual overrides the auto-detected default.
_AFTER_FEATURES := $(call _after,$(MAKECMDGOALS),--features)
ifneq ($(strip $(_AFTER_FEATURES)),)
ELPH_METAL_FEATURE := --features $(firstword $(_AFTER_FEATURES))
endif
ifeq ($(_PROFILE_FLAG),--dist)
BUILD_PROFILE := dist
else ifeq ($(_PROFILE_FLAG),--release)
BUILD_PROFILE := release
else ifeq ($(_PROFILE_FLAG),--debug)
BUILD_PROFILE := debug
else ifneq ($(filter dist,$(PROFILE)),)
BUILD_PROFILE := dist
else ifneq ($(filter release,$(PROFILE)),)
BUILD_PROFILE := release
else ifneq ($(filter debug,$(PROFILE)),)
BUILD_PROFILE := debug
else ifneq ($(filter 1 true yes,$(RELEASE)),)
BUILD_PROFILE := release
else
BUILD_PROFILE := debug
endif
ifeq ($(BUILD_PROFILE),dist)
CARGO_BUILD_FLAGS := --profile dist
else ifeq ($(BUILD_PROFILE),release)
CARGO_BUILD_FLAGS := --release
else
CARGO_BUILD_FLAGS :=
endif
BUILD_DIR := ./target/$(BUILD_PROFILE)
# Shared by check / clippy / nextest so they reuse target/$(BUILD_PROFILE).
CARGO_QA_FLAGS :=
NEXTEST_CARGO_FLAGS :=
.PHONY: build install run watch test check generate-models prepare
.PHONY: lint fmt clean coverage help stats release
.PHONY: bump bump-elph bump-libs publish publish-dry-run version
.PHONY: web-dev web-build web-start web-deps
# ─── Build ──────────────────────────────────────────────────────────────────
check: ## Check code compiles (fast, no codegen); pass -p <pkg> for a subset
@$(CARGO) check --workspace $(CARGO_QA_FLAGS) $(_FWD_ARGS) 2>&1
# @$(CARGO) bloat --release -n 50
build: ## Build elph binary (debug default; pass -- --debug|--release|--dist, --features, or -p)
@set -eu; \
_rustc_display=$$(if [ -n "$${RUSTC_WRAPPER:-}" ]; then echo "$${RUSTC_WRAPPER:-}"; else echo "rustc"; fi); \
echo "Building $(APP_BIN) v$(ELPH_VERSION) ($(BUILD_HASH)) [$$_rustc_display] ($(BUILD_PROFILE))"
@set -eu; _start=$$(python3 -c "import time; print(int(time.time()*1000))"); \
$(CARGO) build $(CARGO_BUILD_FLAGS) $(ELPH_METAL_FEATURE) $(_FWD_ARGS) $(_BUILD_BIN) 2>&1; \
_end=$$(python3 -c "import time; print(int(time.time()*1000))"); \
_elapsed=$$(( _end - _start )); \
echo ""; \
for bin in $(APP_BINS); do \
if [ -f "$(BUILD_DIR)/$$bin" ]; then \
if command -v rapidhash >/dev/null 2>&1; then \
hash=$$(rapidhash "$(BUILD_DIR)/$$bin"); \
elif command -v sha256sum >/dev/null 2>&1; then \
hash=$$(sha256sum "$(BUILD_DIR)/$$bin" | cut -d' ' -f1); \
else \
hash=$$(shasum -a 256 "$(BUILD_DIR)/$$bin" | cut -d' ' -f1); \
fi; \
echo "Binary $$bin: $$(du -sh $(BUILD_DIR)/$$bin | cut -f1) ($$hash)"; \
else \
echo "Binary $$bin:(not built)"; \
fi; \
done; \
printf "Build time: %d.%03ds\n" $$(( _elapsed / 1000 )) $$(( _elapsed % 1000 ))
release: ## Build a local release archive (CHANNEL=stable|canary, OUTPUT_DIR=release)
@set -eu; \
case "$(CHANNEL)" in \
stable) _profile=dist ;; \
canary) _profile=release ;; \
*) echo "Usage: make release [CHANNEL=stable|canary]" >&2; exit 2 ;; \
esac; \
$(MAKE) --no-print-directory build PROFILE="$$_profile"; \
_os="$$(uname -s)"; \
_arch="$$(uname -m)"; \
case "$$_os" in \
Darwin) _platform=macos; case "$$_arch" in arm64|aarch64) _release_arch=aarch64 ;; x86_64|amd64) _release_arch=x86_64 ;; *) echo "Unsupported macOS architecture: $$_arch" >&2; exit 2 ;; esac; _archive="elph-$${_platform}-$${_release_arch}.tar.gz" ;; \
Linux) _platform=linux; case "$$_arch" in arm64|aarch64) _release_arch=arm64 ;; x86_64|amd64) _release_arch=x86_64 ;; *) echo "Unsupported Linux architecture: $$_arch" >&2; exit 2 ;; esac; _archive="elph-$${_platform}-$${_release_arch}.tar.gz" ;; \
MINGW*|MSYS*|CYGWIN*) _platform=windows; _release_arch=x86_64; _archive="elph-windows-x86_64.zip" ;; \
*) echo "Unsupported operating system: $$_os" >&2; exit 2 ;; \
esac; \
mkdir -p "$(OUTPUT_DIR)/archives" "$(OUTPUT_DIR)/binaries"; \
rm -f "$(OUTPUT_DIR)/archives/$${_archive}" "$(OUTPUT_DIR)/archives/SHA256SUMS" "$(OUTPUT_DIR)/binaries/elph-$${_platform}-$${_release_arch}" "$(OUTPUT_DIR)/binaries/elph-$${_platform}-$${_release_arch}.exe"; \
if [ "$$_platform" = windows ]; then \
powershell.exe -NoProfile -NonInteractive -Command "Compress-Archive -LiteralPath 'target/'$${_profile}'/elph.exe' -DestinationPath '$(OUTPUT_DIR)/archives/'$${_archive} -Force; Copy-Item -LiteralPath 'target/'$${_profile}'/elph.exe' -Destination '$(OUTPUT_DIR)/binaries/elph-windows-x86_64.exe' -Force; (Get-FileHash -Algorithm SHA256 -LiteralPath '$(OUTPUT_DIR)/archives/'$${_archive}).Hash.ToLower() + ' ' + '$${_archive}' | Set-Content -NoNewline -LiteralPath '$(OUTPUT_DIR)/archives/SHA256SUMS'"; \
else \
tar -C "target/$${_profile}" -czf "$(OUTPUT_DIR)/archives/$$_archive" elph; \
cp "target/$${_profile}/elph" "$(OUTPUT_DIR)/binaries/elph-$${_platform}-$${_release_arch}"; \
if command -v sha256sum >/dev/null 2>&1; then sha256sum "$(OUTPUT_DIR)/archives/$$_archive" | sed 's# .*/# #' > "$(OUTPUT_DIR)/archives/SHA256SUMS"; else shasum -a 256 "$(OUTPUT_DIR)/archives/$$_archive" | sed 's# .*/# #' > "$(OUTPUT_DIR)/archives/SHA256SUMS"; fi; \
fi; \
echo "Release archive: $(OUTPUT_DIR)/archives/$$_archive"; \
echo "Checksum file: $(OUTPUT_DIR)/archives/SHA256SUMS"
install: build ## Install elph (debug -> elph-debug; release -> elph-canary; dist -> elph)
@mkdir -p $(INSTALL_DIR) && echo
@for bin in $(APP_BINS); do \
case "$(BUILD_PROFILE)" in \
dist) _suffix="" ;; \
release) _suffix="-canary" ;; \
*) _suffix="-debug" ;; \
esac; \
rm -f "$(INSTALL_DIR)/$$bin$${_suffix}"; \
cp "$(BUILD_DIR)/$$bin" "$(INSTALL_DIR)/$$bin$${_suffix}"; \
echo "$$bin$${_suffix} installed at: $(INSTALL_DIR)/$$bin$${_suffix} [$(BUILD_PROFILE)]"; \
done
run: ## Run elph coding agent
@_args='$(or $(_RESIDUAL_),$(ARGS))'; \
if [ -n "$$_args" ]; then \
$(CARGO) run -q -p $(APP_BIN) -- $$_args; \
else \
$(CARGO) run -q -p $(APP_BIN); \
fi
web-deps: ## Install website dependencies from the lockfile
@cd "$(WEB_DIR)" && pnpm install --frozen-lockfile
web-dev: ## Start the website development server
@cd "$(WEB_DIR)" && pnpm run dev
web-build: ## Build the website for production
@cd "$(WEB_DIR)" && pnpm run build
web-start: ## Serve the built website
@cd "$(WEB_DIR)" && pnpm run start
watch: ## Run elph with hot reload (requires watchexec)
@-$(CARGO) watch -c -- cargo run --bin $(APP_BIN) $(or $(_RESIDUAL_),$(ARGS)) 2>&1
test: ## Run tests (workspace; pass -p <pkg>, --features, -- --debug|--release|--dist)
@$(CARGO) nextest run --no-fail-fast $(NEXTEST_CARGO_FLAGS) $(_FWD_ARGS) $(SHARD)
generate-models: ## Regenerate elph-ai model catalogs (pi packages/ai; ARGS=--skip-scripts)
@$(CARGO) run -p elph-ai --features generate-models --bin generate-models -- all $(ARGS)
@pnpm dlx --silent oxfmt crates/elph-ai/models/
# ─── Code Quality ───────────────────────────────────────────────────────────
lint: ## Run clippy (workspace, all targets; pass -p <pkg> for a subset)
@$(CARGO) clippy --workspace --all-targets $(CARGO_QA_FLAGS) $(_FWD_ARGS) -- -D warnings
fmt: ## Format all code
@$(CARGO) fmt --all -- --style-edition 2024
@pnpm --silent dlx oxfmt crates/elph-ai/models/ schemas/
coverage: ## Run tests with coverage (requires cargo-llvm-cov)
@$(CARGO) llvm-cov nextest --no-cfg-coverage 2>&1
stats: ## Show sccache stats, code line count, and target/ breakdown
@tokei . -e "*.json" -e "*.md"
@if [ -n "$(SCCACHE_BIN)" ]; then \
echo ""; \
printf '\033[33msccache stats:\033[0m\n'; \
"$(SCCACHE_BIN)" --show-stats; \
fi
@echo ""; \
printf '\033[33mtarget/breakdown:\033[0m\n'; \
for _d in debug release; do \
if [ -d "target/$$_d" ]; then \
_sz=$$(du -sh "target/$$_d" 2>/dev/null | cut -f1); \
_incr=$$(du -sh "target/$$_d/incremental" 2>/dev/null | cut -f1); \
_deps=$$(du -sh "target/$$_d/deps" 2>/dev/null | cut -f1); \
_bins=$$(du -sh "target/$$_d/bin" 2>/dev/null | cut -f1); \
printf ' %8s %8s (incr %s · deps %s · bin %s)\n' "$$_d" "$$_sz" "$$_incr" "$$_deps" "$$_bins"; \
fi; \
done
@echo ""; \
printf '\033[33mcargo registry:\033[0m '; du -sh ~/.cargo/registry/src 2>/dev/null | cut -f1; true
clean: ## Clean build artifacts and caches
@find crates -type f -name '*_gen.rs' -delete
@rm -fr crates/elph-ai/models/.cache
@$(CARGO) clean
@rm -f Cargo.lock
# ─── Space reclamation ──────────────────────────────────────────────────────────
#
# Incremental build dirs are redundant with sccache's remote cache — a fresh
# full compile produces the same artifact and re-caches it. Removing old ones
# is safe; the first rebuild after GC may be slower but re-populates the cache.
#
# Dry-run (make gc DRY=1): prints what would be deleted without removing anything.
# Defaults: incremental dirs >7 days old, deps files >60 days old.
GC_INCR_MAX_AGE := 7d
GC_DEPS_MAX_AGE := 60d
gc: ## Reclaim space from stale build artefacts (incremental >7d, deps >60d)
@_dry="$(DRY)"; \
if [ "$$_dry" = "1" ]; then _op="would remove"; _skip=yes; else _op="removing"; _skip=no; fi; \
echo "=== GC $$_op ==="; \
incr=$$(du -sh target/debug/incremental 2>/dev/null | cut -f1); \
incr_count=$$(find target/debug/incremental -maxdepth 1 -type d -mtime +$(GC_INCR_MAX_AGE) 2>/dev/null | wc -l | tr -d ' '); \
echo " incremental : $$incr ($$incr_count dirs older than $(GC_INCR_MAX_AGE))"; \
if [ "$$_skip" = "no" ]; then \
find target/debug/incremental -maxdepth 1 -type d -mtime +$(GC_INCR_MAX_AGE) -exec rm -rf {} + 2>/dev/null || true; \
fi; \
deps=$$(du -sh target/debug/deps 2>/dev/null | cut -f1); \
dep_count=$$(find target/debug/deps -maxdepth 1 -type f -mtime +$(GC_DEPS_MAX_AGE) 2>/dev/null | wc -l | tr -d ' '); \
echo " deps : $$deps ($$dep_count files older than $(GC_DEPS_MAX_AGE))"; \
if [ "$$_skip" = "no" ] && [ "$$dep_count" -gt 0 ]; then \
find target/debug/deps -maxdepth 1 -type f -mtime +$(GC_DEPS_MAX_AGE) -delete 2>/dev/null || true; \
fi; \
echo " done."; \
new_inc=$$(du -sh target/debug/incremental 2>/dev/null | cut -f1); \
new_deps=$$(du -sh target/debug/deps 2>/dev/null | cut -f1); \
echo " after: incremental $$new_inc · deps $$new_deps"
clean-incremental: ## Remove all incremental build dirs (faster rebuild, re-cached by sccache)
@echo "Removing target/debug/incremental/ ..."
@rm -fr target/debug/incremental
@echo "Done."
clean-deps: ## Remove deps older than $(GC_DEPS_MAX_AGE) (safe — cargo will re-download/rebuild)
@echo "Removing deps older than $(GC_DEPS_MAX_AGE) ..."
@find target/debug/deps -maxdepth 1 -type f -mtime +$(GC_DEPS_MAX_AGE) -print -delete
@echo "Done."
# ─── Misc ───────────────────────────────────────────────────────────────────
prepare: ## Install required toolchain
@command -v cargo-binstall >/dev/null 2>&1 || $(CARGO) install cargo-binstall --locked
@command -v cargo-bloat >/dev/null 2>&1 || $(CARGO) binstall --locked -y cargo-bloat
@command -v cargo-deny >/dev/null 2>&1 || $(CARGO) binstall --locked -y cargo-deny
@command -v cargo-nextest >/dev/null 2>&1 || $(CARGO) binstall --locked -y cargo-nextest
@command -v cargo-machete >/dev/null 2>&1 || $(CARGO) binstall --locked -y cargo-machete
@command -v cargo-flamegraph >/dev/null 2>&1 || $(CARGO) binstall --locked -y flamegraph
@command -v cargo-llvm-cov >/dev/null 2>&1 || $(CARGO) binstall --locked -y cargo-llvm-cov
@command -v communique >/dev/null 2>&1 || $(CARGO) binstall --locked -y communique
@command -v watchexec >/dev/null 2>&1 || $(CARGO) binstall --locked -y watchexec-cli
@command -v rapidhash >/dev/null 2>&1 || $(CARGO) install --locked -y rapidhash
@command -v sccache >/dev/null 2>&1 || $(CARGO) binstall --locked -y sccache
@command -v tokei >/dev/null 2>&1 || $(CARGO) binstall --locked -y tokei
@if [ "$(UNAME_S)" = "Darwin" ]; then \
if xcrun --find metal 2>/dev/null >/dev/null; then \
echo "Metal toolchain already installed at $$(xcrun --find metal)"; \
else \
xcodebuild -downloadComponent MetalToolchain 2>&1; \
fi; \
fi
# ─── Versioning ────────────────────────────────────────────────────────────────
# version: compare Cargo.toml with latest GitHub releases
# make version
# make version APP=elph
# make version TAG=v0.0.28
version: ## Compare app versions with latest GitHub releases (APP=, TAG=)
@APP="$(APP)" TAG="$(TAG)" ./scripts/version.sh
# Independent version streams:
# bump-elph — crates/coding-agent/Cargo.toml
# bump-libs — crates/elph-{core,agent,ai,tui,swarm} (+ workspace pins)
# bump — bump-libs + bump-elph
#
# Usage (level is required):
# make bump patch|minor|major
# make bump-elph patch|minor|major
# make bump-libs patch|minor|major
ifeq ($(UNAME_S),Darwin)
SED_INPLACE := sed -i ''
else
SED_INPLACE := sed -i
endif
_BUMP_LEVEL := $(firstword $(_RESIDUAL_))
_BUMP_PY := python3 -c "import sys;m,M,p=sys.argv[1].split('.');l=sys.argv[2];print(f'{m}.{M}.{int(p)+1}' if l=='patch' else f'{m}.{int(M)+1}.0' if l=='minor' else f'{int(m)+1}.0.0')"
_LIBS := elph-ai elph-agent
define _require_bump_level
@case "$(1)" in patch|minor|major) ;; *) \
echo "Usage: make $(2) {patch|minor|major}" >&2; \
exit 1;; esac
endef
define _bump_manifest
@_f="$(1)"; _l="$(2)"; \
_cur=$$(grep '^version = ' "$$_f" | head -1 | sed 's/.*= *"\(.*\)"/\1/'); \
_new=$$($(_BUMP_PY) "$$_cur" "$$_l"); \
$(SED_INPLACE) "s/^version = \"[^\"]*\"/version = \"$$_new\"/" "$$_f"; \
echo " $$_f: $$_cur → $$_new"
endef
define _sync_workspace_pin
@_crate="$(1)"; \
_ver=$$(grep '^version = ' "crates/$$_crate/Cargo.toml" | head -1 | sed 's/.*= *"\(.*\)"/\1/'); \
$(SED_INPLACE) "s/\($$_crate = { path = \"crates\/$$_crate\", version = \)\"[^\"]*\"/\1\"$$_ver\"/" Cargo.toml; \
echo " Cargo.toml: $$_crate → $$_ver"
endef
bump-elph: ## Bump elph app version (patch|minor|major required)
$(call _require_bump_level,$(_BUMP_LEVEL),bump-elph)
@echo "bump-elph ($(_BUMP_LEVEL))..."
$(call _bump_manifest,crates/coding-agent/Cargo.toml,$(_BUMP_LEVEL))
@echo "Done."
bump-libs: ## Bump all library crates independently (patch|minor|major required)
$(call _require_bump_level,$(_BUMP_LEVEL),bump-libs)
@echo "bump-libs ($(_BUMP_LEVEL))..."
@for c in $(_LIBS); do \
$(MAKE) --no-print-directory _bump_lib LIB=$$c LEVEL=$(_BUMP_LEVEL); \
done
@for c in $(_LIBS); do \
$(MAKE) --no-print-directory _sync_lib_pin LIB=$$c; \
done
@echo "Done."
bump: ## Bump all libs and elph (patch|minor|major required)
$(call _require_bump_level,$(_BUMP_LEVEL),bump)
@echo "bump ($(_BUMP_LEVEL))..."
@$(MAKE) --no-print-directory bump-libs $(_BUMP_LEVEL)
@$(MAKE) --no-print-directory bump-elph $(_BUMP_LEVEL)
@echo "Done."
_bump_lib:
$(call _bump_manifest,crates/$(LIB)/Cargo.toml,$(LEVEL))
_sync_lib_pin:
$(call _sync_workspace_pin,$(LIB))
.PHONY: _bump_lib _sync_lib_pin
publish: ## Publish to crates.io (elph-ai first, then libs, then apps)
@CARGO="$(CARGO)" ./scripts/publish-crates.sh
publish-dry-run: ## Dry-run publish checks (elph-ai first)
@DRY_RUN=1 CARGO="$(CARGO)" ./scripts/publish-crates.sh
# ─── Help ───────────────────────────────────────────────────────────────────
help: ## Show this help
@printf '\033[33mUsage:\033[0m make \033[36m<target>\033[0m\n'
@awk -F ':.*## ' '/^[a-zA-Z_-]+:.*## / {printf " \033[36m%-18s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@printf '\033[33mBuild / install (use -- before flags):\033[0m\n'
@printf ' \033[36mmake build -- --features metal --debug\033[0m\n'
@printf ' \033[36mmake build -- --features metal --release\033[0m\n'
@printf ' \033[36mmake build -- --features metal --dist\033[0m\n'
@printf ' \033[36mmake release CHANNEL=stable\033[0m\n'
@printf ' \033[36mmake release CHANNEL=canary\033[0m\n'
@printf ' \033[36mmake install -- --features metal --debug\033[0m -> elph-debug\n'
@printf ' \033[36mmake install -- --features metal --release\033[0m -> elph-canary\n'
@printf ' \033[36mmake install -- --features metal --dist\033[0m -> elph\n'
@printf '\033[33mNote: \033[36mmake install --release\033[0m is invalid (make option parse)\n'