guenther/Makefile

50 lines
1.5 KiB
Makefile

BINARY := guenther
BUILD_DIR := build
CMD := ./cmd/pipeline/main.go
CONFIG := configs/default.yaml
GO_IMAGE := golang:bookworm
BUILD_TAGS := duckdb_arrow
LDFLAGS := -s -w
GO_BUILD_FLAGS := -tags=$(BUILD_TAGS) -buildvcs=false -ldflags='$(LDFLAGS)'
# ── Targets ───────────────────────────────────────────────────────────────────
.PHONY: all build build-local test clean run help
all: build
## build: Build the binary inside a Docker container (no local toolchain needed)
build:
@mkdir -p $(BUILD_DIR)
docker run --rm \
-v $(PWD):/app:Z \
-w /app \
$(GO_IMAGE) \
sh -c "apt-get update -qq && \
apt-get install -y -qq gcc libc6-dev && \
CGO_ENABLED=1 go build $(GO_BUILD_FLAGS) -o $(BUILD_DIR)/$(BINARY) $(CMD) && \
echo BUILD_OK" \
2>&1
## build-local: Build the binary using the local Go toolchain (requires gcc)
build-local:
@mkdir -p $(BUILD_DIR)
CGO_ENABLED=1 go build $(GO_BUILD_FLAGS) -o $(BUILD_DIR)/$(BINARY) $(CMD)
## test: Run all tests (requires local Go toolchain with gcc)
test:
CGO_ENABLED=1 go test -v -tags=$(BUILD_TAGS) ./...
## run: Run the pipeline with the default config (binary must be built first)
run: $(BUILD_DIR)/$(BINARY)
./$(BUILD_DIR)/$(BINARY) -config $(CONFIG)
## clean: Remove build artefacts
clean:
rm -rf $(BUILD_DIR)
## help: Show this help message
help:
@grep -E '^## ' $(MAKEFILE_LIST) | sed 's/^## / /'