-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
136 lines (118 loc) · 4.11 KB
/
Makefile
File metadata and controls
136 lines (118 loc) · 4.11 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
.PHONY: build test lint fmt clean install coverage coverage-html check help bench fuzz
# Go settings
GOCMD = go
GOTEST = $(GOCMD) test
GOBUILD = $(GOCMD) build
GOVET = $(GOCMD) vet
GOFMT = $(GOCMD) fmt
# Directories
BIN_DIR = bin
COVERAGE_FILE = coverage.out
COVERAGE_HTML = coverage.html
# Library packages (excluding cmd and examples)
LIB_PKGS = ./internal/... .
# All packages
ALL_PKGS = ./...
# Default target
all: check
# Full check: lint, test, build
check: lint test build
@echo "✓ All checks passed"
# Build the library, CLI, and examples
build:
@echo "Building..."
@mkdir -p $(BIN_DIR)
$(GOBUILD) $(ALL_PKGS)
cd cmd/imx && $(GOBUILD) -o ../../$(BIN_DIR)/imx .
$(GOBUILD) -o $(BIN_DIR)/basic ./examples/basic
@echo "✓ Build complete"
# Run all tests with race detector
test:
@echo "Running tests..."
$(GOTEST) -race $(ALL_PKGS)
cd cmd/imx && $(GOTEST) -race ./...
@echo "✓ All tests passed"
# Run linter (go vet)
lint:
@echo "Running linter..."
$(GOVET) $(ALL_PKGS)
cd cmd/imx && $(GOVET) ./...
@echo "✓ Linting passed"
# Format code
fmt:
@echo "Formatting code..."
$(GOFMT) $(ALL_PKGS)
cd cmd/imx && $(GOFMT) ./...
@echo "✓ Formatting complete"
# Clean build artifacts
clean:
@echo "Cleaning..."
rm -rf $(BIN_DIR)
rm -f $(COVERAGE_FILE) $(COVERAGE_HTML)
rm -f go.work go.work.sum
@echo "✓ Clean complete"
# Install CLI to GOPATH/bin
install:
@echo "Installing CLI..."
cd cmd/imx && $(GOCMD) install .
@echo "✓ Installed imx to GOPATH/bin"
# Generate coverage report for all packages (library + CLI)
coverage:
@echo "Running tests with coverage..."
$(GOTEST) -coverprofile=$(COVERAGE_FILE) -covermode=atomic ./...
@echo ""
@$(GOCMD) tool cover -func=$(COVERAGE_FILE) | tail -1
# Generate HTML coverage report
coverage-html: coverage
@echo "Generating HTML coverage report..."
@go work init . ./cmd/imx 2>/dev/null || true
@$(GOCMD) tool cover -html=$(COVERAGE_FILE) -o $(COVERAGE_HTML)
@rm -f go.work go.work.sum
@echo "✓ Coverage report: $(COVERAGE_HTML)"
# Run basic example
example: build
@echo "Running example..."
./$(BIN_DIR)/imx testdata/jpeg/google_iptc.jpg
# Run benchmarks
bench:
@echo "Running benchmarks..."
$(GOTEST) -run=^$$ -bench=. -benchmem -benchtime=2s $(ALL_PKGS)
cd cmd/imx && $(GOTEST) -run=^$$ -bench=. -benchmem -benchtime=2s ./...
# Run fuzz tests
fuzz:
@echo "Running fuzz tests..."
@$(GOTEST) -fuzz='^FuzzCR2Parse$$' -fuzztime=5s ./internal/parser/cr2
@$(GOTEST) -fuzz='^FuzzFLACParse$$' -fuzztime=5s ./internal/parser/flac
@$(GOTEST) -fuzz='^FuzzGIFParse$$' -fuzztime=5s ./internal/parser/gif
@$(GOTEST) -fuzz='^FuzzHEICParse$$' -fuzztime=5s ./internal/parser/heic
@$(GOTEST) -fuzz='^FuzzICCParse$$' -fuzztime=5s ./internal/parser/icc
@$(GOTEST) -fuzz='^FuzzID3Parse$$' -fuzztime=5s ./internal/parser/id3
@$(GOTEST) -fuzz='^FuzzIPTCParse$$' -fuzztime=5s ./internal/parser/iptc
@$(GOTEST) -fuzz='^FuzzJPEGParse$$' -fuzztime=5s ./internal/parser/jpeg
@$(GOTEST) -fuzz='^FuzzMP4Parse$$' -fuzztime=5s ./internal/parser/mp4
@$(GOTEST) -fuzz='^FuzzPNGParse$$' -fuzztime=5s ./internal/parser/png
@$(GOTEST) -fuzz='^FuzzTIFFParse$$' -fuzztime=5s ./internal/parser/tiff
@$(GOTEST) -fuzz='^FuzzWebPParse$$' -fuzztime=5s ./internal/parser/webp
@$(GOTEST) -fuzz='^FuzzXMPParse$$' -fuzztime=5s ./internal/parser/xmp
@echo "✓ All fuzz tests complete"
# Show help
help:
@echo "imx - Image Metadata Extraction Library"
@echo ""
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@echo " all - Run check (default)"
@echo " check - Run lint, test, and build"
@echo " build - Build library, CLI, and examples"
@echo " test - Run all tests with race detector"
@echo " lint - Run go vet"
@echo " fmt - Format code with go fmt"
@echo " clean - Remove build artifacts"
@echo " install - Install CLI to GOPATH/bin"
@echo " coverage - Run tests with coverage (library + CLI)"
@echo " coverage-html- Generate HTML coverage report (library + CLI)"
@echo " bench - Run benchmarks"
@echo " fuzz - Run fuzz tests"
@echo " example - Build and run example"
@echo " help - Show this help"