Files
motr-enclave/Makefile

84 lines
2.2 KiB
Makefile

.PHONY: all generate build build-debug build-opt test test-cover test-plugin lint fmt vet clean tidy deps verify help
MODULE := enclave
BINARY := enclave.wasm
BUILD_DIR := build
TINYGO_FLAGS := -target=wasip1 -scheduler=none -gc=leaking
all: generate build
generate:
@sqlc generate
build:
@mkdir -p $(BUILD_DIR)
@tinygo build $(TINYGO_FLAGS) -o $(BUILD_DIR)/$(BINARY) .
build-debug:
@mkdir -p $(BUILD_DIR)
@tinygo build $(TINYGO_FLAGS) -no-debug=false -o $(BUILD_DIR)/$(BINARY) .
build-opt:
@mkdir -p $(BUILD_DIR)
@tinygo build $(TINYGO_FLAGS) -opt=2 -o $(BUILD_DIR)/$(BINARY) .
@wasm-opt -Os $(BUILD_DIR)/$(BINARY) -o $(BUILD_DIR)/$(BINARY)
test:
@go test -v ./...
test-cover:
@go test -coverprofile=coverage.out ./...
@go tool cover -html=coverage.out -o coverage.html
test-plugin:
@extism call $(BUILD_DIR)/$(BINARY) generate --input '{}' --wasi
lint:
@golangci-lint run ./...
fmt:
@go fmt ./...
@gofumpt -w .
vet:
@go vet ./...
clean:
@rm -rf $(BUILD_DIR)
@rm -f coverage.out coverage.html
tidy:
@go mod tidy
deps:
@go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
@go install mvdan.cc/gofumpt@latest
@echo "Install TinyGo: https://tinygo.org/getting-started/install/"
@echo "Install Extism CLI: https://extism.org/docs/install"
verify: fmt vet lint test
help:
@echo "Motr Enclave - Extism Plugin (TinyGo/wasip1)"
@echo ""
@echo "Build targets:"
@echo " build - Build WASM plugin with TinyGo"
@echo " build-debug - Build with debug symbols"
@echo " build-opt - Build optimized (requires wasm-opt)"
@echo ""
@echo "Development targets:"
@echo " generate - Run sqlc to generate Go code"
@echo " test - Run tests with Go"
@echo " test-cover - Run tests with coverage"
@echo " test-plugin - Test plugin with Extism CLI"
@echo " lint - Run golangci-lint"
@echo " fmt - Format code"
@echo " vet - Run go vet"
@echo " verify - Run fmt, vet, lint, and test"
@echo ""
@echo "Utility targets:"
@echo " clean - Remove build artifacts"
@echo " tidy - Run go mod tidy"
@echo " deps - Install development dependencies"