-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
98 lines (79 loc) · 2.07 KB
/
Copy pathmakefile
File metadata and controls
98 lines (79 loc) · 2.07 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
# Project
BINARY_NAME := dizz
BUILD_DIR := bin
MAIN_PKG := .
# Local development install
INSTALL_DIR := $(HOME)/.local/bin
TARGET_NAME := dizz-dev
# Go env
GO := go
GOFLAGS := -trimpath
# Version injection — uses the latest git tag, falls back to "dev"
VERSION := $(shell git describe --tags --abbrev=0 2>/dev/null || echo "dev")
LDFLAGS := -X github.com/TheShiveshNetwork/dizz/cmd.version=$(VERSION)
# Default target
.PHONY: all
all: build
## Build the binary
.PHONY: build
build:
@echo "🔨 Building $(BINARY_NAME) $(VERSION)..."
@mkdir -p $(BUILD_DIR)
$(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME) $(MAIN_PKG)
## Run the CLI (after build)
.PHONY: run
run: build
@echo "🚀 Running $(BINARY_NAME)..."
@$(BUILD_DIR)/$(BINARY_NAME)
## Run with args: make run ARGS="status"
.PHONY: run-args
run-args: build
@$(BUILD_DIR)/$(BINARY_NAME) $(ARGS)
## Dev shortcut (fast rebuild + run)
.PHONY: dev
dev:
@$(GO) build -o /tmp/$(BINARY_NAME)
@/tmp/$(BINARY_NAME)
## Clean build artifacts
.PHONY: clean
clean:
@echo "🧹 Cleaning..."
@rm -rf $(BUILD_DIR)
@rm -f /tmp/$(BINARY_NAME)
## Run tests
.PHONY: test
test:
@echo "🧪 Running tests..."
@$(GO) test -v ./tests/...
## Run benchmarks
.PHONY: bench
bench:
@echo "📊 Running benchmarks..."
@$(GO) test -bench=. -benchmem ./tests/...
## Format code
.PHONY: fmt
fmt:
@$(GO) fmt ./...
## Lint (requires golangci-lint)
.PHONY: lint
lint:
@golangci-lint run
## Install locally (copy binary)
.PHONY: install
install: build
@echo "📦 Installing $(TARGET_NAME) to $(INSTALL_DIR)..."
@mkdir -p $(INSTALL_DIR)
@cp $(BUILD_DIR)/$(BINARY_NAME) $(INSTALL_DIR)/$(TARGET_NAME)
@chmod +x $(INSTALL_DIR)/$(TARGET_NAME)
@echo "✅ Installed as $(TARGET_NAME)"
.PHONY: uninstall
uninstall:
@echo "🗑 Removing $(TARGET_NAME)..."
@rm -f $(INSTALL_DIR)/$(TARGET_NAME)
build-site:
./scripts/build-site.sh
wasm:
cd site/wasm && GOOS=js GOARCH=wasm go build -o ../public/dizz.wasm
cp "$$(go env GOROOT)/misc/wasm/wasm_exec.js" site/public/
serve-site:
cd site/server && go run server.go