-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
45 lines (36 loc) · 1.59 KB
/
Copy pathMakefile
File metadata and controls
45 lines (36 loc) · 1.59 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
PREFIX ?= $(HOME)/.local/bin
VERSION ?= 1.0.0
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
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.
$(BUILDINFO): $(SOURCES)
@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}\n' "$(VERSION)" "$$(date -u +%Y-%m-%dT%H:%M:%SZ)" "$$n" > $(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
clean:
rm -f $(BUILDINFO) $(SEQ_FILE)
swift package clean
.PHONY: install build hooks unhooks uninstall clean