diff --git a/Makefile b/Makefile index dbfb669..4949642 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,7 @@ ELM_MAKE := elm make CARGO_BUILD := cargo build CARGO_RUN := cargo run +# Ensure exactly one of DEBUG or RELEASE is set ifeq ($(DEBUG)$(RELEASE),) # Both are empty $(error You must set exactly one of DEBUG=1 or RELEASE=1) endif @@ -20,14 +21,15 @@ endif # Targets .PHONY: all frontend backend clean serve +# Ensure PUBLIC_DIR exists $(PUBLIC_DIR): mkdir -p $(PUBLIC_DIR) +# Copy index.html into PUBLIC_DIR $(PUBLIC_DIR)/index.html: $(FRONTEND_DIR)/index.html $(PUBLIC_DIR) cp $< $@ -.PHONY: frontend backend - +# Frontend build target frontend: $(PUBLIC_DIR)/index.html $(PUBLIC_DIR) mkdir -p $(PUBLIC_DIR)/assets make -C $(FRONTEND_DIR) @@ -35,14 +37,21 @@ frontend: $(PUBLIC_DIR)/index.html $(PUBLIC_DIR) cp $(FRONTEND_DIR)/src/ports.websocket.js $(PUBLIC_DIR)/ cp $(FRONTEND_DIR)/assets/CourierPrime-Regular.ttf $(PUBLIC_DIR)/assets/ +# Backend build target backend: $(CARGO_BUILD) --manifest-path=$(BACKEND_DIR)/Cargo.toml +# Clean target (optional, assuming we want to remove build artifacts) +clean: + rm -rf $(PUBLIC_DIR) + +# Serve: Runs both frontend and backend serve: frontend backend ifeq ($(DEBUG),1) $(MAKE) -C $(FRONTEND_DIR) serve DEBUG=1 & \ + FRONTEND_PID=$$!; \ RUST_LOG=info,actix_web=debug $(CARGO_RUN) --manifest-path=$(BACKEND_DIR)/Cargo.toml; \ - kill %1 + kill $$FRONTEND_PID else ifeq ($(RELEASE),1) $(CARGO_RUN) --release --manifest-path=$(BACKEND_DIR)/Cargo.toml endif