bonsairobo / building-blocks

A voxel library for real-time applications.
MIT License
369 stars 30 forks source link

WASM support? #8

Closed schell closed 3 years ago

schell commented 3 years ago

First off - thank you for this crate!

When building for WASM I run into the following error:

error: failed to run custom build command for `lz4-sys v1.9.2`

Caused by:
  process didn't exit successfully: `/xxxxxxx/target/debug/build/lz4-sys-45650fce57a5b4fe/build-script-build` (exit code: 1)
  --- stdout
  TARGET = Some("wasm32-unknown-unknown")
  HOST = Some("x86_64-unknown-linux-gnu")
  CC_wasm32-unknown-unknown = None
  CC_wasm32_unknown_unknown = None
  TARGET_CC = None
  CC = None
  CFLAGS_wasm32-unknown-unknown = None
  CFLAGS_wasm32_unknown_unknown = None
  TARGET_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-Wall" "-Wextra" "-o" "/xxxxxx/wasm32-unknown-unknown/debug/build/lz4-sys-b5586b91058cef1c/out/liblz4/lib/lz4.o" "-c" "liblz4/lib/lz4.c"

  --- stderr

  error occurred: Failed to find tool. Is `clang` installed?

My guess is that we would have to replace the lz4-sys crate with pure Rust implementation?

schell commented 3 years ago

Or maybe there's a way to turn off the compression feature? My application doesn't need incredibly large maps, but the other features seem like a grab bag of goodies that I'd like.

bonsairobo commented 3 years ago

@indiv0 recently contributed a new compression backend called "snappy" that is WASM compatible (pure rust). You just need to specify:

[dependencies.building-blocks]
version = 0.3
no-default-features = true
features = ["snappy", $ETC]
bonsairobo commented 3 years ago

I'll should mention this in the README.