High-performance implementation of plcbundle written in Rust
at main 4.0 kB view raw
1.PHONY: build install release clean test run help version patch minor major alpha beta rc docker-build docker-run docker-compose-up docker-compose-down docker-compose-logs docker-push docker-tag 2 3# Default target 4help: 5 @echo "plcbundle Makefile" 6 @echo "" 7 @echo "Available targets:" 8 @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-12s\033[0m %s\n", $$1, $$2}' 9 10build: ## Build in debug mode 11 cargo build 12 13build-go: build 14 @echo "Building Go bindings..." 15 cd bindings/go && go build ./... 16 17build-go-example: build-go 18 cd bindings/go && go build -o ../../plcbundle-go cmd/example/main.go 19 20release: ## Build optimized release binary 21 cargo build --release 22 @echo "" 23 @echo "Release binary: target/release/plcbundle" 24 25install: ## Install to ~/.cargo/bin (with all features) 26 cargo install --path . 27 28clean: ## Clean build artifacts 29 cargo clean 30 31test: ## Run tests 32 cargo test --all-features 33 34run: ## Run with example query 35 cargo run -- "did" -b "1" -j 1 36 37fmt: ## Format code 38 cargo fmt 39 40lint: ## Run clippy linter 41 cargo clippy --all-features -- -D warnings 42 43check: ## Check without building 44 cargo check 45 46# Version management with cargo-release 47# Requires: cargo install cargo-release 48 49version: ## Show current version 50 @cargo metadata --format-version 1 | jq -r '.packages[] | select(.name=="plcbundle") | .version' 51 52patch: ## Bump patch version (0.1.0 -> 0.1.1) 53 cargo release patch --execute 54 55minor: ## Bump minor version (0.1.0 -> 0.2.0) 56 cargo release minor --execute 57 58major: ## Bump major version (0.1.0 -> 1.0.0) 59 cargo release major --execute 60 61release-dry-run: ## Dry run of release (no changes) 62 cargo release patch --dry-run 63 64release-preview: ## Preview what would change in a release 65 cargo release patch --no-publish --no-push --no-tag --allow-dirty 66 67# Pre-release version bumping with cargo-release 68alpha: ## Bump alpha version (0.9.0-alpha.0 -> 0.9.0-alpha.1) 69 cargo release alpha --execute 70 71beta: ## Bump beta version (0.9.0-beta.0 -> 0.9.0-beta.1) 72 cargo release beta --execute 73 74rc: ## Bump release candidate version (0.9.0-rc.0 -> 0.9.0-rc.1) 75 cargo release rc --execute 76 77# ----------------------------------------------------------------------------- 78# Docker targets 79# ----------------------------------------------------------------------------- 80 81IMAGE ?= atscan/plcbundle:latest 82HTTP_PORT ?= 8080 83DATA_DIR ?= ./data 84TZ ?= UTC 85 86docker-build: ## Build Docker image (Alpine musl) for current platform 87 docker build -t $(IMAGE) . 88 89docker-build-amd64: ## Build Docker image for linux/amd64 90 docker buildx build --platform linux/amd64 -t $(IMAGE) --load . 91 92docker-build-arm64: ## Build Docker image for linux/arm64 93 docker buildx build --platform linux/arm64 -t $(IMAGE) --load . 94 95docker-build-multi: ## Build multi-arch Docker image (amd64 + arm64) 96 @echo "Building multi-architecture image for linux/amd64,linux/arm64..." 97 docker buildx build --platform linux/amd64,linux/arm64 -t $(IMAGE) --push . 98 99docker-build-multi-local: ## Build multi-arch image and load both architectures locally 100 @echo "Building multi-architecture image for linux/amd64,linux/arm64 (local)..." 101 docker buildx build --platform linux/amd64,linux/arm64 -t $(IMAGE) . 102 103docker-run: ## Run container locally with sync and websocket 104 mkdir -p $(DATA_DIR) 105 docker run --rm \ 106 --name plcbundle \ 107 -p $(HTTP_PORT):8080 \ 108 -v $(PWD)/$(DATA_DIR):/data \ 109 -e TZ=$(TZ) \ 110 $(IMAGE) server --host 0.0.0.0 --port 8080 --sync --websocket -C /data 111 112docker-compose-up: ## Start via docker compose (detached) 113 docker compose up -d 114 115docker-compose-down: ## Stop compose services 116 docker compose down 117 118docker-compose-logs: ## Tail compose logs 119 docker compose logs -f --tail=100 120 121docker-tag: ## Tag local image (set TAG=...) 122 @if [ -z "$(TAG)" ]; then echo "TAG is required (e.g., make docker-tag TAG=v0.9.0)"; exit 1; fi 123 docker tag $(IMAGE) $(IMAGE:latest=$(TAG)) 124 125docker-push: ## Push image to registry 126 docker push $(IMAGE)