-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
109 lines (88 loc) · 4.04 KB
/
Makefile
File metadata and controls
109 lines (88 loc) · 4.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Makefile for ZQS Terminal
WASM_TARGET = wasm32-unknown-unknown
STATIC_DIR = static
PKG_DIR = pkg
STATIC_PKG = $(STATIC_DIR)/pkg
HOST ?= 0.0.0.0
SERVER_PORT ?= 3000
STATIC_PORT ?= 8765
SERVER_MANIFEST = server/Cargo.toml
NETLIFY_BIN ?= netlify
NETLIFY_FLAGS ?=
PROJECT_VERSION := $(shell cat VERSION 2>/dev/null)
LOCAL_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null)
BUILD_ID := $(or $(LOCAL_COMMIT),$(PROJECT_VERSION),dev)
NETLIFY_MESSAGE ?= Deploy $(PROJECT_VERSION)
AUTOTEST_FLAGS ?=
VERSION_URL ?= https://www.zqsdev.com/api/version
.PHONY: build build-frontend clean check fmt serve serve-static test autotest deploy-preview deploy-prod deploy update backend-log rag version-check bump-version ensure-version-bumped
build:
@command -v wasm-pack >/dev/null 2>&1 || { echo "wasm-pack not found. Install with 'cargo install wasm-pack'."; exit 1; }
rustup target add $(WASM_TARGET) >/dev/null 2>&1 || true
wasm-pack build --target web --release
@if command -v wasm-opt >/dev/null 2>&1; then \
wasm-opt -Oz $(PKG_DIR)/zqs_terminal_bg.wasm -o $(PKG_DIR)/zqs_terminal_bg.wasm; \
else \
echo "wasm-opt not found. Install binaryen to optimize the WebAssembly output."; \
fi
mkdir -p $(STATIC_PKG)
cp -r $(PKG_DIR)/* $(STATIC_PKG)/
python3 scripts/minify_css.py $(STATIC_DIR)/style.css -o $(STATIC_DIR)/style.min.css
@echo "window.__BUILD_ID__ = \"$(BUILD_ID)\";" > $(STATIC_DIR)/build_id.js
@if [ "$(SKIP_RAG)" = "1" ]; then \
echo "Skipping RAG bundle rebuild because SKIP_RAG=1"; \
else \
$(MAKE) rag; \
fi
cargo build --release --manifest-path $(SERVER_MANIFEST)
build-frontend:
@SKIP_RAG=1 $(MAKE) build
rag:
@command -v python3 >/dev/null 2>&1 || { echo "python3 not found. Install Python 3 to continue."; exit 1; }
python3 scripts/build_rag.py $(RAG_FLAGS)
rag-inspect:
@python3 scripts/inspect_rag.py $(RAG_INSPECT_FLAGS)
test:
@command -v wasm-pack >/dev/null 2>&1 || { echo "wasm-pack not found. Install with 'cargo install wasm-pack'."; exit 1; }
@command -v python3 >/dev/null 2>&1 || { echo "python3 not found. Install Python 3 to continue."; exit 1; }
rustup target add $(WASM_TARGET) >/dev/null 2>&1 || true
python3 -m unittest scripts.test_build_rag
wasm-pack test --node
cargo test --manifest-path $(SERVER_MANIFEST)
autotest:
@command -v python3 >/dev/null 2>&1 || { echo "python3 not found. Install Python 3 to continue."; exit 1; }
@python3 -c "import requests" >/dev/null 2>&1 || { echo "Python package 'requests' not found. Install with 'pip install requests'."; exit 1; }
python3 scripts/live_smoke_test.py $(AUTOTEST_FLAGS)
check:
cargo check --target $(WASM_TARGET)
fmt:
cargo fmt
serve: build
@echo "Starting Rust proxy server on http://$(HOST):$(SERVER_PORT)"
HOST=$(HOST) PORT=$(SERVER_PORT) STATIC_DIR=$(STATIC_DIR) cargo run --manifest-path $(SERVER_MANIFEST)
serve-static: build
@python3 scripts/serve.py --root $(STATIC_DIR) --host $(HOST) --port $(STATIC_PORT)
deploy-preview: build
@command -v $(NETLIFY_BIN) >/dev/null 2>&1 || { echo "netlify CLI not found. Install with 'npm install -g netlify-cli'."; exit 1; }
$(NETLIFY_BIN) deploy --dir $(STATIC_DIR) --message "$(NETLIFY_MESSAGE)" $(NETLIFY_FLAGS)
deploy-prod: build
@command -v $(NETLIFY_BIN) >/dev/null 2>&1 || { echo "netlify CLI not found. Install with 'npm install -g netlify-cli'."; exit 1; }
$(NETLIFY_BIN) deploy --dir $(STATIC_DIR) --prod --message "$(NETLIFY_MESSAGE)" $(NETLIFY_FLAGS)
deploy: deploy-prod
update:
@git pull --rebase
$(MAKE) build
@sudo systemctl restart zqs-terminal.service
backend-log:
@sudo tail -f backend.log
version-check:
@echo "Local frontend version: $(PROJECT_VERSION)"
@echo "Local commit: $(LOCAL_COMMIT)"
@VERSION_URL="$(VERSION_URL)" python3 scripts/version_check.py
bump-version:
@python3 scripts/bump_version.py $(BUMP_ARGS)
ensure-version-bumped:
@git diff --cached --quiet VERSION && { echo "\n[ensure-version-bumped] VERSION is not staged. Run 'git add VERSION' after bumping."; exit 1; } || echo "[ensure-version-bumped] VERSION bump detected in staged changes."
clean:
cargo clean
rm -rf $(PKG_DIR) $(STATIC_PKG)