Make audio/image dependencies optional through feature flags

This commit is contained in:
caelunshun 2020-08-11 00:30:42 -06:00
parent 5e76a018c9
commit a694d9a1b6
No known key found for this signature in database
GPG key ID: EC60409E5A0D4ECC
4 changed files with 25 additions and 5 deletions

View file

@ -13,9 +13,19 @@ readme = "README.md"
exclude = ["assets/**/*", "tools/**/*", ".github/**/*", "crates/**/*"] exclude = ["assets/**/*", "tools/**/*", ".github/**/*", "crates/**/*"]
[features] [features]
default = ["bevy_audio", "bevy_gltf", "bevy_wgpu", "bevy_winit"] default = ["bevy_audio", "bevy_gltf", "bevy_wgpu", "bevy_winit", "png", "hdr", "mp3"]
profiler = ["bevy_ecs/profiler", "bevy_diagnostic/profiler"] profiler = ["bevy_ecs/profiler", "bevy_diagnostic/profiler"]
# Image format support for texture loading (PNG and HDR are enabled by default)
png = ["bevy_render/png"]
hdr = ["bevy_render/hdr"]
# Audio format support (MP3 is enabled by default)
mp3 = ["bevy_audio/mp3"]
flac = ["bevy_audio/flac"]
wav = ["bevy_audio/wav"]
vorbis = ["bevy_audio/vorbis"]
[workspace] [workspace]
members = [ members = [
"crates/*", "crates/*",

View file

@ -17,4 +17,10 @@ bevy_ecs = {path = "../bevy_ecs", version = "0.1"}
# other # other
anyhow = "1.0" anyhow = "1.0"
rodio = {version = "0.11", default-features = false, features = ["mp3"]} rodio = {version = "0.11", default-features = false}
[features]
mp3 = ["rodio/mp3"]
flac = ["rodio/flac"]
wav = ["rodio/wav"]
vorbis = ["rodio/vorbis"]

View file

@ -26,7 +26,7 @@ impl AssetLoader<AudioSource> for Mp3Loader {
} }
fn extensions(&self) -> &[&str] { fn extensions(&self) -> &[&str] {
static EXTENSIONS: &[&str] = &["mp3"]; static EXTENSIONS: &[&str] = &["mp3", "flac", "wav", "ogg"];
EXTENSIONS EXTENSIONS
} }
} }

View file

@ -25,7 +25,7 @@ bevy_window = { path = "../bevy_window", version = "0.1" }
# rendering # rendering
spirv-reflect = "0.2.3" spirv-reflect = "0.2.3"
bevy-glsl-to-spirv = "0.1.7" bevy-glsl-to-spirv = "0.1.7"
image = { version = "0.23", default-features = false, features = ["png", "hdr"] } image = { version = "0.23", default-features = false }
# misc # misc
log = { version = "0.4", features = ["release_max_level_info"] } log = { version = "0.4", features = ["release_max_level_info"] }
@ -37,4 +37,8 @@ smallvec = "1.4.0"
once_cell = "1.4.0" once_cell = "1.4.0"
downcast-rs = "1.1.1" downcast-rs = "1.1.1"
thiserror = "1.0" thiserror = "1.0"
anyhow = "1.0" anyhow = "1.0"
[features]
png = ["image/png"]
hdr = ["image/hdr"]