-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
67 lines (52 loc) · 1.97 KB
/
Copy pathMakefile
File metadata and controls
67 lines (52 loc) · 1.97 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
PROJECT_NAME := plus
VERSION := $(shell cat VERSION)
GIT_COMMIT := $(shell git rev-parse HEAD)
GO := go
GOOS := linux
GOARCH := amd64
OUTPUT_DIR := bin
OUTPUT_BIN := $(OUTPUT_DIR)/$(PROJECT_NAME)
SRC_DIR := .
all: build
build:
@echo "Building $(PROJECT_NAME) for macOS..."
@mkdir -p $(OUTPUT_DIR)
@$(GO) build -ldflags "-X main.version=${VERSION} -X main.gitCommit=${GIT_COMMIT}" -o $(OUTPUT_BIN)-darwin-arm64 $(SRC_DIR)
@echo "Build completed: $(OUTPUT_BIN) for macOS"
build-amd:
@echo "Building $(PROJECT_NAME) for $(GOOS)/$(GOARCH)..."
@mkdir -p $(OUTPUT_DIR)
@GOOS=$(GOOS) GOARCH=$(GOARCH) $(GO) build -ldflags "-X main.version=${VERSION} -X main.gitCommit=${GIT_COMMIT}" -o $(OUTPUT_BIN)-$(GOOS)-amd64 $(SRC_DIR)
@echo "Build completed: $(OUTPUT_BIN)-$(GOOS)-amd"
build-arm:
@echo "Building $(PROJECT_NAME) for $(GOOS)/arm..."
@mkdir -p $(OUTPUT_DIR)
@GOOS=$(GOOS) GOARCH=arm64 $(GO) build -ldflags "-X main.version=${VERSION} -X main.gitCommit=${GIT_COMMIT}" -o $(OUTPUT_BIN)-$(GOOS)-arm64 $(SRC_DIR)
@echo "Build completed: $(OUTPUT_BIN)-$(GOOS)-arm"
build-all: build build-amd build-arm
clean:
@echo "Cleaning build artifacts..."
@rm -rf $(OUTPUT_DIR)
@echo "Clean completed."
run: build
@echo "Running $(PROJECT_NAME)..."
@$(OUTPUT_BIN)
test:
@echo "Running tests..."
@$(GO) test -v ./...
deps:
@echo "Installing dependencies..."
@$(GO) mod download
help:
@echo "Available targets:"
@echo " all - Build the project for macOS (default target)"
@echo " build - Build the project for macOS"
@echo " build-amd - Build the project for x86"
@echo " build-arm - Build the project for ARM"
@echo " build-all - Build the project for both x86/ARM/macOS"
@echo " clean - Clean build artifacts"
@echo " run - Build and run the project (x86 version)"
@echo " test - Run tests"
@echo " deps - Install dependencies"
@echo " help - Show this help message"
.PHONY: all build build-amd build-arm build-all clean run test deps help