-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
157 lines (127 loc) · 5.42 KB
/
Copy pathMakefile
File metadata and controls
157 lines (127 loc) · 5.42 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
147
148
149
150
151
152
153
154
155
156
157
# qdesk Makefile — common developer + release tasks.
#
# `make help` lists everything. Most useful day-to-day: `make build test smoke`.
GO ?= go
DOCKER ?= docker
DIST_DIR ?= dist
INSTALL_PREFIX ?= /usr/local
SANDBOX_IMAGE ?= qdesk/ubuntu-chrome:dev
APT_MIRROR ?= mirrors.aliyun.com
GOPROXY_BUILD ?= https://goproxy.cn,direct
# Version + commit injection.
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
LDFLAGS := -s -w \
-X github.com/jeffwang/qdesk/pkg/version.Version=$(VERSION) \
-X github.com/jeffwang/qdesk/pkg/version.Commit=$(COMMIT)
# Cross-compile matrix for the host-side binaries (qdesk, qdesk-control, qdesk-mcp).
# qdesk-agentd ships only as linux/amd64 because it lives inside the sandbox image.
HOST_BINARIES := qdesk qdesk-control qdesk-mcp
HOST_PLATFORMS := linux/amd64 linux/arm64 darwin/amd64 darwin/arm64
.PHONY: help
help: ## Show this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nqdesk targets:\n"} /^[a-zA-Z0-9_.-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
@echo
@echo "Common combos:"
@echo " make build test smoke — verify everything still works"
@echo " make image — rebuild sandbox docker image"
@echo " make demo — full pipeline against examples/recompdaily"
@echo " make release VERSION=v0.1.0 — see scripts/release.sh"
@echo
# ----- Build -----
.PHONY: build
build: ## Build all 4 binaries into dist/ (host platform).
@mkdir -p $(DIST_DIR)
$(GO) build -trimpath -ldflags="$(LDFLAGS)" -o $(DIST_DIR)/qdesk-agentd ./cmd/qdesk-agentd
$(GO) build -trimpath -ldflags="$(LDFLAGS)" -o $(DIST_DIR)/qdesk-control ./cmd/qdesk-control
$(GO) build -trimpath -ldflags="$(LDFLAGS)" -o $(DIST_DIR)/qdesk ./cmd/qdesk
$(GO) build -trimpath -ldflags="$(LDFLAGS)" -o $(DIST_DIR)/qdesk-mcp ./cmd/qdesk-mcp
@ls -la $(DIST_DIR)
.PHONY: build-cross
build-cross: ## Cross-compile host binaries for $(HOST_PLATFORMS).
@mkdir -p $(DIST_DIR)
@set -e; \
for p in $(HOST_PLATFORMS); do \
os=$${p%/*}; arch=$${p#*/}; \
for b in $(HOST_BINARIES); do \
out=$(DIST_DIR)/$$b-$$os-$$arch; \
echo " → $$out"; \
GOOS=$$os GOARCH=$$arch CGO_ENABLED=0 \
$(GO) build -trimpath -ldflags="$(LDFLAGS)" -o $$out ./cmd/$$b; \
done; \
done
@ls -la $(DIST_DIR)
.PHONY: install
install: build ## Install binaries to $(INSTALL_PREFIX)/bin (may need sudo).
install -m 0755 $(DIST_DIR)/qdesk-agentd $(INSTALL_PREFIX)/bin/
install -m 0755 $(DIST_DIR)/qdesk-control $(INSTALL_PREFIX)/bin/
install -m 0755 $(DIST_DIR)/qdesk $(INSTALL_PREFIX)/bin/
install -m 0755 $(DIST_DIR)/qdesk-mcp $(INSTALL_PREFIX)/bin/
@echo "Installed to $(INSTALL_PREFIX)/bin"
# ----- Test -----
.PHONY: test
test: ## Run unit tests.
$(GO) test ./...
.PHONY: vet
vet: ## go vet all packages.
$(GO) vet ./...
.PHONY: fmt
fmt: ## go fmt all files.
$(GO) fmt ./...
.PHONY: tidy
tidy: ## go mod tidy.
$(GO) mod tidy
# ----- Sandbox image + smoke test -----
.PHONY: image
image: ## Build the qdesk/ubuntu-chrome sandbox docker image.
$(DOCKER) build \
--build-arg APT_MIRROR=$(APT_MIRROR) \
--build-arg GOPROXY=$(GOPROXY_BUILD) \
--build-arg VERSION=$(VERSION) \
--build-arg COMMIT=$(COMMIT) \
-t $(SANDBOX_IMAGE) \
-f images/ubuntu-chrome/Dockerfile .
.PHONY: smoke
smoke: ## Run the end-to-end sandbox smoke test (needs $(SANDBOX_IMAGE)).
IMAGE=$(SANDBOX_IMAGE) ./scripts/smoke-sandbox.sh
# ----- Demo / dogfood -----
.PHONY: demo
demo: build image ## Full pipeline against examples/recompdaily-landing (requires $$GEMINI_API_KEY).
@./scripts/demo.sh
# ----- MCP install convenience -----
.PHONY: mcp-install
mcp-install: install ## Register qdesk-mcp with Claude Code (claude mcp add).
@command -v claude >/dev/null 2>&1 || { echo "Claude Code CLI not on PATH; install it first."; exit 1; }
claude mcp add --transport stdio qdesk -- $(INSTALL_PREFIX)/bin/qdesk-mcp \
--control http://127.0.0.1:8090 \
--api-key "$$QDESK_DEV_KEY" \
--gemini-key "$$GEMINI_API_KEY"
@echo "qdesk MCP server registered."
# ----- Release -----
.PHONY: release
release: ## Cut a versioned release. Usage: make release VERSION=v0.1.0
@if [ -z "$(VERSION_ARG)" ] && [ -z "$$VERSION" ]; then \
echo "Usage: make release VERSION=v0.1.0"; exit 2; fi
@VERSION=$${VERSION:-$(VERSION_ARG)} ./scripts/release.sh
# ----- Cleanup -----
.PHONY: clean
clean: ## Remove dist/ and trace artifacts.
rm -rf $(DIST_DIR) qdesk-runs/ qdesk-control.db*
.PHONY: ci
ci: vet test build image smoke ## What CI runs.
# ----- Mac host mode -----
.PHONY: mac-build
mac-build: ## Build qdesk-mac and qdesk-mac-helper for macOS.
@mkdir -p bin
go build -o bin/qdesk-mac ./cmd/qdesk-mac
cd cmd/qdesk-mac-helper && swift build -c release
cp cmd/qdesk-mac-helper/.build/release/Helper bin/qdesk-mac-helper
QDESK_WIN_HOST ?= Administrator@192.168.0.127
.PHONY: win-build win-deploy
win-build: ## Cross-compile qdesk-win.exe (windows/amd64).
@mkdir -p bin
GOOS=windows GOARCH=amd64 go build -o bin/qdesk-win.exe ./cmd/qdesk-win
win-deploy: win-build ## Build and scp qdesk-win.exe to $(QDESK_WIN_HOST).
scp bin/qdesk-win.exe $(QDESK_WIN_HOST):qdesk-win.exe
@echo "Deployed to $(QDESK_WIN_HOST). Start with:"
@echo " ssh $(QDESK_WIN_HOST) './qdesk-win.exe --listen 0.0.0.0:8765 --api-key YOURKEY'"