-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
76 lines (66 loc) · 2.6 KB
/
Copy pathMakefile
File metadata and controls
76 lines (66 loc) · 2.6 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
EXECUTABLE := quectool
GITVERSION := $(shell git describe --dirty --always --tags --long)
LDFLAGS := -X github.com/snowzach/golib/version.Executable=$(EXECUTABLE) \
-X github.com/snowzach/golib/version.GitVersion=$(GITVERSION)
.PHONY: default
default: $(EXECUTABLE)
# Host build for local development.
.PHONY: $(EXECUTABLE)
$(EXECUTABLE):
mkdir -p build
go build -ldflags "$(LDFLAGS)" -o build/$(EXECUTABLE)
# Cross-compile for the modem (Quectel RM5xx OpenLinux is 32-bit ARMv7).
.PHONY: armv7
armv7: frontend
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 \
go build -trimpath -ldflags "-w -s $(LDFLAGS)" -o build/$(EXECUTABLE)-armv7
# Tagged release artifact: armv7 binary + dist/ files in a single tarball
# with sha256. Same artifact CI publishes; usable locally with deploy.sh.
.PHONY: release-tar
release-tar: armv7
rm -rf build/pkg
mkdir -p build/pkg
cp build/$(EXECUTABLE)-armv7 build/pkg/quectool
cp dist/quectool.yaml build/pkg/
cp dist/quectool.service build/pkg/
cp dist/install.sh build/pkg/
cp dist/uninstall.sh build/pkg/
cp dist/README build/pkg/
chmod +x build/pkg/install.sh build/pkg/uninstall.sh
tar -C build/pkg -czf build/$(EXECUTABLE)-$(GITVERSION)-armv7.tar.gz .
cd build && sha256sum $(EXECUTABLE)-$(GITVERSION)-armv7.tar.gz \
> $(EXECUTABLE)-$(GITVERSION)-armv7.tar.gz.sha256
@echo "==> build/$(EXECUTABLE)-$(GITVERSION)-armv7.tar.gz"
# Frontend bundle, embedded into the binary at compile time.
.PHONY: frontend
frontend: types
cd frontend && [ -d node_modules ] || npm install
cd frontend && rm -rf dist && npm run build
# Regenerate frontend/src/types/ from the Go structs.
.PHONY: types
types:
mkdir -p frontend/src/types
go run github.com/gzuidhof/tygo@latest generate
.PHONY: test
test:
go test -cover ./...
# Local development:
# make dev-backend in one terminal (override MODEM_PORT if not /dev/ttyUSB3)
# make dev-frontend in another (vite dev server, proxies /api → :8082)
# Override the production defaults (HTTPS on :443, embedded SPA, /usrdata
# paths) for local laptop dev: plain HTTP on :8080, frontend served from
# the on-disk build, modem on the typical Quectel USB AT port.
.PHONY: dev-backend
dev-backend:
SERVER_EMBEDDED=false SERVER_TLS=false SERVER_PORT=8080 \
SERVER_SSH_HOST_KEY_FILE=./host_key \
SERVER_AUTH_CREDENTIALS_FILE=./credentials \
MODEM_PORT=/dev/ttyUSB3 \
go run main.go server
.PHONY: dev-frontend
dev-frontend: types
cd frontend && [ -d node_modules ] || npm install
cd frontend && npm run dev
.PHONY: clean
clean:
rm -rf build frontend/dist embed/public_html frontend/src/types