Phase 6
This commit is contained in:
@@ -1,43 +1,72 @@
|
||||
.PHONY: all frontend backend backend-epics test test-epics clean
|
||||
.PHONY: all frontend backend backend-epics backend-debug test lint clean run
|
||||
|
||||
all: frontend backend
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Sources — adding any file here triggers a frontend or backend rebuild #
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
frontend:
|
||||
cd web && npm ci && npm run build
|
||||
FRONTEND_SRCS := $(shell find web/src -name '*.tsx' -o -name '*.ts' -o -name '*.css') \
|
||||
$(wildcard web/vendor/*.mjs web/vendor/*.js web/vendor/*.css) \
|
||||
tools/buildfrontend/main.go
|
||||
|
||||
backend:
|
||||
go build -ldflags="-s -w" -o dist/uopi ./cmd/uopi
|
||||
GO_SRCS := $(shell find cmd internal -name '*.go') web/embed.go go.mod go.sum
|
||||
|
||||
# Build backend with EPICS Channel Access support.
|
||||
# Requires EPICS Base to be installed and the following environment variables:
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Outputs #
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
FRONTEND_OUT := web/dist/main.js
|
||||
BINARY := dist/uopi
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Top-level targets #
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
all: $(BINARY)
|
||||
|
||||
frontend: $(FRONTEND_OUT)
|
||||
|
||||
backend: $(BINARY)
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Build rules #
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
# Bundle TypeScript/TSX → web/dist/ using esbuild (pure Go, no npm)
|
||||
$(FRONTEND_OUT): $(FRONTEND_SRCS)
|
||||
@mkdir -p web/dist
|
||||
go run ./tools/buildfrontend/main.go
|
||||
|
||||
# Compile the self-contained binary (embeds web/dist at build time)
|
||||
$(BINARY): $(GO_SRCS) $(FRONTEND_OUT)
|
||||
@mkdir -p dist
|
||||
go build -ldflags="-s -w" -o $(BINARY) ./cmd/uopi
|
||||
|
||||
# Build with EPICS Channel Access support.
|
||||
# Requires EPICS Base and:
|
||||
# EPICS_BASE=/path/to/epics/base
|
||||
# CGO_CFLAGS="-I${EPICS_BASE}/include -I${EPICS_BASE}/include/os/Linux"
|
||||
# CGO_LDFLAGS="-L${EPICS_BASE}/lib/linux-x86_64 -lca -lCom"
|
||||
backend-epics:
|
||||
CGO_ENABLED=1 go build -tags epics -ldflags="-s -w" -o dist/uopi ./cmd/uopi
|
||||
# CGO_CFLAGS="-I$$EPICS_BASE/include -I$$EPICS_BASE/include/os/Linux"
|
||||
# CGO_LDFLAGS="-L$$EPICS_BASE/lib/linux-x86_64 -lca -lCom"
|
||||
backend-epics: $(FRONTEND_OUT)
|
||||
@mkdir -p dist
|
||||
CGO_ENABLED=1 go build -tags epics -ldflags="-s -w" -o $(BINARY) ./cmd/uopi
|
||||
|
||||
# Build backend without -s -w for debugging
|
||||
backend-debug:
|
||||
go build -o dist/uopi ./cmd/uopi
|
||||
# Unstripped binary for debugging
|
||||
backend-debug: $(FRONTEND_OUT)
|
||||
@mkdir -p dist
|
||||
go build -o $(BINARY) ./cmd/uopi
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Dev / CI #
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
test:
|
||||
go test ./...
|
||||
cd web && npm run check
|
||||
|
||||
# Run EPICS integration tests (requires EPICS Base; see backend-epics target).
|
||||
test-epics:
|
||||
go test -tags epics ./internal/datasource/epics/...
|
||||
|
||||
lint:
|
||||
go vet ./...
|
||||
cd web && npm run lint
|
||||
|
||||
run: $(BINARY)
|
||||
$(BINARY)
|
||||
|
||||
clean:
|
||||
rm -rf dist/ web/dist/
|
||||
|
||||
# Run dev servers (requires two terminals or a process manager)
|
||||
run-backend:
|
||||
go run ./cmd/uopi
|
||||
|
||||
run-frontend:
|
||||
cd web && npm run dev
|
||||
|
||||
Reference in New Issue
Block a user