Skip to content

Commit

Permalink
can disable file system watching from bevy_asset
Browse files Browse the repository at this point in the history
  • Loading branch information
mockersf committed Nov 10, 2021
1 parent c402551 commit 1ab4e52
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 16 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ default = [
"hdr",
"mp3",
"x11",
"filesystem_watcher"
]

# Force dynamic linking, which improves iterative compile times
Expand Down Expand Up @@ -68,6 +69,9 @@ mp3 = ["bevy_internal/mp3"]
vorbis = ["bevy_internal/vorbis"]
wav = ["bevy_internal/wav"]

# Enable watching file system for asset hot reload
filesystem_watcher = ["bevy_internal/filesystem_watcher"]

# WASM support for audio (Currently only works with flac, wav and vorbis. Not with mp3)
wasm_audio = ["bevy_internal/wasm_audio"]

Expand Down
19 changes: 14 additions & 5 deletions crates/bevy_asset/src/io/file_asset_io.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
use crate::{filesystem_watcher::FilesystemWatcher, AssetIo, AssetIoError, AssetServer};
#[cfg(feature = "filesystem_watcher")]
use crate::{filesystem_watcher::FilesystemWatcher, AssetServer};
use crate::{AssetIo, AssetIoError};
use anyhow::Result;
#[cfg(feature = "filesystem_watcher")]
use bevy_ecs::system::Res;
use bevy_utils::{BoxedFuture, HashSet};
use bevy_utils::BoxedFuture;
#[cfg(feature = "filesystem_watcher")]
use bevy_utils::HashSet;
#[cfg(feature = "filesystem_watcher")]
use crossbeam_channel::TryRecvError;
use fs::File;
use io::Read;
#[cfg(feature = "filesystem_watcher")]
use parking_lot::RwLock;
#[cfg(feature = "filesystem_watcher")]
use std::sync::Arc;
use std::{
env, fs, io,
env, fs,
io::Read,
path::{Path, PathBuf},
sync::Arc,
};

pub struct FileAssetIo {
Expand All @@ -21,6 +29,7 @@ pub struct FileAssetIo {
impl FileAssetIo {
pub fn new<P: AsRef<Path>>(path: P) -> Self {
FileAssetIo {
#[cfg(feature = "filesystem_watcher")]
filesystem_watcher: Default::default(),
root_path: Self::get_root_path().join(path.as_ref()),
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_audio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ keywords = ["bevy"]
[dependencies]
# bevy
bevy_app = { path = "../bevy_app", version = "0.5.0" }
bevy_asset = { path = "../bevy_asset", version = "0.5.0" }
bevy_asset = { path = "../bevy_asset", version = "0.5.0", default-features = false }
bevy_ecs = { path = "../bevy_ecs", version = "0.5.0" }
bevy_reflect = { path = "../bevy_reflect", version = "0.5.0", features = ["bevy"] }
bevy_utils = { path = "../bevy_utils", version = "0.5.0" }
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ keywords = ["bevy"]

[dependencies]
# bevy
bevy_app = { path = "../bevy_app", version = "0.5.0" }
bevy_app = { path = "../bevy_app", version = "0.5.0", features = ["bevy_reflect"] }
bevy_derive = { path = "../bevy_derive", version = "0.5.0" }
bevy_ecs = { path = "../bevy_ecs", version = "0.5.0", features = ["bevy_reflect"] }
bevy_math = { path = "../bevy_math", version = "0.5.0" }
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_gltf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ keywords = ["bevy"]
[dependencies]
# bevy
bevy_app = { path = "../bevy_app", version = "0.5.0" }
bevy_asset = { path = "../bevy_asset", version = "0.5.0" }
bevy_asset = { path = "../bevy_asset", version = "0.5.0", default-features = false }
bevy_core = { path = "../bevy_core", version = "0.5.0" }
bevy_ecs = { path = "../bevy_ecs", version = "0.5.0" }
bevy_pbr = { path = "../bevy_pbr", version = "0.5.0" }
Expand Down
5 changes: 4 additions & 1 deletion crates/bevy_internal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ wav = ["bevy_audio/wav"]
# WASM support for audio
wasm_audio = ["bevy_audio/wasm_audio"]

# Enable watching file system for asset hot reload
filesystem_watcher = ["bevy_asset/filesystem_watcher"]

serialize = ["bevy_input/serialize"]

# Display server protocol support (X11 is enabled by default)
Expand All @@ -47,7 +50,7 @@ bevy_ci_testing = ["bevy_app/bevy_ci_testing"]
[dependencies]
# bevy
bevy_app = { path = "../bevy_app", version = "0.5.0" }
bevy_asset = { path = "../bevy_asset", version = "0.5.0" }
bevy_asset = { path = "../bevy_asset", version = "0.5.0", default-features = false }
bevy_core = { path = "../bevy_core", version = "0.5.0" }
bevy_derive = { path = "../bevy_derive", version = "0.5.0" }
bevy_diagnostic = { path = "../bevy_diagnostic", version = "0.5.0" }
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_pbr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ keywords = ["bevy"]
[dependencies]
# bevy
bevy_app = { path = "../bevy_app", version = "0.5.0" }
bevy_asset = { path = "../bevy_asset", version = "0.5.0" }
bevy_asset = { path = "../bevy_asset", version = "0.5.0", default-features = false }
bevy_core = { path = "../bevy_core", version = "0.5.0" }
bevy_ecs = { path = "../bevy_ecs", version = "0.5.0" }
bevy_math = { path = "../bevy_math", version = "0.5.0" }
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_render/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ keywords = ["bevy"]
[dependencies]
# bevy
bevy_app = { path = "../bevy_app", version = "0.5.0" }
bevy_asset = { path = "../bevy_asset", version = "0.5.0" }
bevy_asset = { path = "../bevy_asset", version = "0.5.0", default-features = false }
bevy_core = { path = "../bevy_core", version = "0.5.0" }
bevy_derive = { path = "../bevy_derive", version = "0.5.0" }
bevy_ecs = { path = "../bevy_ecs", version = "0.5.0" }
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_scene/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ keywords = ["bevy"]
[dependencies]
# bevy
bevy_app = { path = "../bevy_app", version = "0.5.0" }
bevy_asset = { path = "../bevy_asset", version = "0.5.0" }
bevy_asset = { path = "../bevy_asset", version = "0.5.0", default-features = false }
bevy_ecs = { path = "../bevy_ecs", version = "0.5.0" }
bevy_reflect = { path = "../bevy_reflect", version = "0.5.0", features = ["bevy"] }
bevy_transform = { path = "../bevy_transform", version = "0.5.0" }
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_sprite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ keywords = ["bevy"]
[dependencies]
# bevy
bevy_app = { path = "../bevy_app", version = "0.5.0" }
bevy_asset = { path = "../bevy_asset", version = "0.5.0" }
bevy_asset = { path = "../bevy_asset", version = "0.5.0", default-features = false }
bevy_core = { path = "../bevy_core", version = "0.5.0" }
bevy_ecs = { path = "../bevy_ecs", version = "0.5.0" }
bevy_log = { path = "../bevy_log", version = "0.5.0" }
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_text/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ subpixel_glyph_atlas = []
[dependencies]
# bevy
bevy_app = { path = "../bevy_app", version = "0.5.0" }
bevy_asset = { path = "../bevy_asset", version = "0.5.0" }
bevy_asset = { path = "../bevy_asset", version = "0.5.0", default-features = false }
bevy_core = { path = "../bevy_core", version = "0.5.0" }
bevy_ecs = { path = "../bevy_ecs", version = "0.5.0" }
bevy_math = { path = "../bevy_math", version = "0.5.0" }
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ keywords = ["bevy"]
[dependencies]
# bevy
bevy_app = { path = "../bevy_app", version = "0.5.0" }
bevy_asset = { path = "../bevy_asset", version = "0.5.0" }
bevy_asset = { path = "../bevy_asset", version = "0.5.0", default-features = false }
bevy_core = { path = "../bevy_core", version = "0.5.0" }
bevy_ecs = { path = "../bevy_ecs", version = "0.5.0" }
bevy_input = { path = "../bevy_input", version = "0.5.0" }
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_wgpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ trace = ["wgpu/trace"]
[dependencies]
# bevy
bevy_app = { path = "../bevy_app", version = "0.5.0" }
bevy_asset = { path = "../bevy_asset", version = "0.5.0" }
bevy_asset = { path = "../bevy_asset", version = "0.5.0", default-features = false }
bevy_core = { path = "../bevy_core", version = "0.5.0" }
bevy_diagnostic = { path = "../bevy_diagnostic", version = "0.5.0" }
bevy_ecs = { path = "../bevy_ecs", version = "0.5.0" }
Expand Down
1 change: 1 addition & 0 deletions docs/cargo_features.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
|hdr|[HDR](https://en.wikipedia.org/wiki/High_dynamic_range) support.|
|mp3|MP3 audio format support.|
|x11|Make GUI applications use X11 protocol. You could enable wayland feature to override this.|
|filesystem_watcher|Enable watching the file system for asset hot reload|

## Optional Features

Expand Down

0 comments on commit 1ab4e52

Please sign in to comment.