131 lines
3.1 KiB
Makefile
131 lines
3.1 KiB
Makefile
EXEC=entity-maker
|
|
BUILD_DIR=./build
|
|
CMD_DIR=./cmd/entity-maker
|
|
|
|
# Build variables
|
|
GOOS ?= linux
|
|
GOARCH ?= amd64
|
|
LDFLAGS=-s -w
|
|
|
|
|
|
.PHONY: build
|
|
build:
|
|
@echo "Building ${EXEC} for ${GOOS}/${GOARCH}..."
|
|
@mkdir -p ${BUILD_DIR}
|
|
@CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} go build \
|
|
-ldflags "${LDFLAGS}" \
|
|
-trimpath \
|
|
-o ${BUILD_DIR}/${EXEC} \
|
|
${CMD_DIR}
|
|
@echo "✓ Binary created: ${BUILD_DIR}/${EXEC}"
|
|
@ls -lh ${BUILD_DIR}/${EXEC}
|
|
|
|
|
|
.PHONY: build-dev
|
|
build-dev:
|
|
@echo "Building ${EXEC} (development mode)..."
|
|
@mkdir -p ${BUILD_DIR}
|
|
@go build -o ${BUILD_DIR}/${EXEC} ${CMD_DIR}
|
|
@echo "✓ Binary created: ${BUILD_DIR}/${EXEC}"
|
|
|
|
|
|
.PHONY: install
|
|
install: build
|
|
@echo "Installing ${EXEC} to /usr/local/bin..."
|
|
@sudo cp ${BUILD_DIR}/${EXEC} /usr/local/bin/${EXEC}
|
|
@echo "✓ Installed successfully"
|
|
|
|
|
|
.PHONY: clean
|
|
clean:
|
|
@echo "Cleaning build artifacts..."
|
|
@rm -rf ${BUILD_DIR}
|
|
@rm -f ${EXEC}
|
|
@echo "✓ Clean complete"
|
|
|
|
|
|
.PHONY: test
|
|
test:
|
|
@echo "Running tests..."
|
|
@go test ./...
|
|
@echo "✓ Tests passed"
|
|
|
|
|
|
.PHONY: test-verbose
|
|
test-verbose:
|
|
@echo "Running tests (verbose)..."
|
|
@go test -v ./...
|
|
|
|
|
|
.PHONY: test-coverage
|
|
test-coverage:
|
|
@echo "Running tests with coverage..."
|
|
@go test -cover ./...
|
|
@echo "✓ Tests completed"
|
|
|
|
|
|
.PHONY: coverage
|
|
coverage:
|
|
@echo "Generating coverage report..."
|
|
@go test -coverprofile=coverage.out ./...
|
|
@go tool cover -html=coverage.out -o coverage.html
|
|
@echo "✓ Coverage report generated: coverage.html"
|
|
@echo " Open coverage.html in your browser to view detailed coverage"
|
|
|
|
|
|
.PHONY: test-short
|
|
test-short:
|
|
@echo "Running short tests..."
|
|
@go test -short ./...
|
|
@echo "✓ Short tests passed"
|
|
|
|
|
|
.PHONY: bench
|
|
bench:
|
|
@echo "Running benchmarks..."
|
|
@go test -bench=. -benchmem ./internal/naming
|
|
@echo "✓ Benchmarks completed"
|
|
|
|
|
|
.PHONY: verify-static
|
|
verify-static: build
|
|
@echo "Verifying binary is statically linked..."
|
|
@file ${BUILD_DIR}/${EXEC}
|
|
@ldd ${BUILD_DIR}/${EXEC} 2>&1 || echo "✓ Binary is statically linked"
|
|
|
|
|
|
.PHONY: upgrade-packages
|
|
upgrade-packages:
|
|
@echo "Upgrading Go packages..."
|
|
@go get -u ./...
|
|
@go mod tidy
|
|
@echo "✓ Packages upgraded"
|
|
|
|
|
|
.PHONY: help
|
|
help:
|
|
@echo "Entity Maker - Makefile targets:"
|
|
@echo ""
|
|
@echo "Build targets:"
|
|
@echo " build Build static binary for Linux (default)"
|
|
@echo " build-dev Build development binary with debug symbols"
|
|
@echo " install Install binary to /usr/local/bin"
|
|
@echo " clean Remove build artifacts"
|
|
@echo " verify-static Verify binary has no dynamic dependencies"
|
|
@echo ""
|
|
@echo "Test targets:"
|
|
@echo " test Run all tests"
|
|
@echo " test-verbose Run tests with verbose output"
|
|
@echo " test-coverage Run tests and show coverage summary"
|
|
@echo " coverage Generate HTML coverage report"
|
|
@echo " test-short Run only short tests"
|
|
@echo " bench Run benchmarks"
|
|
@echo ""
|
|
@echo "Other targets:"
|
|
@echo " upgrade-packages Update Go dependencies"
|
|
@echo " help Show this help message"
|
|
@echo ""
|
|
@echo "Build options:"
|
|
@echo " GOOS=linux GOARCH=amd64 make build (default)"
|
|
@echo ""
|