Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
67 lines (56 loc) · 2.29 KB
/
Copy pathMakefile
File metadata and controls
67 lines (56 loc) · 2.29 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
# ==============================================================================
# GoRuntime Kernel Makefile
# Target Architecture: WebAssembly (GOOS=js GOARCH=wasm)
# ==============================================================================
.PHONY: all build-wasm test bench lint fmt clean check help
# Toolchain executables and paths
GO ?= go
GOLANGCI_LINT ?= golangci-lint
WASM_OUT = dist/engine.wasm
CMD_WASM_PATH = ./cmd/wasm/main.go
PKG_PATHS = ./pkg/...
# Default target executed when running `make`
all: check build-wasm
# Help target: displays available targets and descriptions
help:
@echo "GoRuntime Kernel Build Tooling"
@echo ""
@echo "Usage:"
@echo " make build-wasm Compile Go engine to WebAssembly ($(WASM_OUT))"
@echo " make test Run unit tests across all Go packages"
@echo " make bench Run benchmarks across all Go packages"
@echo " make fmt Format all Go source files using gofmt"
@echo " make lint Run golangci-lint static analysis"
@echo " make check Execute formatting, linting, tests, and Wasm build checks"
@echo " make clean Remove build artifacts and temporary files"
@echo ""
# Compile the Go engine core into a WebAssembly binary
build-wasm:
@echo "--> Compiling Go Engine to WebAssembly..."
@mkdir -p dist
GOOS=js GOARCH=wasm $(GO) build -ldflags="-s -w" -o $(WASM_OUT) $(CMD_WASM_PATH)
@echo "--> WebAssembly binary successfully generated at $(WASM_OUT)"
# Execute Go unit tests for core engine packages
test:
@echo "--> Running Go unit tests..."
$(GO) test -v $(PKG_PATHS)
# Execute performance benchmarks and memory allocation checks
bench:
@echo "--> Running Go benchmarks..."
$(GO) test -bench=. -benchmem $(PKG_PATHS)
# Format all Go source files according to official Go formatting standards
fmt:
@echo "--> Formatting Go source files..."
gofmt -s -w .
# Run static analysis and linter checks
lint:
@echo "--> Running golangci-lint..."
$(GOLANGCI_LINT) run ./...
# Run full pre-flight quality checks before committing or opening a PR
check: fmt lint test build-wasm
@echo "--> All pre-flight quality checks passed successfully!"
# Clean up compiled WebAssembly artifacts and test coverage reports
clean:
@echo "--> Cleaning build artifacts and temporary files..."
rm -rf dist/ coverage.out
@echo "--> Clean complete."