Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 25 additions & 11 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ GOFMT = gofmt

BACKEND_DIR = backend
FRONTEND_DIR = frontend
BACKEND_LOG = backend.log
BACKEND_PORT = 8080 # Update this if needed

deps:
@echo "Installing Go dependencies..."
Expand All @@ -18,25 +20,37 @@ build-frontend:
@echo "Building the frontend application..."
$(GO) build -o $(FRONTEND_DIR)/$(BINARY_NAME) $(FRONTEND_DIR)/widget.go

run-backend: build-backend
build: build-backend build-frontend

run-backend:
@echo "Running the backend server..."
$(BACKEND_DIR)/$(BINARY_NAME)
@$(BACKEND_DIR)/$(BINARY_NAME) > $(BACKEND_LOG) 2>&1 & # Run in background
@echo "Backend started in the background."

wait-backend:
@echo "Waiting for backend to start..."
@while ! nc -z localhost $(BACKEND_PORT); do sleep 1; done
@echo "Backend is running!"

run-frontend: build-frontend
run-frontend:
@echo "Running the frontend application..."
$(FRONTEND_DIR)/$(BINARY_NAME)
@$(FRONTEND_DIR)/$(BINARY_NAME)

run-all: deps build run-backend wait-backend run-frontend

clean:
@echo "Cleaning up..."
rm -f $(BACKEND_DIR)/$(BINARY_NAME) $(FRONTEND_DIR)/$(BINARY_NAME)
rm -f $(BACKEND_DIR)/$(BINARY_NAME) $(FRONTEND_DIR)/$(BINARY_NAME) $(BACKEND_LOG)

help:
@echo "Makefile for Go application"
@echo ""
@echo "Available targets:"
@echo " build - Build both backend and frontend applications"
@echo " run-backend - Build and run the backend server"
@echo " run-frontend - Build and run the frontend application"
@echo " clean - Remove the generated binaries"
@echo " deps - Install Go dependencies and tidy up"
@echo " help - Show this help message"
@echo " build - Build both backend and frontend applications"
@echo " run-backend - Build and run the backend server"
@echo " wait-backend - Wait until the backend is ready using a real check"
@echo " run-frontend - Build and run the frontend application"
@echo " run-all - Install deps, build everything, then run backend & frontend"
@echo " clean - Remove generated binaries and logs"
@echo " deps - Install Go dependencies and tidy up"
@echo " help - Show this help message"