-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
87 lines (76 loc) · 2.92 KB
/
Copy pathMakefile
File metadata and controls
87 lines (76 loc) · 2.92 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
BINARY := vidian
CMD := ./cmd/vidian/main.go
FRONTEND := ./frontend
PREFIX ?= /usr/local
INSTALL_DIR = $(PREFIX)/bin
.PHONY: all build install uninstall dev clean help visual-test user-install frontend
## help: Show this help message
help:
@echo ""
@echo " Vidian — Build & Install Commands"
@echo ""
@grep -E '^## ' Makefile | sed 's/^## //' | awk -F': ' '{printf " \033[36mmake %-14s\033[0m %s\n", $$1, $$2}'
@echo ""
## all: Build frontend and compile binary
all: frontend build
## frontend: Install npm deps and build Svelte assets
frontend:
@echo "→ Building frontend assets..."
cd $(FRONTEND) && npm install && npm run build
@echo "✓ Frontend built."
## build: Compile Go binary (requires frontend to be built first)
build:
@echo "→ Compiling Go binary..."
go build -ldflags="-s -w" -o $(BINARY) $(CMD)
@echo "✓ Binary ready: ./$(BINARY)"
## install: Build everything and install to $(INSTALL_DIR)
install: all
@echo "→ Installing $(BINARY) to $(INSTALL_DIR)..."
@# Copy to a temp name then atomically rename over the target. A plain cp
@# fails with "Text file busy" when the destination binary is currently
@# running; rename(2) swaps the directory entry instead, so a running
@# instance keeps its old (now-unlinked) inode and the next launch is new.
@if [ ! -w "$(INSTALL_DIR)" ]; then \
sudo cp $(BINARY) $(INSTALL_DIR)/$(BINARY).new && sudo mv -f $(INSTALL_DIR)/$(BINARY).new $(INSTALL_DIR)/$(BINARY); \
else \
cp $(BINARY) $(INSTALL_DIR)/$(BINARY).new && mv -f $(INSTALL_DIR)/$(BINARY).new $(INSTALL_DIR)/$(BINARY); \
fi
@echo "✓ Installed! Run: $(BINARY) ."
## user-install: Build everything and install to ~/.local/bin (no sudo)
user-install: all
@echo "→ Installing $(BINARY) to $(HOME)/.local/bin ..."
@mkdir -p $(HOME)/.local/bin
@# Temp-then-rename so re-installing over a running instance doesn't hit
@# "Text file busy" (see install target above).
@cp $(BINARY) $(HOME)/.local/bin/$(BINARY).new
@mv -f $(HOME)/.local/bin/$(BINARY).new $(HOME)/.local/bin/$(BINARY)
@echo "✓ Installed! Run: $(BINARY) ."
@echo " Tip: add $(HOME)/.local/bin to your PATH if needed."
## uninstall: Remove installed binary from $(INSTALL_DIR)
uninstall:
@echo "→ Removing $(BINARY) from $(INSTALL_DIR)..."
@if [ ! -w "$(INSTALL_DIR)" ]; then \
sudo rm -f $(INSTALL_DIR)/$(BINARY); \
else \
rm -f $(INSTALL_DIR)/$(BINARY); \
fi
@echo "✓ Uninstalled."
## dev: Show dev mode instructions
dev:
@echo ""
@echo " Run these in two separate terminals:"
@echo ""
@echo " Terminal 1 — Svelte dev server with HMR:"
@echo " cd frontend && npm run dev"
@echo ""
@echo " Terminal 2 — Go backend in dev mode:"
@echo " go run $(CMD) -dir . -dev -port 8080"
@echo ""
## visual-test: Run visual tests with screenshots and video (requires Docker)
visual-test: all
@./tests/visual/run.sh
## clean: Remove build artifacts
clean:
@rm -f $(BINARY)
@rm -rf $(FRONTEND)/dist
@echo "✓ Cleaned."