-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
92 lines (79 loc) · 4.14 KB
/
Copy pathMakefile
File metadata and controls
92 lines (79 loc) · 4.14 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
BINDIR ?= $(HOME)/.local/bin
DATADIR ?= $(HOME)/.local/share/brw
MAC_APPDIR ?= $(HOME)/Library/Application Support/brw
EXTENSION_ID = amocjcgddnoakjijfggdpnefdnboilpe
VERSION ?= $(shell git describe --tags --always --dirty | sed 's/^v//')
GOARCH ?= $(shell go env GOARCH)
# Inject the resolved version into the MCP serverInfo.version so the version an
# agent sees over MCP always matches the binary, instead of a hand-edited constant.
GO_LDFLAGS ?= -X github.com/Don-Works/brw/internal/mcp.Version=$(VERSION)
.PHONY: build test test-extension install install-mac install-extension package-darwin-arm64 package-linux package-macos
build:
go build -ldflags "$(GO_LDFLAGS)" -o bin/brwd ./cmd/brwd
go build -ldflags "$(GO_LDFLAGS)" -o bin/brwcheck ./cmd/brwcheck
go build -ldflags "$(GO_LDFLAGS)" -o bin/brwctl ./cmd/brwctl
go build -ldflags "$(GO_LDFLAGS)" -o bin/brw-devtools-mcp ./cmd/brw-devtools-mcp
test: test-extension
go test ./...
# Extension service-worker regression tests (run the real service_worker.js in a
# vm with a mocked chrome API). Skipped — not failed — when node is unavailable.
test-extension:
@if command -v node >/dev/null 2>&1; then \
node extension/tab_resolution_test.mjs; \
else \
echo "node not found; skipping extension tests"; \
fi
install: build
mkdir -p "$(BINDIR)" "$(DATADIR)/extension" "$(DATADIR)/tests"
cp bin/brwd "$(BINDIR)/brwd"
cp bin/brwcheck "$(BINDIR)/brwcheck"
cp bin/brwctl "$(BINDIR)/brwctl"
cp bin/brw-devtools-mcp "$(BINDIR)/brw-devtools-mcp"
cp -R extension/. "$(DATADIR)/extension/"
cp -R tests/. "$(DATADIR)/tests/"
@# On Apple Silicon, copying a Go binary invalidates its ad-hoc code
@# signature and the OS then SIGKILLs it ("Killed: 9"); re-sign the copies.
@if [ "$$(uname)" = "Darwin" ] && command -v codesign >/dev/null 2>&1; then \
codesign --force --sign - "$(BINDIR)/brwd" "$(BINDIR)/brwcheck" "$(BINDIR)/brwctl" "$(BINDIR)/brw-devtools-mcp"; \
fi
install-mac: build
mkdir -p "$(MAC_APPDIR)/bin" "$(MAC_APPDIR)/extension" "$(MAC_APPDIR)/tests" "$(MAC_APPDIR)/config"
cp bin/brwd "$(MAC_APPDIR)/bin/brwd"
cp bin/brwcheck "$(MAC_APPDIR)/bin/brwcheck"
cp bin/brwctl "$(MAC_APPDIR)/bin/brwctl"
cp bin/brw-devtools-mcp "$(MAC_APPDIR)/bin/brw-devtools-mcp"
cp -R extension/. "$(MAC_APPDIR)/extension/"
cp -R tests/. "$(MAC_APPDIR)/tests/"
if [ -f "$(HOME)/.config/brw/browser-profiles.json" ]; then cp "$(HOME)/.config/brw/browser-profiles.json" "$(MAC_APPDIR)/config/browser-profiles.json"; fi
@# Re-sign: copying a Go binary on Apple Silicon breaks its ad-hoc signature
@# and the OS SIGKILLs it on launch ("Killed: 9").
@if command -v codesign >/dev/null 2>&1; then \
codesign --force --sign - "$(MAC_APPDIR)/bin/brwd" "$(MAC_APPDIR)/bin/brwcheck" "$(MAC_APPDIR)/bin/brwctl" "$(MAC_APPDIR)/bin/brw-devtools-mcp"; \
fi
# Streamline the one-time load-unpacked install of the brw Chrome extension.
# Prints the exact folder + stable id, then (best-effort on macOS) opens
# chrome://extensions and reveals the folder in Finder so you can pick it.
install-extension:
@echo ""
@echo " Load the brw Chrome extension (one-time, Developer Mode):"
@echo ""
@echo " 1. In chrome://extensions, enable Developer mode (top right)."
@echo " 2. Click 'Load unpacked'."
@echo " 3. Select this folder:"
@echo ""
@echo " $(CURDIR)/extension"
@echo ""
@echo " The extension id will be: $(EXTENSION_ID)"
@echo " (matches DefaultBridgeExtensionID, so the bridge trusts it with no config)"
@echo ""
-@open -a "Google Chrome" "chrome://extensions" 2>/dev/null || true
-@open -R "$(CURDIR)/extension" 2>/dev/null || true
package-darwin-arm64:
GOOS=darwin GOARCH=arm64 go build -ldflags "$(GO_LDFLAGS)" -o bin/brwd-darwin-arm64 ./cmd/brwd
GOOS=darwin GOARCH=arm64 go build -ldflags "$(GO_LDFLAGS)" -o bin/brwcheck-darwin-arm64 ./cmd/brwcheck
GOOS=darwin GOARCH=arm64 go build -ldflags "$(GO_LDFLAGS)" -o bin/brwctl-darwin-arm64 ./cmd/brwctl
GOOS=darwin GOARCH=arm64 go build -ldflags "$(GO_LDFLAGS)" -o bin/brw-devtools-mcp-darwin-arm64 ./cmd/brw-devtools-mcp
package-linux:
scripts/package-linux.sh "$(VERSION)" "$(GOARCH)" dist/release
package-macos:
scripts/package-macos.sh "$(VERSION)" dist/release