-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
37 lines (30 loc) · 739 Bytes
/
Copy pathMakefile
File metadata and controls
37 lines (30 loc) · 739 Bytes
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
# Variables
BINARY_NAME=dated
OUTPUT_DIR=out
SRC_DIR=.
GO=go
GOFLAGS=-ldflags="-s -w"
# Default target
all: build
# Build the binary
build:
@echo "Building $(BINARY_NAME)..."
@mkdir -p $(OUTPUT_DIR)
@$(GO) build $(GOFLAGS) -o $(OUTPUT_DIR)/$(BINARY_NAME) $(SRC_DIR)
@echo "Built successfully in $(OUTPUT_DIR)/"
# Clean the output directory
clean:
@echo "Cleaning up..."
@rm -rf $(OUTPUT_DIR)
@echo "Done cleaning."
# Run the application (with optional args)
run: build
@echo "Running $(BINARY_NAME) with args: $(filter-out run,$(MAKECMDGOALS))\n"
@./$(OUTPUT_DIR)/$(BINARY_NAME) $(filter-out run,$(MAKECMDGOALS))
# Run all tests
test:
@echo "Running tests..."
@$(GO) test -v ./...
%:
@:
.PHONY: all build clean run test