Skip to content

Commit ba74bdd

Browse files
authored
Merge pull request #304 from HyperloopUPV-H8/chore/improve-dev-environment
chore: enhance development environment with Makefile and shell.nix
2 parents e50eb4c + 241ceaf commit ba74bdd

2 files changed

Lines changed: 330 additions & 57 deletions

File tree

Makefile

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
# Hyperloop H10 Control Station Makefile
2+
3+
.PHONY: all install clean build-backend build-common-front build-control-station build-ethernet-view
4+
.PHONY: backend common-front control-station ethernet-view
5+
.PHONY: dev-backend dev-control-station dev-ethernet-view
6+
.PHONY: test test-backend test-frontend
7+
.PHONY: ethernet-view-tmux control-station-tmux
8+
9+
# Colors for output
10+
GREEN := \033[0;32m
11+
YELLOW := \033[0;33m
12+
BLUE := \033[0;34m
13+
RED := \033[0;31m
14+
NC := \033[0m # No Color
15+
16+
# Build directories
17+
BACKEND_DIR := backend
18+
COMMON_FRONT_DIR := common-front
19+
CONTROL_STATION_DIR := control-station
20+
ETHERNET_VIEW_DIR := ethernet-view
21+
22+
# Output binary
23+
BACKEND_BIN := $(BACKEND_DIR)/cmd/backend
24+
25+
# Default target
26+
all: install build
27+
28+
# Install all dependencies
29+
install: install-backend install-frontend
30+
@echo "$(GREEN)✓ All dependencies installed$(NC)"
31+
32+
install-backend:
33+
@echo "$(BLUE)Installing backend dependencies...$(NC)"
34+
@cd $(BACKEND_DIR) && go mod download
35+
@echo "$(GREEN)✓ Backend dependencies installed$(NC)"
36+
37+
install-frontend:
38+
@echo "$(BLUE)Installing frontend dependencies...$(NC)"
39+
@cd $(COMMON_FRONT_DIR) && npm install
40+
@cd $(CONTROL_STATION_DIR) && npm install
41+
@cd $(ETHERNET_VIEW_DIR) && npm install
42+
@echo "$(GREEN)✓ Frontend dependencies installed$(NC)"
43+
44+
# Build all components
45+
build: build-backend build-frontend
46+
@echo "$(GREEN)✓ All components built successfully$(NC)"
47+
48+
build-frontend: build-common-front build-control-station build-ethernet-view
49+
50+
# Individual build targets
51+
backend build-backend:
52+
@echo "$(BLUE)Building backend...$(NC)"
53+
@cd $(BACKEND_DIR)/cmd && go build -o backend
54+
@echo "$(GREEN)✓ Backend built: $(BACKEND_BIN)$(NC)"
55+
56+
common-front build-common-front:
57+
@echo "$(BLUE)Building common-front...$(NC)"
58+
@cd $(COMMON_FRONT_DIR) && npm run build
59+
@echo "$(GREEN)✓ Common-front built$(NC)"
60+
61+
control-station build-control-station: build-common-front
62+
@echo "$(BLUE)Building control-station...$(NC)"
63+
@cd $(CONTROL_STATION_DIR) && npm run build
64+
@echo "$(GREEN)✓ Control-station built$(NC)"
65+
66+
ethernet-view build-ethernet-view: build-common-front
67+
@echo "$(BLUE)Building ethernet-view...$(NC)"
68+
@cd $(ETHERNET_VIEW_DIR) && npm run build
69+
@echo "$(GREEN)✓ Ethernet-view built$(NC)"
70+
71+
# Development servers (individual)
72+
dev-backend:
73+
@echo "$(YELLOW)Starting backend development server...$(NC)"
74+
@cd $(BACKEND_DIR)/cmd && ./backend
75+
76+
dev-control-station:
77+
@echo "$(YELLOW)Starting control-station development server...$(NC)"
78+
@cd $(CONTROL_STATION_DIR) && npm run dev
79+
80+
dev-ethernet-view:
81+
@echo "$(YELLOW)Starting ethernet-view development server...$(NC)"
82+
@cd $(ETHERNET_VIEW_DIR) && npm run dev
83+
84+
# Testing
85+
test: test-backend test-frontend
86+
87+
test-backend:
88+
@echo "$(BLUE)Running backend tests...$(NC)"
89+
@cd $(BACKEND_DIR) && go test -v -timeout 30s ./...
90+
91+
test-frontend:
92+
@echo "$(BLUE)Running frontend tests...$(NC)"
93+
@cd $(ETHERNET_VIEW_DIR) && npm test || true
94+
@echo "$(YELLOW)Note: Only ethernet-view has tests configured$(NC)"
95+
96+
# Clean build artifacts
97+
clean:
98+
@echo "$(YELLOW)Cleaning build artifacts...$(NC)"
99+
@rm -f $(BACKEND_BIN)
100+
@rm -rf $(COMMON_FRONT_DIR)/dist
101+
@rm -rf $(CONTROL_STATION_DIR)/dist
102+
@rm -rf $(ETHERNET_VIEW_DIR)/dist
103+
@echo "$(GREEN)✓ Clean complete$(NC)"
104+
105+
# Combined tmux sessions
106+
ethernet-view-tmux: build-backend
107+
@echo "$(BLUE)Starting backend + ethernet-view in tmux...$(NC)"
108+
@tmux new-session -d -s ethernet-view-session -n main
109+
@tmux send-keys -t ethernet-view-session:main "cd $(BACKEND_DIR)/cmd && ./backend" C-m
110+
@tmux split-window -t ethernet-view-session:main -h
111+
@tmux send-keys -t ethernet-view-session:main.1 "cd $(ETHERNET_VIEW_DIR) && npm run dev" C-m
112+
@tmux select-pane -t ethernet-view-session:main.0
113+
@tmux attach-session -t ethernet-view-session
114+
115+
control-station-tmux: build-backend
116+
@echo "$(BLUE)Starting backend + control-station in tmux...$(NC)"
117+
@tmux new-session -d -s control-station-session -n main
118+
@tmux send-keys -t control-station-session:main "cd $(BACKEND_DIR)/cmd && ./backend" C-m
119+
@tmux split-window -t control-station-session:main -h
120+
@tmux send-keys -t control-station-session:main.1 "cd $(CONTROL_STATION_DIR) && npm run dev" C-m
121+
@tmux select-pane -t control-station-session:main.0
122+
@tmux attach-session -t control-station-session
123+
124+
# Help target
125+
help:
126+
@echo "Hyperloop H10 Control Station - Build System"
127+
@echo "==========================================="
128+
@echo ""
129+
@echo "$(YELLOW)Installation:$(NC)"
130+
@echo " make install - Install all dependencies"
131+
@echo " make install-backend - Install backend dependencies only"
132+
@echo " make install-frontend - Install frontend dependencies only"
133+
@echo ""
134+
@echo "$(YELLOW)Building:$(NC)"
135+
@echo " make all - Install deps and build everything"
136+
@echo " make build - Build all components"
137+
@echo " make backend - Build backend only"
138+
@echo " make common-front - Build common frontend library"
139+
@echo " make control-station - Build control station"
140+
@echo " make ethernet-view - Build ethernet view"
141+
@echo ""
142+
@echo "$(YELLOW)Development:$(NC)"
143+
@echo " make dev-backend - Run backend dev server"
144+
@echo " make dev-control-station - Run control station dev server"
145+
@echo " make dev-ethernet-view - Run ethernet view dev server"
146+
@echo ""
147+
@echo "$(YELLOW)Combined Sessions:$(NC)"
148+
@echo " make ethernet-view-tmux - Run backend + ethernet-view in tmux"
149+
@echo " make control-station-tmux - Run backend + control-station in tmux"
150+
@echo ""
151+
@echo "$(YELLOW)Testing:$(NC)"
152+
@echo " make test - Run all tests"
153+
@echo " make test-backend - Run backend tests"
154+
@echo " make test-frontend - Run frontend tests"
155+
@echo ""
156+
@echo "$(YELLOW)Maintenance:$(NC)"
157+
@echo " make clean - Remove build artifacts"
158+
@echo " make help - Show this help message"

0 commit comments

Comments
 (0)