Refactor build script into Makefile #3

Open
opened 2024-10-27 13:23:27 +01:00 by sven.seeberg · 0 comments
Owner
# Define variables for directories and executable names
TARGET_DIR = ./build
BACKEND_EXECUTABLE = simple-wkd
FRONTEND_DIST = dist
ASSETS_DIR = assets/webpage

# Phony targets to ensure they are always executed
.PHONY: all backend frontend

# Main target to build both backend and frontend
all: backend frontend

# Target to install dependencies for the backend
backend-deps:
	sudo apt install -y clang lld cargo

# Target to build the backend using Cargo
backend: backend-deps
	@echo "Building backend..."
	cp -R backend/* .
	cargo build --release --target-dir $(TARGET_DIR)
	mv $(TARGET_DIR)/release/$(BACKEND_EXECUTABLE) $(BACKEND_EXECUTABLE)-executable

# Target to install dependencies for the frontend
frontend-deps:
	sudo apt install -y npm

# Target to build the frontend using pnpm
frontend: frontend-deps
	@echo "Building frontend..."
	cp -R website/* .
	npm install -g pnpm
	pnpm install
	pnpm astro telemetry disable
	pnpm run build
	mv $(FRONTEND_DIST) $(ASSETS_DIR)
```makefile # Define variables for directories and executable names TARGET_DIR = ./build BACKEND_EXECUTABLE = simple-wkd FRONTEND_DIST = dist ASSETS_DIR = assets/webpage # Phony targets to ensure they are always executed .PHONY: all backend frontend # Main target to build both backend and frontend all: backend frontend # Target to install dependencies for the backend backend-deps: sudo apt install -y clang lld cargo # Target to build the backend using Cargo backend: backend-deps @echo "Building backend..." cp -R backend/* . cargo build --release --target-dir $(TARGET_DIR) mv $(TARGET_DIR)/release/$(BACKEND_EXECUTABLE) $(BACKEND_EXECUTABLE)-executable # Target to install dependencies for the frontend frontend-deps: sudo apt install -y npm # Target to build the frontend using pnpm frontend: frontend-deps @echo "Building frontend..." cp -R website/* . npm install -g pnpm pnpm install pnpm astro telemetry disable pnpm run build mv $(FRONTEND_DIST) $(ASSETS_DIR) ```
sven.seeberg changed title from Add makefile to Refactor build script into Makefile 2024-10-27 13:23:43 +01:00
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
NB-Public/simple-wkd#3
No description provided.