-
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathMakefile
More file actions
88 lines (74 loc) · 2.53 KB
/
Copy pathMakefile
File metadata and controls
88 lines (74 loc) · 2.53 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
.PHONY: all build test clean generate install release lint check help
# Project variables
BINARY_NAME=vipsgen
BUILD_DIR=./bin
TEMPLATE_DIR=./internal/templates
OUTPUT_DIR=./vips
CMD_DIR=./cmd/vipsgen
MAIN_GO=$(CMD_DIR)/main.go
VERSION=$(shell git describe --tags --always --dirty 2>/dev/null || echo "v0.0.0")
LDFLAGS=-ldflags "-X main.version=$(VERSION)"
GO=$(shell command -v go)
# CGO environment variables for macOS and other platforms that need them
CGO_FLAGS=CGO_CFLAGS_ALLOW=-Xpreprocessor
# Default target
all: check build test
# Build the binary
build:
@echo "Building $(BINARY_NAME)..."
@mkdir -p $(BUILD_DIR)
$(CGO_FLAGS) $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME) $(MAIN_GO)
@echo "Binary $(BUILD_DIR)/$(BINARY_NAME) is ready"
# Run all tests
test:
@echo "Running tests..."
@$(GO) clean -testcache
$(CGO_FLAGS) $(GO) test -v -coverprofile=profile.cov ./...
# Clean build artifacts
clean:
@echo "Cleaning build artifacts..."
@rm -rf $(BUILD_DIR)
@rm -rf $(OUTPUT_DIR)
@$(GO) clean
# Generate bindings
generate: build
@echo "Generating libvips bindings..."
@mkdir -p $(OUTPUT_DIR)
$(CGO_FLAGS) $(BUILD_DIR)/$(BINARY_NAME) -out $(OUTPUT_DIR) -debug
@echo "Bindings generated in $(OUTPUT_DIR)"
# Generate with custom templates
generate-custom: build
@echo "Generating libvips bindings with custom templates..."
@mkdir -p $(OUTPUT_DIR)
$(CGO_FLAGS) $(BUILD_DIR)/$(BINARY_NAME) -templates $(TEMPLATE_DIR) -out $(OUTPUT_DIR)
@echo "Bindings generated in $(OUTPUT_DIR)"
# Extract templates
extract-templates: build
@echo "Extracting templates..."
@mkdir -p $(TEMPLATE_DIR)
$(CGO_FLAGS) $(BUILD_DIR)/$(BINARY_NAME) -extract -extract-dir $(TEMPLATE_DIR)
@echo "Templates extracted to $(TEMPLATE_DIR)"
# Install the binary
install: build
@echo "Installing $(BINARY_NAME)..."
$(CGO_FLAGS) $(GO) install $(LDFLAGS) $(MAIN_GO)
@echo "Installation complete"
# Run the generator directly from source (without installing)
run:
@echo "Running $(BINARY_NAME) directly..."
$(CGO_FLAGS) $(GO) run $(MAIN_GO) -out $(OUTPUT_DIR)
# Create a release
release: check test build
@echo "Creating release $(VERSION)..."
@mkdir -p release
@tar -czf release/$(BINARY_NAME)-$(VERSION).tar.gz -C $(BUILD_DIR) $(BINARY_NAME)
@echo "Release $(VERSION) created in release/"
# Run golangci-lint
lint:
@echo "Running linters..."
@golangci-lint run ./...
# Check dependencies
check:
@echo "Checking dependencies..."
@pkg-config --exists vips || (echo "Error: libvips not found (install libvips-dev or equivalent)" && exit 1)
@echo "All dependencies satisfied"