beads/Makefile
beads/crew/emma 2137693dad revert: restore embedded Dolt mode (was only supposed to be removed from Gas Town)
Revert commits e5330641 and 0df41523 which removed embedded Dolt mode
from the beads codebase. The embedded Dolt removal was only intended for
Gas Town, not for Beads.

Restores:
- dolthub/driver dependency and embedded connection path
- Advisory flock (AccessLock) for concurrent process protection
- Embedded connector lifecycle management in DoltStore
- All CGO build tags across ~45 files
- Vendored go-icu-regex library
- nocgo stub files for non-CGO builds
- Bootstrap and embedded_uow helpers
- factory_dolt_test.go and dolt_singleprocess_test.go

Merge conflict resolutions:
- store.go: TCP fail-fast check wrapped inside if cfg.ServerMode
- store.go: backtick-quoting for embedded CREATE DATABASE (prefix-based names)
- perf_dolt.go: port references updated from 3306 to 3307
- ci.yml: restored continue-on-error for Nix (dolthub/driver requires Go 1.25.6+)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-07 21:21:24 -08:00

126 lines
4.5 KiB
Makefile

# Makefile for beads project
.PHONY: all build test bench bench-quick clean install help check-up-to-date fmt fmt-check
# Default target
all: build
BINARY := bd
BUILD_DIR := .
INSTALL_DIR := $(HOME)/.local/bin
# Dolt backend requires CGO for embedded database support.
# Without CGO, builds will fail with "dolt backend requires CGO".
export CGO_ENABLED := 1
# ICU4C is keg-only on macOS (Homebrew doesn't symlink it into /opt/homebrew).
# Dolt's go-icu-regex dependency needs these paths to compile and link.
ifeq ($(shell uname),Darwin)
ICU_PREFIX := $(shell brew --prefix icu4c 2>/dev/null)
ifneq ($(ICU_PREFIX),)
export CGO_CFLAGS += -I$(ICU_PREFIX)/include
export CGO_CPPFLAGS += -I$(ICU_PREFIX)/include
export CGO_LDFLAGS += -L$(ICU_PREFIX)/lib
endif
endif
# Build the bd binary
build:
@echo "Building bd..."
ifeq ($(OS),Windows_NT)
go build -tags gms_pure_go -ldflags="-X main.Build=$$(git rev-parse --short HEAD)" -o $(BUILD_DIR)/$(BINARY) ./cmd/bd
else
go build -ldflags="-X main.Build=$$(git rev-parse --short HEAD)" -o $(BUILD_DIR)/$(BINARY) ./cmd/bd
ifeq ($(shell uname),Darwin)
@codesign -s - -f $(BUILD_DIR)/$(BINARY) 2>/dev/null || true
@echo "Signed $(BINARY) for macOS"
endif
endif
# Run all tests (skips known broken tests listed in .test-skip)
test:
@echo "Running tests..."
@TEST_COVER=1 ./scripts/test.sh
# Run performance benchmarks (10K and 20K issue databases with automatic CPU profiling)
# Generates CPU profile: internal/storage/sqlite/bench-cpu-<timestamp>.prof
# View flamegraph: go tool pprof -http=:8080 <profile-file>
bench:
@echo "Running performance benchmarks..."
@echo "This will generate 10K and 20K issue databases and profile all operations."
@echo "CPU profiles will be saved to internal/storage/sqlite/"
@echo ""
go test -bench=. -benchtime=1s -tags=bench -run=^$$ ./internal/storage/sqlite/ -timeout=30m
@echo ""
@echo "Benchmark complete. Profile files saved in internal/storage/sqlite/"
@echo "View flamegraph: cd internal/storage/sqlite && go tool pprof -http=:8080 bench-cpu-*.prof"
# Run quick benchmarks (shorter benchtime for faster feedback)
bench-quick:
@echo "Running quick performance benchmarks..."
go test -bench=. -benchtime=100ms -tags=bench -run=^$$ ./internal/storage/sqlite/ -timeout=15m
# Check that local branch is up to date with origin/main
check-up-to-date:
ifndef SKIP_UPDATE_CHECK
@git fetch origin main --quiet 2>/dev/null || true
@LOCAL=$$(git rev-parse HEAD 2>/dev/null); \
REMOTE=$$(git rev-parse origin/main 2>/dev/null); \
if [ -n "$$REMOTE" ] && [ "$$LOCAL" != "$$REMOTE" ]; then \
echo "ERROR: Local branch is not up to date with origin/main"; \
echo " Local: $$(git rev-parse --short HEAD)"; \
echo " Remote: $$(git rev-parse --short origin/main)"; \
echo "Run 'git pull' first, or use SKIP_UPDATE_CHECK=1 to override"; \
exit 1; \
fi
endif
# Install bd to ~/.local/bin (builds, signs on macOS, and copies)
# Also creates 'beads' symlink as an alias for bd
install: check-up-to-date build
@mkdir -p $(INSTALL_DIR)
@rm -f $(INSTALL_DIR)/$(BINARY)
@cp $(BUILD_DIR)/$(BINARY) $(INSTALL_DIR)/$(BINARY)
@echo "Installed $(BINARY) to $(INSTALL_DIR)/$(BINARY)"
@rm -f $(INSTALL_DIR)/beads
@ln -s $(BINARY) $(INSTALL_DIR)/beads
@echo "Created 'beads' alias -> $(BINARY)"
# Format all Go files
fmt:
@echo "Formatting Go files..."
@gofmt -w .
@echo "Done"
# Check that all Go files are properly formatted (for CI)
fmt-check:
@echo "Checking Go formatting..."
@UNFORMATTED=$$(gofmt -l .); \
if [ -n "$$UNFORMATTED" ]; then \
echo "The following files are not properly formatted:"; \
echo "$$UNFORMATTED"; \
echo ""; \
echo "Run 'make fmt' to fix formatting"; \
exit 1; \
fi
@echo "All Go files are properly formatted"
# Clean build artifacts and benchmark profiles
clean:
@echo "Cleaning..."
rm -f bd
rm -f internal/storage/sqlite/bench-cpu-*.prof
rm -f beads-perf-*.prof
# Show help
help:
@echo "Beads Makefile targets:"
@echo " make build - Build the bd binary"
@echo " make test - Run all tests"
@echo " make bench - Run performance benchmarks (generates CPU profiles)"
@echo " make bench-quick - Run quick benchmarks (shorter benchtime)"
@echo " make install - Install bd to ~/.local/bin (with codesign on macOS, includes 'beads' alias)"
@echo " make fmt - Format all Go files with gofmt"
@echo " make fmt-check - Check Go formatting (for CI)"
@echo " make clean - Remove build artifacts and profile files"
@echo " make help - Show this help message"