-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
60 lines (45 loc) · 1.45 KB
/
Makefile
File metadata and controls
60 lines (45 loc) · 1.45 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
SHELL := /bin/bash
.PHONY: oapi-generate generate-wire generate-all dev build test install-tools
# Directory where local binaries will be installed
BIN_DIR ?= $(CURDIR)/bin
$(BIN_DIR):
mkdir -p $(BIN_DIR)
# Local binary paths
OAPI_CODEGEN ?= $(BIN_DIR)/oapi-codegen
AIR ?= $(BIN_DIR)/air
WIRE ?= $(BIN_DIR)/wire
# Install oapi-codegen
$(OAPI_CODEGEN): | $(BIN_DIR)
GOBIN=$(BIN_DIR) go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latest
# Install air for hot reload
$(AIR): | $(BIN_DIR)
GOBIN=$(BIN_DIR) go install github.com/air-verse/air@latest
# Install wire for dependency injection
$(WIRE): | $(BIN_DIR)
GOBIN=$(BIN_DIR) go install github.com/google/wire/cmd/wire@latest
install-tools: $(OAPI_CODEGEN) $(AIR) $(WIRE)
# Generate Go code from OpenAPI spec
oapi-generate: $(OAPI_CODEGEN)
@echo "Generating Go code from OpenAPI spec..."
$(OAPI_CODEGEN) -config ./oapi-codegen.yaml ./openapi.yaml
@echo "Formatting generated code..."
go fmt ./lib/oapi/oapi.go
# Generate wire dependency injection code
generate-wire: $(WIRE)
@echo "Generating wire code..."
cd ./cmd/api && $(WIRE)
# Generate all code
generate-all: oapi-generate generate-wire
# Build the binary
build: | $(BIN_DIR)
go build -o $(BIN_DIR)/hypeman ./cmd/api
# Run in development mode with hot reload
dev: $(AIR)
$(AIR) -c .air.toml
# Run tests
test:
go test -v -timeout 30s ./...
# Clean generated files and binaries
clean:
rm -rf $(BIN_DIR)
rm -f lib/oapi/oapi.go