-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
81 lines (69 loc) · 3.71 KB
/
Copy pathMakefile
File metadata and controls
81 lines (69 loc) · 3.71 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
PREFIX ?= $(HOME)/.local/bin
VERSION ?= 1.1.2
SEQ_FILE := .build-seq
BUILDINFO := Sources/code-monkey/BuildInfo.swift
SOURCES := $(shell find Sources -name '*.swift' -not -path $(BUILDINFO))
install: build
@mkdir -p $(PREFIX)
cp .build/release/code-monkey $(PREFIX)/code-monkey
cp .build/release/code-monkey-mcp $(PREFIX)/code-monkey-mcp
@# Copying invalidates the ad-hoc linker signature; macOS then SIGKILLs the
@# binary at exec ("Taskgated Invalid Signature"), which an MCP client only
@# sees as a closed connection. Re-sign in place so the installed copy runs.
codesign -f -s - $(PREFIX)/code-monkey $(PREFIX)/code-monkey-mcp
@# Provenance for `doctor`. An installed binary carries its own build stamp,
@# but nothing on disk says which *checkout* produced it — and more than one
@# repository builds binaries of this name. Without this file the only
@# symptom of running the wrong one is a schema mismatch, or an MCP tool list
@# that disagrees with the CLI. Sits beside the binaries because `doctor`
@# finds it from the running executable's own directory.
@printf '{"source_root":"%s","commit":"%s","build_seq":%s,"build_date":"%s","version":"%s"}\n' \
"$(CURDIR)" \
"$$(git rev-parse --short HEAD 2>/dev/null || echo unknown)" \
"$$(sed -n 's/.*buildSeq = \([0-9][0-9]*\).*/\1/p' $(BUILDINFO))" \
"$$(sed -n 's/.*buildDate = "\([^"]*\)".*/\1/p' $(BUILDINFO))" \
"$(VERSION)" > $(PREFIX)/.code-monkey-build.json
build: $(BUILDINFO)
swift build -c release
# Regenerated only when real sources change, so unrelated `make build` runs
# don't touch BuildInfo.swift's mtime and force a needless recompile/relink,
# and the build seq only bumps on builds that actually have something to build.
#
# The Makefile is a prerequisite because VERSION lives here and nowhere else.
# Without it a version bump never reached the binary: no .swift file changes
# when you edit this line, so the stamp stayed current and `code-monkey version`
# kept printing the old number until some unrelated source happened to change.
# This file changes rarely, so it costs a relink about as often as a release.
$(BUILDINFO): $(SOURCES) Makefile
@n=$$(cat $(SEQ_FILE) 2>/dev/null || echo 0); \
n=$$((n + 1)); \
echo $$n > $(SEQ_FILE); \
printf '// Generated by Makefile. Do not edit.\nenum BuildInfo {\n static let version = "%s"\n static let buildDate = "%s"\n static let buildSeq = %s\n static let commit = "%s"\n}\n' "$(VERSION)" "$$(date -u +%Y-%m-%dT%H:%M:%SZ)" "$$n" "$$(git rev-parse --short HEAD 2>/dev/null || echo unknown)" > $(BUILDINFO)
# Point git at the versioned hooks in hooks/, so a checkout, merge or rebase
# refreshes the index instead of leaving every byte offset in it pointing at the
# wrong place. `core.hooksPath` replaces .git/hooks wholesale — `make unhooks`
# puts it back.
hooks:
git config core.hooksPath hooks
@echo "git hooks -> hooks/ (post-checkout, post-merge, post-rewrite)"
unhooks:
git config --unset core.hooksPath || true
@echo "git hooks -> .git/hooks (default)"
uninstall:
rm -f $(PREFIX)/code-monkey
rm -f $(PREFIX)/code-monkey-mcp
rm -f $(PREFIX)/.code-monkey-build.json
# The catalog documents an executable target, where nothing is `public`. Without
# the access-level floor DocC would extract an empty symbol graph and the
# articles would have no module to attach to.
DOCC_FLAGS := --target code-monkey --symbol-graph-minimum-access-level internal
docs:
swift package --allow-writing-to-directory .build/docs \
generate-documentation $(DOCC_FLAGS) --output-path .build/docs
docs-preview:
swift package --disable-sandbox preview-documentation $(DOCC_FLAGS)
clean:
rm -f $(BUILDINFO) $(SEQ_FILE)
rm -rf .build/docs
swift package clean
.PHONY: install build hooks unhooks uninstall docs docs-preview clean