Rename the web dashboard binary to maglevd-frontend and move it to /usr/sbin (it's a daemon and belongs with maglevd). The systemd unit name stays vpp-maglev-frontend.service since that prefix is the package name. Manpage, README, user-guide, and debian packaging all updated in lockstep; bump to 0.9.1 for the first real release. All frontend env vars are now prefixed MAGLEV_FRONTEND_ so a single /etc/default/vpp-maglev can be shared with maglevd without collisions. Every flag has an env equivalent for Docker use. MAGLEV_FRONTEND_USER and MAGLEV_FRONTEND_PASSWORD still gate the /admin surface. VPPInfoPanel now pulses "API: ↑↓" indicators in the zippy title whenever a vpp-api-send / vpp-api-recv log event arrives on the SSE stream for the scoped maglevd — 250ms blue flash, re-triggerable, with the two arrows tightly kerned via negative letter-spacing.
114 lines
4.2 KiB
Makefile
114 lines
4.2 KiB
Makefile
BINARIES := maglevd maglevc maglevd-frontend
|
|
MODULE := git.ipng.ch/ipng/vpp-maglev
|
|
PROTO_DIR := proto
|
|
PROTO_FILE := $(PROTO_DIR)/maglev.proto
|
|
GEN_FILES := internal/grpcapi/maglev.pb.go internal/grpcapi/maglev_grpc.pb.go
|
|
|
|
# Web bundle is built by Vite and embedded by the Go binary via //go:embed.
|
|
# Any change under cmd/frontend/web/src/ retriggers an npm build; the
|
|
# generated cmd/frontend/web/dist/index.html is the sentinel.
|
|
FRONTEND_WEB_SRC := $(shell find cmd/frontend/web/src -type f 2>/dev/null) \
|
|
cmd/frontend/web/index.html \
|
|
cmd/frontend/web/package.json \
|
|
cmd/frontend/web/vite.config.ts \
|
|
cmd/frontend/web/tsconfig.json
|
|
FRONTEND_WEB_DIST := cmd/frontend/web/dist/index.html
|
|
|
|
NATIVE_ARCH := $(shell go env GOARCH)
|
|
VERSION := 0.9.1
|
|
COMMIT_HASH := $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
|
|
DATE := $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
|
|
LDFLAGS := -X '$(MODULE)/cmd.version=$(VERSION)' \
|
|
-X '$(MODULE)/cmd.commit=$(COMMIT_HASH)' \
|
|
-X '$(MODULE)/cmd.date=$(DATE)'
|
|
|
|
TEST ?= tests/
|
|
|
|
VPP_API_DIR ?= $(HOME)/src/vpp/build-root/install-vpp_debug-native/vpp/share/vpp/api
|
|
|
|
.PHONY: all build build-amd64 build-arm64 test proto vpp-binapi lint fixstyle fixstyle-web pkg-deb robot-test clean maglevd-frontend-web
|
|
|
|
all: build
|
|
|
|
build: $(GEN_FILES) $(FRONTEND_WEB_DIST)
|
|
mkdir -p build/$(NATIVE_ARCH)
|
|
go build -ldflags "$(LDFLAGS)" -o build/$(NATIVE_ARCH)/maglevd ./cmd/maglevd/
|
|
go build -ldflags "$(LDFLAGS)" -o build/$(NATIVE_ARCH)/maglevc ./cmd/maglevc/
|
|
go build -ldflags "$(LDFLAGS)" -o build/$(NATIVE_ARCH)/maglevd-frontend ./cmd/frontend/
|
|
|
|
build-amd64: $(GEN_FILES) $(FRONTEND_WEB_DIST)
|
|
mkdir -p build/amd64
|
|
GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o build/amd64/maglevd ./cmd/maglevd/
|
|
GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o build/amd64/maglevc ./cmd/maglevc/
|
|
GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o build/amd64/maglevd-frontend ./cmd/frontend/
|
|
|
|
build-arm64: $(GEN_FILES) $(FRONTEND_WEB_DIST)
|
|
mkdir -p build/arm64
|
|
GOOS=linux GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -o build/arm64/maglevd ./cmd/maglevd/
|
|
GOOS=linux GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -o build/arm64/maglevc ./cmd/maglevc/
|
|
GOOS=linux GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -o build/arm64/maglevd-frontend ./cmd/frontend/
|
|
|
|
# maglevd-frontend-web rebuilds the SolidJS bundle. The Go binary embeds the
|
|
# resulting cmd/frontend/web/dist/ via //go:embed, so a `go build` after
|
|
# this target picks up any asset changes automatically.
|
|
maglevd-frontend-web: $(FRONTEND_WEB_DIST)
|
|
|
|
$(FRONTEND_WEB_DIST): $(FRONTEND_WEB_SRC)
|
|
cd cmd/frontend/web && npm install && npm run build
|
|
|
|
pkg-deb: build-amd64 build-arm64
|
|
debian/build-deb.sh amd64 $(VERSION)
|
|
debian/build-deb.sh arm64 $(VERSION)
|
|
|
|
test: $(GEN_FILES)
|
|
go test ./...
|
|
|
|
proto: $(GEN_FILES)
|
|
|
|
$(GEN_FILES): $(PROTO_FILE)
|
|
protoc \
|
|
--go_out=. --go_opt=module=$(MODULE) \
|
|
--go-grpc_out=. --go-grpc_opt=module=$(MODULE) \
|
|
$(PROTO_FILE)
|
|
|
|
# vpp-binapi regenerates the Go bindings for VPP API files used by maglevd
|
|
# from a local VPP build. The LB plugin ships with upstream VPP; any newer
|
|
# messages (e.g. lb_conf_get, lb_as_v2_dump) require a VPP build that has
|
|
# them. Override VPP_API_DIR on the command line to point at another tree:
|
|
# make vpp-binapi VPP_API_DIR=/path/to/share/vpp/api
|
|
vpp-binapi:
|
|
@command -v binapi-generator >/dev/null 2>&1 || { \
|
|
echo "installing binapi-generator..."; \
|
|
go install go.fd.io/govpp/cmd/binapi-generator@v0.12.0; \
|
|
}
|
|
rm -rf internal/vpp/binapi
|
|
mkdir -p internal/vpp/binapi
|
|
binapi-generator \
|
|
--input=$(VPP_API_DIR) \
|
|
--output-dir=internal/vpp/binapi \
|
|
--import-prefix=$(MODULE)/internal/vpp/binapi \
|
|
--no-source-path-info \
|
|
--no-version-info \
|
|
lb lb_types
|
|
rm -f internal/vpp/binapi/lb/lb_rpc.ba.go
|
|
|
|
fixstyle: fixstyle-web
|
|
gofmt -w .
|
|
|
|
fixstyle-web:
|
|
cd cmd/frontend/web && npx prettier --write .
|
|
|
|
lint:
|
|
golangci-lint run ./...
|
|
|
|
tests/.venv: tests/requirements.txt
|
|
python3 -m venv tests/.venv
|
|
tests/.venv/bin/pip install -q -r tests/requirements.txt
|
|
|
|
robot-test: build tests/.venv
|
|
tests/rf-run.sh docker $(TEST)
|
|
|
|
clean:
|
|
rm -rf build/
|
|
rm -f $(GEN_FILES)
|