From 5466a1137a9a4b27a99b83c45c0b337775bacf7c Mon Sep 17 00:00:00 2001 From: Bernie Innocenti Date: Sun, 2 Jul 2017 11:16:26 -0400 Subject: [PATCH] Add rust-rocket optional dependency. --- .gitmodules | 3 +++ Cargo.toml | 13 +++++++++---- README.md | 2 +- lib.rs | 7 +++++++ release_wasm.sh | 2 +- rust-rocket | 1 + 6 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 .gitmodules create mode 160000 rust-rocket diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..60c990d --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "rust-rocket"] + path = rust-rocket + url = https://github.com/Darksecond/rust-rocket diff --git a/Cargo.toml b/Cargo.toml index 4e927c4..ae262eb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,15 +13,20 @@ cgmath = "*" glium = "0.16.0" glutin = "0.7.4" genmesh = "0.4.1" -image = { version = "0.14.0", features = ["png_codec"] } +image = { version = "0.14.0", features = ["png_codec"], optional = true } libxm = "1.0.0" obj = { version = "0.5", features = ["usegenmesh"] } +rust-rocket = { path = "rust-rocket", optional = true } rand = "*" sdl2 = "*" -#[replace] -#"glutin:0.7.4" = { path = "/home/bernie/src/glutin" } -#"glium:0.16.0" = { path = "/home/bernie/src/glium" } +[features] +default = ["rust-rocket", "image"] +min = [] + +[replace] +"glutin:0.7.4" = { path = "/home/bernie/src/glutin" } +"glium:0.16.0" = { path = "/home/bernie/src/glium" } [target.armv7-linux-androideabi] ar = "$ANDROID_NDK_HOME/arm/bin/arm-linux-androideabi-ar" diff --git a/README.md b/README.md index 5754000..9be1a31 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ I followed these steps to build a native Windows binary: ### WebAssembly / asm.js -Install emsdk 1.36.14: +Install emsdk: ``` cd ~ diff --git a/lib.rs b/lib.rs index c702671..eba89b1 100644 --- a/lib.rs +++ b/lib.rs @@ -2,8 +2,11 @@ extern crate cgmath; #[macro_use(uniform,program,implement_vertex)] extern crate glium; extern crate glutin; +#[cfg(feature = "image")] extern crate image; extern crate libxm; +#[cfg(feature = "rust_rocket")] +extern crate rust_rocket; extern crate sdl2; pub mod bounding_box; @@ -18,6 +21,7 @@ pub use bounding_box::BoundingBox; pub use cube::Cube; pub use shaded_cube::ShadedCube; +#[cfg(feature = "image")] pub fn screenshot(display : &glium::Display) { let image: glium::texture::RawImage2d = display.read_front_buffer(); let image = image::ImageBuffer::from_raw(image.width, image.height, image.data.into_owned()).unwrap(); @@ -26,3 +30,6 @@ pub fn screenshot(display : &glium::Display) { image.save(&mut output, image::ImageFormat::PNG).unwrap(); } +#[cfg(not(feature = "image"))] +pub fn screenshot(display : &glium::Display) { +} diff --git a/release_wasm.sh b/release_wasm.sh index fc6d926..bdabb1c 100755 --- a/release_wasm.sh +++ b/release_wasm.sh @@ -1,5 +1,5 @@ set -e -cargo rustc --target wasm32-unknown-emscripten --release -- -C link-args='-s USE_SDL=2 --preload-file flora.xm' +cargo rustc --target wasm32-unknown-emscripten --release --bin mandelwow -- -C link-args='-s USE_SDL=2 --preload-file flora.xm' cp -a target/wasm32-unknown-emscripten/release/mandelwow.js . cp -a target/wasm32-unknown-emscripten/release/deps/mandelwow-*.{wasm,data} . emrun . diff --git a/rust-rocket b/rust-rocket new file mode 160000 index 0000000..3ca2cab --- /dev/null +++ b/rust-rocket @@ -0,0 +1 @@ +Subproject commit 3ca2caba4878c73bfa4d2d7a36c2f3b943f9888a -- 2.25.1