Fix Makefile: use -C flag to set module root
This commit is contained in:
18
Makefile
18
Makefile
@@ -27,12 +27,12 @@ help: ## Show this help message
|
||||
|
||||
build: ## Build the binary
|
||||
@echo "Building $(BINARY)..."
|
||||
@cd $(ROOTDIR) && $(GOBUILD) -o $(BINARY) $(CMD_PATH)/main.go
|
||||
@$(GOBUILD) -C $(ROOTDIR) -o $(BINARY) cmd/$(BINARY)/main.go
|
||||
@echo "Build complete: $(BINARY)"
|
||||
|
||||
build-all: ## Build all binaries
|
||||
@echo "Building all binaries..."
|
||||
@cd $(ROOTDIR) && $(GOBUILD) -o $(BINARY) ./...
|
||||
@$(GOBUILD) -C $(ROOTDIR) -o $(BINARY) ./...
|
||||
|
||||
clean: ## Clean build artifacts
|
||||
@echo "Cleaning..."
|
||||
@@ -42,21 +42,21 @@ clean: ## Clean build artifacts
|
||||
|
||||
install: ## Install the binary to $GOPATH/bin
|
||||
@echo "Installing $(BINARY)..."
|
||||
@cd $(ROOTDIR) && $(GOBUILD) -o $$($(GOCMD) env GOPATH)/bin/$(BINARY) $(CMD_PATH)/main.go
|
||||
@$(GOBUILD) -C $(ROOTDIR) -o $$($(GOCMD) env GOPATH)/bin/$(BINARY) cmd/$(BINARY)/main.go
|
||||
@echo "Install complete"
|
||||
|
||||
test: ## Run tests
|
||||
@echo "Running tests..."
|
||||
@cd $(ROOTDIR) && $(GOTEST) -v ./...
|
||||
@$(GOTEST) -C $(ROOTDIR) -v ./...
|
||||
|
||||
test-coverage: ## Run tests with coverage
|
||||
@echo "Running tests with coverage..."
|
||||
@cd $(ROOTDIR) && $(GOTEST) -v -coverprofile=coverage.out ./...
|
||||
@cd $(ROOTDIR) && $(GOCMD) tool cover -html=coverage.out -o coverage.html
|
||||
@$(GOTEST) -C $(ROOTDIR) -v -coverprofile=coverage.out ./...
|
||||
@$(GOCMD) tool -C $(ROOTDIR) cover -html=coverage.out -o coverage.html
|
||||
|
||||
fmt: ## Format Go code
|
||||
@echo "Formatting code..."
|
||||
@cd $(ROOTDIR) && $(GOCMD) fmt ./...
|
||||
@$(GOCMD) fmt -C $(ROOTDIR) ./...
|
||||
|
||||
lint: ## Run golangci-lint (if installed)
|
||||
@echo "Running linter..."
|
||||
@@ -68,8 +68,8 @@ lint: ## Run golangci-lint (if installed)
|
||||
|
||||
deps: ## Download dependencies
|
||||
@echo "Downloading dependencies..."
|
||||
@cd $(ROOTDIR) && $(GOMOD) download
|
||||
@cd $(ROOTDIR) && $(GOMOD) tidy
|
||||
@$(GOMOD) -C $(ROOTDIR) download
|
||||
@$(GOMOD) -C $(ROOTDIR) tidy
|
||||
|
||||
run: build ## Build and run the binary
|
||||
@echo "Running $(BINARY)..."
|
||||
|
||||
Reference in New Issue
Block a user