-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
117 lines (104 loc) · 2.69 KB
/
Makefile
File metadata and controls
117 lines (104 loc) · 2.69 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# Horizon - Infrastructure Intelligence Tool
# Makefile for building and installing
BINARY_NAME := hz
CARGO := cargo
INSTALL_DIR := $(HOME)/.local/bin
DATA_DIR := $(HOME)/.horizon
DB_FILE := horizon.db
# Default target
.PHONY: all
all: build
# Build release binary
.PHONY: build
build:
$(CARGO) build --release
# Build debug binary
.PHONY: debug
debug:
$(CARGO) build
# Run tests
.PHONY: test
test:
$(CARGO) test
# Run clippy
.PHONY: lint
lint:
$(CARGO) clippy --all-targets
# Format code
.PHONY: fmt
fmt:
$(CARGO) fmt
# Run benchmarks
.PHONY: bench
bench:
$(CARGO) bench
# Install binary and database
.PHONY: install
install: build
@echo "Installing Horizon..."
@mkdir -p $(INSTALL_DIR)
@mkdir -p $(DATA_DIR)
@cp target/release/$(BINARY_NAME) $(INSTALL_DIR)/$(BINARY_NAME)
@chmod +x $(INSTALL_DIR)/$(BINARY_NAME)
@if [ -f data/$(DB_FILE) ]; then \
cp data/$(DB_FILE) $(DATA_DIR)/$(DB_FILE); \
echo "Database installed to $(DATA_DIR)/$(DB_FILE)"; \
else \
echo "Warning: No database found in data/. Run 'make install-db' after building database."; \
fi
@echo ""
@echo "✓ Installed $(BINARY_NAME) to $(INSTALL_DIR)"
@echo ""
@echo "Make sure $(INSTALL_DIR) is in your PATH:"
@echo " export PATH=\"\$$HOME/.local/bin:\$$PATH\""
@echo ""
@echo "Test with: hz --version"
# Install only the database (useful for updates)
.PHONY: install-db
install-db:
@mkdir -p $(DATA_DIR)
@if [ -f data/$(DB_FILE) ]; then \
cp data/$(DB_FILE) $(DATA_DIR)/$(DB_FILE); \
echo "✓ Database installed to $(DATA_DIR)/$(DB_FILE)"; \
else \
echo "Error: No database found. Build it first with the data pipeline."; \
exit 1; \
fi
# Uninstall
.PHONY: uninstall
uninstall:
@echo "Uninstalling Horizon..."
@rm -f $(INSTALL_DIR)/$(BINARY_NAME)
@echo "✓ Removed $(INSTALL_DIR)/$(BINARY_NAME)"
@echo ""
@echo "Note: Database at $(DATA_DIR) was not removed."
@echo "To fully remove: rm -rf $(DATA_DIR)"
# Clean build artifacts
.PHONY: clean
clean:
$(CARGO) clean
# Show help
.PHONY: help
help:
@echo "Horizon Makefile"
@echo ""
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@echo " build Build release binary (default)"
@echo " debug Build debug binary"
@echo " test Run tests"
@echo " lint Run clippy linter"
@echo " fmt Format code"
@echo " bench Run benchmarks"
@echo ""
@echo " install Install binary and database to ~/.local/bin and ~/.horizon"
@echo " install-db Install only the database (for updates)"
@echo " uninstall Remove installed binary"
@echo ""
@echo " clean Remove build artifacts"
@echo " help Show this help"
@echo ""
@echo "Environment:"
@echo " INSTALL_DIR=$(INSTALL_DIR)"
@echo " DATA_DIR=$(DATA_DIR)"