-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathMakefile
More file actions
146 lines (125 loc) · 5.32 KB
/
Copy pathMakefile
File metadata and controls
146 lines (125 loc) · 5.32 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
ifeq ($(OS),Windows_NT)
SHELL := pwsh.exe
.SHELLFLAGS := -NoProfile -Command
EXE := .exe
INSTALL_DIR ?= $(USERPROFILE)/.local/bin
CONFIG_DIR ?= $(USERPROFILE)/.config/code-agent-manager
TAURI_CLI ?= ./frontend/node_modules/.bin/tauri.cmd
CARGO_ENV := $$env:CARGO_HTTP_CHECK_REVOKE='false';
SIDECAR_TARGET ?= src-tauri/binaries/cam-sidecar-x86_64-pc-windows-msvc.exe
else
SHELL := /bin/sh
.SHELLFLAGS := -c
EXE :=
INSTALL_DIR ?= $(HOME)/.local/bin
CONFIG_DIR ?= $(HOME)/.config/code-agent-manager
TAURI_CLI ?= ./frontend/node_modules/.bin/tauri
CARGO_ENV := CARGO_HTTP_CHECK_REVOKE=false
SIDECAR_TARGET ?= src-tauri/binaries/cam-sidecar
endif
.PHONY: help install clean test test-race build build-cli build-sidecar node-deps stop-desktop frontend app dev start sidecar desktop-build fmt fmt-check vet check release
VERSION ?= dev
GOFLAGS ?=
FRONTEND_HOST ?= 127.0.0.1
FRONTEND_PORT ?= 5173
SIDECAR_HOST ?= 127.0.0.1
SIDECAR_PORT ?= 0
TAURI_MANIFEST ?= src-tauri/Cargo.toml
TAURI_CONFIG ?= src-tauri/tauri.conf.json
help:
@echo "Available commands:"
@echo " make start - Start the full Tauri desktop app (same as make app)"
@echo " make app - Start the Tauri desktop app (alias: make dev)"
@echo " make frontend - Start browser-only Vite frontend at $(FRONTEND_HOST):$(FRONTEND_PORT)"
@echo " make sidecar - Start Go sidecar API at $(SIDECAR_HOST):$(SIDECAR_PORT)"
@echo " make desktop-build - Build frontend, Go sidecar, and cargo-check Tauri shell"
@echo " make build - Build Go CLI binaries and sidecar into dist/"
@echo " make install - Build and install cam/code-agent-manager"
@echo " make test - Run Go test suite"
@echo " make test-race - Run Go tests with race detector"
@echo " make fmt - Format Go code"
@echo " make vet - Run go vet"
@echo " make check - Run fmt check, vet, tests, frontend tests, and sidecar build"
@echo " make clean - Remove build artifacts"
install: build-cli
ifeq ($(OS),Windows_NT)
pwsh.exe -NoProfile -Command "New-Item -ItemType Directory -Force '$(INSTALL_DIR)', '$(CONFIG_DIR)' | Out-Null"
pwsh.exe -NoProfile -Command "Copy-Item 'dist/cam$(EXE)' '$(INSTALL_DIR)/cam$(EXE)' -Force"
pwsh.exe -NoProfile -Command "Copy-Item 'dist/code-agent-manager$(EXE)' '$(INSTALL_DIR)/code-agent-manager$(EXE)' -Force"
pwsh.exe -NoProfile -Command "if (Test-Path '$(CONFIG_DIR)/providers.json') { Remove-Item '$(CONFIG_DIR)/providers.json' -Force }"
pwsh.exe -NoProfile -Command "if (-not (Test-Path '$(USERPROFILE)/.env')) { New-Item -ItemType File -Force '$(USERPROFILE)/.env' | Out-Null }"
@echo "Installed cam and code-agent-manager to $(INSTALL_DIR)"
else
VERSION=$(VERSION) ./install.sh install
endif
clean:
ifeq ($(OS),Windows_NT)
Remove-Item -Recurse -Force dist, frontend/dist, src-tauri/target, src-tauri/binaries -ErrorAction SilentlyContinue
Get-ChildItem -Recurse -Filter *.test -ErrorAction SilentlyContinue | Remove-Item -Force -ErrorAction SilentlyContinue
Get-ChildItem -Recurse -Filter coverage.out -ErrorAction SilentlyContinue | Remove-Item -Force -ErrorAction SilentlyContinue
else
rm -rf dist/ frontend/dist/ src-tauri/target/ src-tauri/binaries/
find . -type f -name "*.test" -delete
find . -type f -name "coverage.out" -delete
endif
build: build-cli build-sidecar
node-deps:
npm --prefix frontend install
build-cli:
ifeq ($(OS),Windows_NT)
New-Item -ItemType Directory -Force dist | Out-Null
else
mkdir -p dist
endif
go build $(GOFLAGS) -ldflags "-X main.version=$(VERSION)" -o dist/cam$(EXE) ./cmd/cam
go build $(GOFLAGS) -ldflags "-X main.version=$(VERSION)" -o dist/code-agent-manager$(EXE) ./cmd/code-agent-manager
stop-desktop:
ifeq ($(OS),Windows_NT)
$$processes = Get-Process cam-sidecar, cam-desktop -ErrorAction SilentlyContinue; if ($$processes) { $$processes | Stop-Process -Force -ErrorAction SilentlyContinue }; exit 0
else
-pkill -f cam-sidecar || true
-pkill -f cam-desktop || true
endif
build-sidecar: stop-desktop
ifeq ($(OS),Windows_NT)
New-Item -ItemType Directory -Force dist, src-tauri/binaries | Out-Null
else
mkdir -p dist src-tauri/binaries
endif
go build $(GOFLAGS) -ldflags "-X main.version=$(VERSION)" -o dist/cam-sidecar$(EXE) ./cmd/cam-sidecar
go build $(GOFLAGS) -ldflags "-X main.version=$(VERSION)" -o $(SIDECAR_TARGET) ./cmd/cam-sidecar
frontend:
npm --prefix frontend run dev -- --host $(FRONTEND_HOST) --port $(FRONTEND_PORT) --strictPort
sidecar:
go run ./cmd/cam-sidecar --host $(SIDECAR_HOST) --port $(SIDECAR_PORT)
app dev start: node-deps build-sidecar
$(CARGO_ENV) $(TAURI_CLI) dev --config $(TAURI_CONFIG)
desktop-build: build-sidecar
npm --prefix frontend run build
$(CARGO_ENV) cargo check --manifest-path $(TAURI_MANIFEST)
test:
go test $(GOFLAGS) ./...
test-race:
go test $(GOFLAGS) -race ./...
fmt:
gofmt -s -w cmd internal
fmt-check:
ifeq ($(OS),Windows_NT)
$$files = gofmt -s -l cmd internal; if ($$files) { $$files; exit 1 }
else
@test -z "$$(gofmt -s -l cmd internal)" || (gofmt -s -l cmd internal && exit 1)
endif
vet:
go vet ./...
check: fmt-check vet test build-sidecar
npm --prefix frontend test -- --run
npm --prefix frontend run build
$(CARGO_ENV) cargo check --manifest-path $(TAURI_MANIFEST)
@echo "All checks passed!"
release: clean check build
@echo "Release build completed successfully!"
ifeq ($(OS),Windows_NT)
Get-ChildItem dist
else
ls -lh dist/
endif