| #!/usr/bin/env bash |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| set -euo pipefail |
|
|
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| cd "$SCRIPT_DIR" |
|
|
| PLUGINS=(bex-gogoanime bex-kaianime bex-hianime bex-imdb bex-kisskh) |
| WASI_ADAPTER="" |
|
|
| |
| for dir in ~/.cargo/registry/src/index.crates.io-*/wasi-preview1-component-adapter-provider-*/artefacts/; do |
| if [ -f "${dir}wasi_snapshot_preview1.reactor.wasm" ]; then |
| WASI_ADAPTER="${dir}wasi_snapshot_preview1.reactor.wasm" |
| break |
| fi |
| done |
|
|
| if [ -z "$WASI_ADAPTER" ]; then |
| echo "ERROR: WASI adapter not found. Run 'cargo build -p bex-gogoanime --target wasm32-wasip1' first to download it." |
| exit 1 |
| fi |
|
|
| echo "=== Building WASM plugins ===" |
| cargo build --target wasm32-wasip1 --release ${PLUGINS[*]/#/-p } |
|
|
| echo "" |
| echo "=== Converting to components ===" |
| mkdir -p target/components |
|
|
| for plugin in "${PLUGINS[@]}"; do |
| |
| wasm_name="${plugin/-/_}" |
| wasm_path="target/wasm32-wasip1/release/${wasm_name}.wasm" |
| component_path="target/components/${plugin}.component.wasm" |
|
|
| if [ ! -f "$wasm_path" ]; then |
| echo " SKIP: $plugin (WASM not found)" |
| continue |
| fi |
|
|
| echo " Converting: $plugin" |
| wasm-tools component new "$wasm_path" -o "$component_path" --adapt "$WASI_ADAPTER" |
| done |
|
|
| echo "" |
| echo "=== Packing .bex packages ===" |
| mkdir -p dist |
|
|
| for plugin in "${PLUGINS[@]}"; do |
| component_path="target/components/${plugin}.component.wasm" |
| manifest_path="dist/${plugin}.yaml" |
| output_path="dist/${plugin}.bex" |
|
|
| if [ ! -f "$component_path" ]; then |
| echo " SKIP: $plugin (component not found)" |
| continue |
| fi |
|
|
| if [ ! -f "$manifest_path" ]; then |
| echo " SKIP: $plugin (manifest not found at $manifest_path)" |
| continue |
| fi |
|
|
| echo " Packing: $plugin" |
| ./target/release/bex pack "$manifest_path" "$component_path" "$output_path" |
| done |
|
|
| echo "" |
| echo "=== Done! ===" |
| echo "Packages in dist/:" |
| ls -la dist/*.bex 2>/dev/null || echo " (no .bex files)" |
|
|