Skip to content

Commit e789e8a

Browse files
committed
fix Makefile
1 parent 6799d19 commit e789e8a

1 file changed

Lines changed: 81 additions & 29 deletions

File tree

Makefile

Lines changed: 81 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
1-
.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
2-
1+
ifeq ($(OS),Windows_NT)
32
SHELL := pwsh.exe
43
.SHELLFLAGS := -NoProfile -Command
4+
EXE := .exe
5+
INSTALL_DIR ?= $(USERPROFILE)/.local/bin
6+
CONFIG_DIR ?= $(USERPROFILE)/.config/code-agent-manager
7+
TAURI_CLI ?= ./frontend/node_modules/.bin/tauri.cmd
8+
CARGO_ENV := $$env:CARGO_HTTP_CHECK_REVOKE='false';
9+
SIDECAR_TARGET ?= src-tauri/binaries/cam-sidecar-x86_64-pc-windows-msvc.exe
10+
else
11+
SHELL := /bin/sh
12+
.SHELLFLAGS := -c
13+
EXE :=
14+
INSTALL_DIR ?= $(HOME)/.local/bin
15+
CONFIG_DIR ?= $(HOME)/.config/code-agent-manager
16+
TAURI_CLI ?= ./frontend/node_modules/.bin/tauri
17+
CARGO_ENV := CARGO_HTTP_CHECK_REVOKE=false
18+
SIDECAR_TARGET ?= src-tauri/binaries/cam-sidecar
19+
endif
20+
21+
.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
522

623
VERSION ?= dev
724
GOFLAGS ?=
@@ -11,49 +28,76 @@ SIDECAR_HOST ?= 127.0.0.1
1128
SIDECAR_PORT ?= 0
1229
TAURI_MANIFEST ?= src-tauri/Cargo.toml
1330
TAURI_CONFIG ?= src-tauri/tauri.conf.json
14-
TAURI_CLI ?= ./frontend/node_modules/.bin/tauri.cmd
15-
SIDECAR_TARGET ?= src-tauri/binaries/cam-sidecar-x86_64-pc-windows-msvc.exe
1631

1732
help:
18-
@Write-Output "Available commands:"
19-
@Write-Output " make start - Start the full Tauri desktop app (same as make app)"
20-
@Write-Output " make app - Start the Tauri desktop app (alias: make dev)"
21-
@Write-Output " make frontend - Start browser-only Vite frontend at $(FRONTEND_HOST):$(FRONTEND_PORT)"
22-
@Write-Output " make sidecar - Start Go sidecar API at $(SIDECAR_HOST):$(SIDECAR_PORT)"
23-
@Write-Output " make desktop-build - Build frontend, Go sidecar, and cargo-check Tauri shell"
24-
@Write-Output " make build - Build Go CLI binaries and sidecar into dist/"
25-
@Write-Output " make install - Build and install cam/code-agent-manager"
26-
@Write-Output " make test - Run Go test suite"
27-
@Write-Output " make test-race - Run Go tests with race detector"
28-
@Write-Output " make fmt - Format Go code"
29-
@Write-Output " make vet - Run go vet"
30-
@Write-Output " make check - Run fmt check, vet, tests, frontend tests, and sidecar build"
31-
@Write-Output " make clean - Remove build artifacts"
32-
33-
install:
34-
bash ./install.sh install
33+
@echo "Available commands:"
34+
@echo " make start - Start the full Tauri desktop app (same as make app)"
35+
@echo " make app - Start the Tauri desktop app (alias: make dev)"
36+
@echo " make frontend - Start browser-only Vite frontend at $(FRONTEND_HOST):$(FRONTEND_PORT)"
37+
@echo " make sidecar - Start Go sidecar API at $(SIDECAR_HOST):$(SIDECAR_PORT)"
38+
@echo " make desktop-build - Build frontend, Go sidecar, and cargo-check Tauri shell"
39+
@echo " make build - Build Go CLI binaries and sidecar into dist/"
40+
@echo " make install - Build and install cam/code-agent-manager"
41+
@echo " make test - Run Go test suite"
42+
@echo " make test-race - Run Go tests with race detector"
43+
@echo " make fmt - Format Go code"
44+
@echo " make vet - Run go vet"
45+
@echo " make check - Run fmt check, vet, tests, frontend tests, and sidecar build"
46+
@echo " make clean - Remove build artifacts"
47+
48+
install: build-cli
49+
ifeq ($(OS),Windows_NT)
50+
pwsh.exe -NoProfile -Command "New-Item -ItemType Directory -Force '$(INSTALL_DIR)', '$(CONFIG_DIR)' | Out-Null"
51+
pwsh.exe -NoProfile -Command "Copy-Item 'dist/cam$(EXE)' '$(INSTALL_DIR)/cam$(EXE)' -Force"
52+
pwsh.exe -NoProfile -Command "Copy-Item 'dist/code-agent-manager$(EXE)' '$(INSTALL_DIR)/code-agent-manager$(EXE)' -Force"
53+
pwsh.exe -NoProfile -Command "if (Test-Path 'providers.json') { if (-not (Test-Path '$(CONFIG_DIR)/providers.json')) { Copy-Item 'providers.json' '$(CONFIG_DIR)/providers.json' -Force } } elseif (Test-Path 'providers.json.example') { if (-not (Test-Path '$(CONFIG_DIR)/providers.json')) { Copy-Item 'providers.json.example' '$(CONFIG_DIR)/providers.json' -Force } }"
54+
pwsh.exe -NoProfile -Command "if (Test-Path 'code_assistant_manager/config.yaml') { if (-not (Test-Path '$(CONFIG_DIR)/config.yaml')) { Copy-Item 'code_assistant_manager/config.yaml' '$(CONFIG_DIR)/config.yaml' -Force } }"
55+
pwsh.exe -NoProfile -Command "if (-not (Test-Path '$(USERPROFILE)/.env')) { New-Item -ItemType File -Force '$(USERPROFILE)/.env' | Out-Null }"
56+
@echo "Installed cam and code-agent-manager to $(INSTALL_DIR)"
57+
else
58+
VERSION=$(VERSION) ./install.sh install
59+
endif
3560

3661
clean:
62+
ifeq ($(OS),Windows_NT)
3763
Remove-Item -Recurse -Force dist, frontend/dist, src-tauri/target, src-tauri/binaries -ErrorAction SilentlyContinue
3864
Get-ChildItem -Recurse -Filter *.test -ErrorAction SilentlyContinue | Remove-Item -Force -ErrorAction SilentlyContinue
3965
Get-ChildItem -Recurse -Filter coverage.out -ErrorAction SilentlyContinue | Remove-Item -Force -ErrorAction SilentlyContinue
66+
else
67+
rm -rf dist/ frontend/dist/ src-tauri/target/ src-tauri/binaries/
68+
find . -type f -name "*.test" -delete
69+
find . -type f -name "coverage.out" -delete
70+
endif
4071

4172
build: build-cli build-sidecar
4273

4374
node-deps:
4475
npm --prefix frontend install
4576

4677
build-cli:
78+
ifeq ($(OS),Windows_NT)
4779
New-Item -ItemType Directory -Force dist | Out-Null
48-
go build $(GOFLAGS) -ldflags "-X main.version=$(VERSION)" -o dist/cam ./cmd/cam
49-
go build $(GOFLAGS) -ldflags "-X main.version=$(VERSION)" -o dist/code-agent-manager ./cmd/code-agent-manager
80+
else
81+
mkdir -p dist
82+
endif
83+
go build $(GOFLAGS) -ldflags "-X main.version=$(VERSION)" -o dist/cam$(EXE) ./cmd/cam
84+
go build $(GOFLAGS) -ldflags "-X main.version=$(VERSION)" -o dist/code-agent-manager$(EXE) ./cmd/code-agent-manager
5085

5186
stop-desktop:
87+
ifeq ($(OS),Windows_NT)
5288
$$processes = Get-Process cam-sidecar, cam-desktop -ErrorAction SilentlyContinue; if ($$processes) { $$processes | Stop-Process -Force -ErrorAction SilentlyContinue }; exit 0
89+
else
90+
-pkill -f cam-sidecar || true
91+
-pkill -f cam-desktop || true
92+
endif
5393

5494
build-sidecar: stop-desktop
95+
ifeq ($(OS),Windows_NT)
5596
New-Item -ItemType Directory -Force dist, src-tauri/binaries | Out-Null
56-
go build $(GOFLAGS) -ldflags "-X main.version=$(VERSION)" -o dist/cam-sidecar ./cmd/cam-sidecar
97+
else
98+
mkdir -p dist src-tauri/binaries
99+
endif
100+
go build $(GOFLAGS) -ldflags "-X main.version=$(VERSION)" -o dist/cam-sidecar$(EXE) ./cmd/cam-sidecar
57101
go build $(GOFLAGS) -ldflags "-X main.version=$(VERSION)" -o $(SIDECAR_TARGET) ./cmd/cam-sidecar
58102

59103
frontend:
@@ -63,11 +107,11 @@ sidecar:
63107
go run ./cmd/cam-sidecar --host $(SIDECAR_HOST) --port $(SIDECAR_PORT)
64108

65109
app dev start: node-deps build-sidecar
66-
$$env:CARGO_HTTP_CHECK_REVOKE='false'; $(TAURI_CLI) dev --config $(TAURI_CONFIG)
110+
$(CARGO_ENV) $(TAURI_CLI) dev --config $(TAURI_CONFIG)
67111

68112
desktop-build: build-sidecar
69113
npm --prefix frontend run build
70-
$$env:CARGO_HTTP_CHECK_REVOKE='false'; cargo check --manifest-path $(TAURI_MANIFEST)
114+
$(CARGO_ENV) cargo check --manifest-path $(TAURI_MANIFEST)
71115

72116
test:
73117
go test $(GOFLAGS) ./...
@@ -79,17 +123,25 @@ fmt:
79123
gofmt -s -w cmd internal
80124

81125
fmt-check:
126+
ifeq ($(OS),Windows_NT)
82127
$$files = gofmt -s -l cmd internal; if ($$files) { $$files; exit 1 }
128+
else
129+
@test -z "$$(gofmt -s -l cmd internal)" || (gofmt -s -l cmd internal && exit 1)
130+
endif
83131

84132
vet:
85133
go vet ./...
86134

87135
check: fmt-check vet test build-sidecar
88136
npm --prefix frontend test -- --run
89137
npm --prefix frontend run build
90-
$$env:CARGO_HTTP_CHECK_REVOKE='false'; cargo check --manifest-path $(TAURI_MANIFEST)
91-
Write-Output "All checks passed!"
138+
$(CARGO_ENV) cargo check --manifest-path $(TAURI_MANIFEST)
139+
@echo "All checks passed!"
92140

93141
release: clean check build
94-
Write-Output "Release build completed successfully!"
142+
@echo "Release build completed successfully!"
143+
ifeq ($(OS),Windows_NT)
95144
Get-ChildItem dist
145+
else
146+
ls -lh dist/
147+
endif

0 commit comments

Comments
 (0)