Latest Posts

Topic: Soldier auto-fighter in webassembly

kaputtnik
Avatar
Joined: 2013-02-18, 20:48
Posts: 2533
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2021-12-27, 11:38

I've tried to run the app locally, but i can't get it to work. After installing this and that and always running into problems, searching the web for a solution the (probably) last error says:

$:> ~/.cargo/bin/wasm-pack build
Error: crate-type must be cdylib to compile to wasm32-unknown-unknown. Add the following to your Cargo.toml file:

[lib]
crate-type = ["cdylib", "rlib"]

but adding those lines to Cargo.toml gives just another error:

$:> ~/.cargo/bin/wasm-pack build --target web
Error: Error during execution of `cargo metadata`: error: failed to parse manifest at `/home/kaputtnik/Quellcode/wide-fighter-master/Cargo.toml`

Caused by:
  can't find library `wide-fighter`, rename file to `src/lib.rs` or specify lib.path

Can you please provide a "How to contribute" chapter in the readme with a short description how to install rust, or rustup, and the other prerequisites to run the app locally? ​

Just to mention: I am on archlinux which provide a package for rustup

Maybe i find some time to add some css…


Top Quote
leklachu
Avatar
Topic Opener
Joined: 2021-12-08, 20:21
Posts: 8
Ranking
Pry about Widelands
Posted at: 2021-12-27, 12:16

I build it with trunk: https://trunkrs.dev/

install with cargo install --locked trunk

run with trunk serve

build for release with trunk build --release

I'll see about instructions to build and contribute in the README, thanks face-smile.png


Top Quote
leklachu
Avatar
Topic Opener
Joined: 2021-12-08, 20:21
Posts: 8
Ranking
Pry about Widelands
Posted at: 2021-12-27, 12:23

OTOH you need

  • rust toolchain (courtesy of rustup)
  • target wasm32-unknown-unknown
  • trunk
  • the source

and trunk build / trunk serve should get the rest.

Edited: 2021-12-27, 12:24

Top Quote
kaputtnik
Avatar
Joined: 2013-02-18, 20:48
Posts: 2533
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2021-12-27, 16:40

Thanks face-smile.png will try that...


Top Quote
kaputtnik
Avatar
Joined: 2013-02-18, 20:48
Posts: 2533
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2021-12-27, 17:19

That worked for me with this differences, maybe archlinux specific:

  1. install the package rustup sudo pacman -S rustup
  2. run rustup install stable, this will install cargo and some other things
  3. run rustup target add wasm32-unknown-unknown
  4. run cargo install --locked trunk. This last a while and compiles trunk (beside many other things). trunk is then be available at ~/.cargo/bin/trunk
  5. get the code: git clone https://github.com/leklachu/wide-fighter.git
  6. run ~/.cargo/bin/trunk build
  7. run ~/.cargo/bin/trunk serve

After that the website is available at localhost:8080


Top Quote