49 lines
1.2 KiB
Makefile
49 lines
1.2 KiB
Makefile
# Directories
|
|
FRONTEND_DIR := ./frontend
|
|
BACKEND_DIR := ./backend
|
|
PUBLIC_DIR := ./public
|
|
ASSET_DIR := ./assets
|
|
|
|
# Commands
|
|
ELM_MAKE := elm make
|
|
CARGO_BUILD := cargo build
|
|
CARGO_RUN := cargo run
|
|
|
|
ifeq ($(DEBUG)$(RELEASE),) # Both are empty
|
|
$(error You must set exactly one of DEBUG=1 or RELEASE=1)
|
|
endif
|
|
|
|
ifeq ($(DEBUG)$(RELEASE),11) # Both are set
|
|
$(error Both DEBUG and RELEASE cannot be set at the same time)
|
|
endif
|
|
|
|
# Targets
|
|
.PHONY: all frontend backend clean serve
|
|
|
|
$(PUBLIC_DIR):
|
|
mkdir -p $(PUBLIC_DIR)
|
|
|
|
$(PUBLIC_DIR)/index.html: $(FRONTEND_DIR)/index.html $(PUBLIC_DIR)
|
|
cp $< $@
|
|
|
|
.PHONY: frontend backend
|
|
|
|
frontend: $(PUBLIC_DIR)/index.html $(PUBLIC_DIR)
|
|
mkdir -p $(PUBLIC_DIR)/assets
|
|
make -C $(FRONTEND_DIR)
|
|
cp $(FRONTEND_DIR)/elm.min.js $(PUBLIC_DIR)/
|
|
cp $(FRONTEND_DIR)/src/ports.websocket.js $(PUBLIC_DIR)/
|
|
cp $(FRONTEND_DIR)/assets/CourierPrime-Regular.ttf $(PUBLIC_DIR)/assets/
|
|
|
|
backend:
|
|
$(CARGO_BUILD) --manifest-path=$(BACKEND_DIR)/Cargo.toml
|
|
|
|
serve: frontend backend
|
|
ifeq ($(DEBUG),1)
|
|
$(MAKE) -C $(FRONTEND_DIR) serve DEBUG=1 & \
|
|
RUST_LOG=info,actix_web=debug $(CARGO_RUN) --manifest-path=$(BACKEND_DIR)/Cargo.toml; \
|
|
kill %1
|
|
else ifeq ($(RELEASE),1)
|
|
$(CARGO_RUN) --release --manifest-path=$(BACKEND_DIR)/Cargo.toml
|
|
endif
|