Spaces:
Sleeping
Sleeping
| set -e | |
| echo "[BUILD] Starting Distribution Build..." | |
| # 1. Clean | |
| echo "[BUILD] Cleaning dist/..." | |
| rm -rf dist | |
| mkdir -p dist/www | |
| mkdir -p dist/pkg | |
| mkdir -p dist/data | |
| # 2. Build WASM | |
| echo "[BUILD] Building WASM..." | |
| if command -v wasm-pack &> /dev/null; then | |
| # Pass --no-default-features to ensure pyo3 is excluded | |
| wasm-pack build --target web --out-dir dist/pkg --no-typescript engine_rust_src -- --no-default-features | |
| else | |
| echo "[WARN] wasm-pack not found. Attempting manual cargo build..." | |
| if cargo build --manifest-path engine_rust_src/Cargo.toml --target wasm32-unknown-unknown --release --no-default-features; then | |
| echo "[INFO] Cargo build success. Note: You need wasm-bindgen to generate valid JS glue code." | |
| echo "[INFO] Creating placeholder WASM files for structure verification." | |
| touch dist/pkg/engine_rust_bg.wasm | |
| touch dist/pkg/engine_rust.js | |
| else | |
| echo "[ERROR] Cargo build failed." | |
| # We continue to generate the structure for demonstration/debugging | |
| fi | |
| fi | |
| # 3. Build Launcher | |
| echo "[BUILD] Building Launcher..." | |
| cd launcher | |
| cargo build --release | |
| cd .. | |
| cp launcher/target/release/loveca_launcher dist/ | |
| # 4. Copy Assets | |
| echo "[BUILD] Copying Assets..." | |
| # Frontend | |
| cp -r frontend/web_ui/* dist/www/ | |
| # Data | |
| if [ -f "data/cards_compiled.json" ]; then | |
| cp data/cards_compiled.json dist/data/ | |
| else | |
| echo "[WARN] data/cards_compiled.json not found!" | |
| fi | |
| # 5. Instructions (User Facing) | |
| echo "[BUILD] Creating README..." | |
| cat > dist/README.txt <<EOF | |
| Loveca Solo - Portable Edition | |
| ============================== | |
| Welcome! This is a portable version of Loveca Solo that runs offline. | |
| HOW TO PLAY: | |
| 1. Double-click "loveca_launcher" (or "loveca_launcher.exe"). | |
| 2. The game will automatically open in your web browser. | |
| 3. Click "Start Offline (WASM)" if prompted, or wait for the game to load. | |
| NO INSTALL NEEDED: | |
| - You do NOT need Python. | |
| - You do NOT need to install anything. | |
| TROUBLESHOOTING: | |
| - If the browser does not open, check the black console window for a link (e.g., http://127.0.0.1:8000). | |
| - Keep all files in this folder together. Moving "loveca_launcher" outside this folder will break the game. | |
| Enjoy! | |
| EOF | |
| echo "[BUILD] Done! Distribution is in 'dist/' folder." | |
| ls -R dist/ | |