Skip to content

Commit

Permalink
update web compilation and CI
Browse files Browse the repository at this point in the history
  • Loading branch information
jmmut committed Mar 30, 2024
1 parent 12e039f commit 31fa185
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 10 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,7 @@ jobs:
- name: Compile and package WebAssembly
run: |
rustup target add wasm32-unknown-unknown
cargo build --release --target wasm32-unknown-unknown --bin bioengineer
# the folder export_html contains the html wrapper so that the wasm can be used
mkdir -p bioengineer_html
cp -r export_html/* bioengineer_html/
cp -r target/wasm32-unknown-unknown/release/*.wasm bioengineer_html/
cp -r assets/ bioengineer_html/
./recompile_web.sh
zip -FS -r wasm.zip bioengineer_html/*
sha512sum wasm.zip
Expand Down
5 changes: 1 addition & 4 deletions game/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
name = "bioengineer"
version = "0.0.0" # version comes from git at build time
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
default-run = "bioengineer"

[lib]
crate-type = ["cdylib", "lib"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = { version = "=3.2.23", features = ["derive"] }
Expand Down
17 changes: 17 additions & 0 deletions local_build_and_run_web.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# Before running this script, you'll need to:
# - add the WebAssembly target in the rust compiler:
# rustup target add wasm32-unknown-unknown
# - install wasm-pack to use wasm-bindgen
# cargo install wasm-pack
# - install the local web server:
# cargo install basic-http-server
# see the readme.md for more info

./recompile_web.sh

# you can also do `basic-http-server export_html/` for faster iteration time if you are
# just changing the html/js, but you will need to copy the built_html/pkg to export_html for the
# webassembly artifact to work
basic-http-server bioengineer_html/
16 changes: 16 additions & 0 deletions recompile_web.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -euo pipefail

# Don't run this manually, run local_build_and_run.sh instead to run the project locally.
# This script exists just to make sure the CI and the local building does the same.

# for this script to work, you need to do `rustup target add wasm32-unknown-unknown`

cargo build --release --target wasm32-unknown-unknown --bin bioengineer
mkdir -p bioengineer_html
# the folder export_html contains the html wrapper so that the wasm can be used
cp -r export_html/* bioengineer_html/
cp -r target/wasm32-unknown-unknown/release/*.wasm bioengineer_html/
cp -r assets/ bioengineer_html/

0 comments on commit 31fa185

Please sign in to comment.