-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
85 lines (67 loc) · 1.7 KB
/
Makefile
File metadata and controls
85 lines (67 loc) · 1.7 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
85
# file: Makefile
# description: Cross-platform makefile for building and testing the gotld package
# Define shell to use
SHELL := /bin/sh
# Go commands
GO := go
GOTEST := $(GO) test
GOBUILD := $(GO) build
# Output binary name (with OS-specific extension)
ifeq ($(OS),Windows_NT)
BINARY_NAME := gotld-example.exe
else
BINARY_NAME := gotld-example
endif
# Directories
EXAMPLE_DIR := ./example
BUILD_DIR := ./build
# Files
EXAMPLE_MAIN := $(EXAMPLE_DIR)/main.go
BINARY_PATH := $(BUILD_DIR)/$(BINARY_NAME)
# Make sure build directory exists
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
# Define all targets as phony
.PHONY: all clean test bench build run lint vet fmt check help
# Default target
all: check test build
# Help target
help:
@echo "Available targets:"
@echo " all - Run checks, tests, and build"
@echo " clean - Remove build artifacts"
@echo " test - Run tests"
@echo " bench - Run benchmarks"
@echo " build - Build the example application"
@echo " run - Run the example application"
@echo " lint - Run linter"
@echo " vet - Run go vet"
@echo " fmt - Run go fmt"
@echo " check - Run all checks (fmt, vet, lint)"
# Test target
test:
$(GOTEST) -v ./...
# Benchmarking target
bench:
$(GOTEST) -bench=. ./...
# Build target
build: $(BUILD_DIR)
$(GOBUILD) -o $(BINARY_PATH) $(EXAMPLE_MAIN)
# Run target
run: build
$(BINARY_PATH)
# Clean target
clean:
rm -rf $(BUILD_DIR)
# Linting target
lint:
@command -v golint >/dev/null 2>&1 || { echo "golint not installed. Installing..."; go install golang.org/x/lint/golint@latest; }
golint ./...
# Go vet target
vet:
$(GO) vet ./...
# Go fmt target
fmt:
$(GO) fmt ./...
# Check target - runs all checks
check: fmt vet lint