convert_to_actix #2

Merged
Yehowshua merged 20 commits from convert_to_actix into main 2025-01-06 06:25:19 +00:00
4 changed files with 45 additions and 20 deletions
Showing only changes of commit 7a59aab77d - Show all commits

1
.gitignore vendored
View file

@ -6,3 +6,4 @@ frontend/package-lock.json
frontend/package.json frontend/package.json
backend/target backend/target
public/* public/*
elm-stuff/*

View file

@ -9,19 +9,33 @@ ELM_MAKE := elm make
CARGO_BUILD := cargo build CARGO_BUILD := cargo build
CARGO_RUN := cargo run 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 # Targets
.PHONY: all frontend backend clean serve .PHONY: all frontend backend clean serve
frontend_release: $(PUBLIC_DIR):
make -C $(FRONTEND_DIR) release_build mkdir -p $(PUBLIC_DIR)
cp $(FRONTEND_DIR)/index.html $(PUBLIC_DIR)/
cp $(FRONTEND_DIR)/elm.min.js $(PUBLIC_DIR)/
cp $(FRONTEND_DIR)/src/ports.websocket.js $(PUBLIC_DIR)/
mkdir -p $(PUBLIC_DIR)/assets
frontend_debug: $(PUBLIC_DIR)/index.html: $(FRONTEND_DIR)/index.html $(PUBLIC_DIR)
make -C $(FRONTEND_DIR) debug_build cp $< $@
cp $(FRONTEND_DIR)/index.html $(PUBLIC_DIR)/
$(FRONTEND_DIR)/elm.min.js:
ifeq ($(DEBUG),1)
make -C $(FRONTEND_DIR) DEBUG=1
else ifeq ($(RELEASE),1)
make -C $(FRONTEND_DIR) RELEASE=1
endif
.PHONY: frontend backend
frontend: $(PUBLIC_DIR)/index.html $(FRONTEND_DIR)/elm.min.js $(PUBLIC_DIR)
cp $(FRONTEND_DIR)/elm.min.js $(PUBLIC_DIR)/ cp $(FRONTEND_DIR)/elm.min.js $(PUBLIC_DIR)/
cp $(FRONTEND_DIR)/src/ports.websocket.js $(PUBLIC_DIR)/ cp $(FRONTEND_DIR)/src/ports.websocket.js $(PUBLIC_DIR)/
mkdir -p $(PUBLIC_DIR)/assets mkdir -p $(PUBLIC_DIR)/assets
@ -29,11 +43,12 @@ frontend_debug:
backend: backend:
$(CARGO_BUILD) --manifest-path=$(BACKEND_DIR)/Cargo.toml $(CARGO_BUILD) --manifest-path=$(BACKEND_DIR)/Cargo.toml
serve: frontend_release backend serve: frontend backend
$(CARGO_RUN) --manifest-path=$(BACKEND_DIR)/Cargo.toml ifeq ($(DEBUG),1)
serve_debug: frontend_debug backend
RUST_LOG=info,actix_web=debug $(CARGO_RUN) --manifest-path=$(BACKEND_DIR)/Cargo.toml RUST_LOG=info,actix_web=debug $(CARGO_RUN) --manifest-path=$(BACKEND_DIR)/Cargo.toml
else ifeq ($(RELEASE),1)
$(CARGO_RUN) --manifest-path=$(BACKEND_DIR)/Cargo.toml
endif
clean: clean:
rm -rf $(PUBLIC_DIR)/* rm -rf $(PUBLIC_DIR)/*

View file

@ -2,10 +2,18 @@ SRC_FILES := $(shell find src -name "*.elm")
all: elm.min.js all: elm.min.js
debug_build: $(SRC_FILES) ifeq ($(DEBUG)$(RELEASE),) # Both are empty
rm -f elm.min.js elm.js $(error You must set exactly one of DEBUG=1 or RELEASE=1)
./build.sh --debug src/Main.elm endif
release_build: $(SRC_FILES) ifeq ($(DEBUG)$(RELEASE),11) # Both are set
rm -f elm.min.js elm.js $(error Both DEBUG and RELEASE cannot be set at the same time)
endif
elm.min.js: $(SRC_FILES)
ifeq ($(DEBUG),1)
./build.sh --debug src/Main.elm
else ifeq ($(RELEASE),1)
./build.sh --optimize src/Main.elm ./build.sh --optimize src/Main.elm
endif

View file

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
set -e set -ex
js="elm.js" js="elm.js"
min="elm.min.js" min="elm.min.js"
@ -14,7 +14,8 @@ else
exit 1 exit 1
fi fi
uglifyjs $js --compress 'pure_funcs=[F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9],pure_getters,keep_fargs=false,unsafe_comps,unsafe' | uglifyjs --mangle --output $min uglifyjs elm.js --compress 'pure_funcs="F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9",pure_getters=true,keep_fargs=false,unsafe_comps=true,unsafe=true,passes=2' --output=elm.js
uglifyjs elm.js --mangle --output=elm.js
echo "Compiled size: $(wc -c < $js) bytes ($js)" echo "Compiled size: $(wc -c < $js) bytes ($js)"
echo "Minified size: $(wc -c < $min) bytes ($min)" echo "Minified size: $(wc -c < $min) bytes ($min)"