| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- .PHONY: build run test clean lint fmt tidy dev
- # Go parameters
- GOCMD=go
- GOBUILD=$(GOCMD) build
- GORUN=$(GOCMD) run
- GOTEST=$(GOCMD) test
- GOCLEAN=$(GOCMD) clean
- GOGET=$(GOCMD) get
- GOMOD=$(GOCMD) mod
- GOFMT=gofmt
- # Binary name
- BINARY_NAME=claude-code-hub
- BINARY_DIR=bin
- # Main package
- MAIN_PACKAGE=./cmd/server
- # Build the project
- build:
- @echo "Building..."
- @mkdir -p $(BINARY_DIR)
- $(GOBUILD) -o $(BINARY_DIR)/$(BINARY_NAME) $(MAIN_PACKAGE)
- # Run the project
- run:
- $(GORUN) $(MAIN_PACKAGE)
- # Run with hot reload (requires air: go install github.com/air-verse/air@latest)
- dev:
- air
- # Run tests
- test:
- $(GOTEST) -v ./...
- # Run tests with coverage
- test-coverage:
- $(GOTEST) -v -coverprofile=coverage.out ./...
- $(GOCMD) tool cover -html=coverage.out -o coverage.html
- # Clean build artifacts
- clean:
- @echo "Cleaning..."
- $(GOCLEAN)
- rm -rf $(BINARY_DIR)
- rm -f coverage.out coverage.html
- # Run linter (requires golangci-lint)
- lint:
- golangci-lint run ./...
- # Format code
- fmt:
- $(GOFMT) -s -w .
- # Tidy dependencies
- tidy:
- $(GOMOD) tidy
- # Download dependencies
- deps:
- $(GOMOD) download
- # Generate mocks (requires mockgen)
- mocks:
- go generate ./...
- # Build for multiple platforms
- build-all:
- @echo "Building for multiple platforms..."
- @mkdir -p $(BINARY_DIR)
- GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BINARY_DIR)/$(BINARY_NAME)-linux-amd64 $(MAIN_PACKAGE)
- GOOS=linux GOARCH=arm64 $(GOBUILD) -o $(BINARY_DIR)/$(BINARY_NAME)-linux-arm64 $(MAIN_PACKAGE)
- GOOS=darwin GOARCH=amd64 $(GOBUILD) -o $(BINARY_DIR)/$(BINARY_NAME)-darwin-amd64 $(MAIN_PACKAGE)
- GOOS=darwin GOARCH=arm64 $(GOBUILD) -o $(BINARY_DIR)/$(BINARY_NAME)-darwin-arm64 $(MAIN_PACKAGE)
- GOOS=windows GOARCH=amd64 $(GOBUILD) -o $(BINARY_DIR)/$(BINARY_NAME)-windows-amd64.exe $(MAIN_PACKAGE)
- # Docker build
- docker-build:
- docker build -t $(BINARY_NAME):latest .
- # Docker run
- docker-run:
- docker run -p 8080:8080 $(BINARY_NAME):latest
|