-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
84 lines (72 loc) · 1.84 KB
/
Makefile
File metadata and controls
84 lines (72 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# Docker Compose Manager (DCM) Makefile
# Variables
BINARY_NAME=dcm
GO=go
GOFMT=gofmt
GOLINT=golint
GOVET=$(GO) vet
BUILD_DIR=.
CMD_DIR=./cmd/dcm
VERSION=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
BUILD_TIME=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS=-ldflags "-X main.Version=$(VERSION) -X main.BuildTime=$(BUILD_TIME)"
# Default target
.PHONY: all
all: fmt lint vet build
# Build the application
.PHONY: build
build:
$(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME) $(CMD_DIR)
# Install the application
.PHONY: install
install:
$(GO) install $(LDFLAGS) $(CMD_DIR)
# Run the application
.PHONY: run
run:
$(GO) run $(CMD_DIR)
# Clean build artifacts
.PHONY: clean
clean:
rm -f $(BUILD_DIR)/$(BINARY_NAME)
$(GO) clean
# Format code
.PHONY: fmt
fmt:
$(GOFMT) -s -w .
# Lint code
.PHONY: lint
lint:
$(GOLINT) ./...
# Run go vet
.PHONY: vet
vet:
$(GOVET) ./...
# Run tests
.PHONY: test
test:
$(GO) test -v ./...
# Build for multiple platforms
.PHONY: release
release: clean
# Linux
GOOS=linux GOARCH=amd64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 $(CMD_DIR)
# macOS
GOOS=darwin GOARCH=amd64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-amd64 $(CMD_DIR)
# Windows
GOOS=windows GOARCH=amd64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe $(CMD_DIR)
# Show help
.PHONY: help
help:
@echo "Available targets:"
@echo " all - Format, lint, vet, and build"
@echo " build - Build the binary"
@echo " install - Install the binary"
@echo " run - Run the application"
@echo " clean - Remove build artifacts"
@echo " fmt - Format code"
@echo " lint - Run linter"
@echo " vet - Run go vet"
@echo " test - Run tests"
@echo " release - Build for multiple platforms"
@echo " help - Show this help"