From 423c5e3e0fb1a8c3d459a15e3baba4550d41743f Mon Sep 17 00:00:00 2001 From: Carter Anderson Date: Sun, 9 Aug 2020 17:58:56 -0700 Subject: [PATCH] ecs: prepare for publishing --- crates/bevy_app/src/app.rs | 3 +- crates/bevy_ecs/Cargo.toml | 2 +- crates/bevy_ecs/hecs/Cargo.toml | 15 +++++---- crates/bevy_ecs/hecs/benches/bench.rs | 2 +- crates/bevy_ecs/hecs/examples/format.rs | 8 ++--- crates/bevy_ecs/hecs/macros/Cargo.toml | 8 ++--- crates/bevy_ecs/hecs/macros/src/lib.rs | 2 +- crates/bevy_ecs/hecs/src/entity_builder.rs | 2 +- crates/bevy_ecs/hecs/src/lib.rs | 4 +-- crates/bevy_ecs/hecs/src/query.rs | 8 ++--- crates/bevy_ecs/hecs/src/world.rs | 16 ++++----- crates/bevy_ecs/hecs/tests/tests.rs | 2 +- crates/bevy_ecs/src/lib.rs | 2 +- .../bevy_ecs/src/resource/resource_query.rs | 2 +- crates/bevy_ecs/src/resource/resources.rs | 2 +- .../src/schedule/parallel_executor.rs | 4 +-- crates/bevy_ecs/src/schedule/schedule.rs | 2 +- crates/bevy_ecs/src/system/commands.rs | 4 +-- crates/bevy_ecs/src/system/into_system.rs | 4 +-- crates/bevy_ecs/src/system/query.rs | 2 +- crates/bevy_ecs/src/system/system.rs | 4 +-- crates/bevy_ecs/src/world/world_builder.rs | 2 +- .../bevy_property_derive/src/lib.rs | 1 - tools/publish.sh | 33 +++++++++++++++++++ 24 files changed, 85 insertions(+), 49 deletions(-) create mode 100644 tools/publish.sh diff --git a/crates/bevy_app/src/app.rs b/crates/bevy_app/src/app.rs index f20cb4fdff..cff6dcb93b 100644 --- a/crates/bevy_app/src/app.rs +++ b/crates/bevy_app/src/app.rs @@ -9,7 +9,8 @@ use bevy_ecs::{ParallelExecutor, Resources, Schedule, World}; /// ## Example /// Here is a simple "Hello World" Bevy app: /// ``` -///use bevy::prelude::*; +///use bevy_app::prelude::*; +///use bevy_ecs::prelude::*; /// ///fn main() { /// App::build() diff --git a/crates/bevy_ecs/Cargo.toml b/crates/bevy_ecs/Cargo.toml index c202cb940e..7222f282c6 100644 --- a/crates/bevy_ecs/Cargo.toml +++ b/crates/bevy_ecs/Cargo.toml @@ -14,7 +14,7 @@ categories = ["game-engines", "data-structures"] profiler = [] [dependencies] -hecs = { path = "hecs", features = ["macros", "serialize"] } +bevy_hecs = { path = "hecs", features = ["macros", "serialize"], version = "0.1" } rand = "0.7.2" rayon = "1.3" crossbeam-channel = "0.4.2" diff --git a/crates/bevy_ecs/hecs/Cargo.toml b/crates/bevy_ecs/hecs/Cargo.toml index 8602c6fb47..2fa311cb28 100644 --- a/crates/bevy_ecs/hecs/Cargo.toml +++ b/crates/bevy_ecs/hecs/Cargo.toml @@ -1,8 +1,11 @@ [package] -name = "hecs" -version = "0.2.12" -description = "A fast, minimal, and ergonomic entity-component-system" -authors = ["Benjamin Saunders "] +name = "bevy_hecs" +version = "0.1.0" +description = "Bevy fork of hecs: a fast, minimal, and ergonomic entity-component-system" +authors = [ + "Benjamin Saunders ", + "Bevy Contributors ", + "Carter Anderson "] edition = "2018" license = "Apache-2.0" repository = "https://github.com/Ralith/hecs" @@ -20,11 +23,11 @@ maintenance = { status = "actively-developed" } default = ["std"] std = [] # Enables derive(Bundle) -macros = ["hecs-macros", "lazy_static"] +macros = ["bevy_hecs_macros", "lazy_static"] serialize = ["serde"] [dependencies] -hecs-macros = { path = "macros", version = "0.3.0", optional = true } +bevy_hecs_macros = { path = "macros", version = "0.1.0", optional = true } hashbrown = { version = "0.8.0", default-features = false, features = ["ahash", "inline-more"] } lazy_static = { version = "1.4.0", optional = true, features = ["spin_no_std"] } serde = { version = "1", features = ["derive"], optional = true} diff --git a/crates/bevy_ecs/hecs/benches/bench.rs b/crates/bevy_ecs/hecs/benches/bench.rs index 3a76340347..eb6220addd 100644 --- a/crates/bevy_ecs/hecs/benches/bench.rs +++ b/crates/bevy_ecs/hecs/benches/bench.rs @@ -15,7 +15,7 @@ // modified by Bevy contributors use bencher::{benchmark_group, benchmark_main, Bencher}; -use hecs::*; +use bevy_hecs::*; struct Position(f32); struct Velocity(f32); diff --git a/crates/bevy_ecs/hecs/examples/format.rs b/crates/bevy_ecs/hecs/examples/format.rs index d021890e9b..2dd33cbb60 100644 --- a/crates/bevy_ecs/hecs/examples/format.rs +++ b/crates/bevy_ecs/hecs/examples/format.rs @@ -3,12 +3,12 @@ //! One way to the contents of an entity, as you might do for debugging. A similar pattern could //! also be useful for serialization, or other row-oriented generic operations. -fn format_entity(entity: hecs::EntityRef<'_>) -> String { - fn fmt(entity: hecs::EntityRef<'_>) -> Option { +fn format_entity(entity: bevy_hecs::EntityRef<'_>) -> String { + fn fmt(entity: bevy_hecs::EntityRef<'_>) -> Option { Some(entity.get::()?.to_string()) } - const FUNCTIONS: &[&dyn Fn(hecs::EntityRef<'_>) -> Option] = + const FUNCTIONS: &[&dyn Fn(bevy_hecs::EntityRef<'_>) -> Option] = &[&fmt::, &fmt::, &fmt::]; let mut out = String::new(); @@ -31,7 +31,7 @@ fn format_entity(entity: hecs::EntityRef<'_>) -> String { } fn main() { - let mut world = hecs::World::new(); + let mut world = bevy_hecs::World::new(); let e = world.spawn((42, true)); println!("{}", format_entity(world.entity(e).unwrap())); } diff --git a/crates/bevy_ecs/hecs/macros/Cargo.toml b/crates/bevy_ecs/hecs/macros/Cargo.toml index bc83a44ba1..ef19cee0a0 100644 --- a/crates/bevy_ecs/hecs/macros/Cargo.toml +++ b/crates/bevy_ecs/hecs/macros/Cargo.toml @@ -1,7 +1,7 @@ [package] -name = "hecs-macros" -version = "0.3.0" -description = "Procedural macro definitions for hecs" +name = "bevy_hecs_macros" +version = "0.1.0" +description = "Bevy fork of hecs-macros: procedural macro definitions for hecs" authors = ["Benjamin Saunders "] edition = "2018" license = "Apache-2.0" @@ -10,7 +10,7 @@ license = "Apache-2.0" proc-macro = true [dependencies] -syn = { version = "1.0", default-features = false, features = ["proc-macro", "parsing", "printing", "derive"] } +syn = "1.0" quote = "1.0.3" proc-macro2 = "1.0.1" proc-macro-crate = "0.1.4" \ No newline at end of file diff --git a/crates/bevy_ecs/hecs/macros/src/lib.rs b/crates/bevy_ecs/hecs/macros/src/lib.rs index 3287b3e652..d430e01704 100644 --- a/crates/bevy_ecs/hecs/macros/src/lib.rs +++ b/crates/bevy_ecs/hecs/macros/src/lib.rs @@ -50,7 +50,7 @@ pub fn derive_bundle(input: TokenStream) -> TokenStream { } else if crate_name("bevy_ecs").is_ok() { "bevy_ecs" } else { - "hecs" + "bevy_hecs" }; let path: Path = syn::parse(path_str.parse::().unwrap()).unwrap(); diff --git a/crates/bevy_ecs/hecs/src/entity_builder.rs b/crates/bevy_ecs/hecs/src/entity_builder.rs index 165abd4d29..d9629941be 100644 --- a/crates/bevy_ecs/hecs/src/entity_builder.rs +++ b/crates/bevy_ecs/hecs/src/entity_builder.rs @@ -35,7 +35,7 @@ use crate::{archetype::TypeInfo, Component, DynamicBundle}; /// Prefer reusing the same builder over creating new ones repeatedly. /// /// ``` -/// # use hecs::*; +/// # use bevy_hecs::*; /// let mut world = World::new(); /// let mut builder = EntityBuilder::new(); /// builder.add(123).add("abc"); diff --git a/crates/bevy_ecs/hecs/src/lib.rs b/crates/bevy_ecs/hecs/src/lib.rs index 851ba45673..1a9690f725 100644 --- a/crates/bevy_ecs/hecs/src/lib.rs +++ b/crates/bevy_ecs/hecs/src/lib.rs @@ -27,7 +27,7 @@ //! - exclusion of externally-implementable functionality //! //! ``` -//! # use hecs::*; +//! # use bevy_hecs::*; //! let mut world = World::new(); //! // Nearly any type can be used as a component with zero boilerplate //! let a = world.spawn((123, true, "abc")); @@ -96,4 +96,4 @@ pub use lazy_static; pub use query::Fetch; #[cfg(feature = "macros")] -pub use hecs_macros::Bundle; +pub use bevy_hecs_macros::Bundle; diff --git a/crates/bevy_ecs/hecs/src/query.rs b/crates/bevy_ecs/hecs/src/query.rs index 4734928b91..14e008ec7e 100644 --- a/crates/bevy_ecs/hecs/src/query.rs +++ b/crates/bevy_ecs/hecs/src/query.rs @@ -463,7 +463,7 @@ impl<'a, T: Fetch<'a>> Fetch<'a> for TryFetch { /// /// # Example /// ``` -/// # use hecs::*; +/// # use bevy_hecs::*; /// let mut world = World::new(); /// let a = world.spawn((123, true, "abc")); /// let b = world.spawn((456, false)); @@ -524,7 +524,7 @@ impl<'a, T: Component, F: Fetch<'a>> Fetch<'a> for FetchWithout { /// /// # Example /// ``` -/// # use hecs::*; +/// # use bevy_hecs::*; /// let mut world = World::new(); /// let a = world.spawn((123, true, "abc")); /// let b = world.spawn((456, false)); @@ -648,7 +648,7 @@ impl<'w, Q: Query> QueryBorrow<'w, Q> { /// /// # Example /// ``` - /// # use hecs::*; + /// # use bevy_hecs::*; /// let mut world = World::new(); /// let a = world.spawn((123, true, "abc")); /// let b = world.spawn((456, false)); @@ -671,7 +671,7 @@ impl<'w, Q: Query> QueryBorrow<'w, Q> { /// /// # Example /// ``` - /// # use hecs::*; + /// # use bevy_hecs::*; /// let mut world = World::new(); /// let a = world.spawn((123, true, "abc")); /// let b = world.spawn((456, false)); diff --git a/crates/bevy_ecs/hecs/src/world.rs b/crates/bevy_ecs/hecs/src/world.rs index 2f69f56877..748f1e9d52 100644 --- a/crates/bevy_ecs/hecs/src/world.rs +++ b/crates/bevy_ecs/hecs/src/world.rs @@ -75,7 +75,7 @@ impl World { /// /// # Example /// ``` - /// # use hecs::*; + /// # use bevy_hecs::*; /// let mut world = World::new(); /// let a = world.spawn((123, "abc")); /// let b = world.spawn((456, true)); @@ -128,7 +128,7 @@ impl World { /// /// # Example /// ``` - /// # use hecs::*; + /// # use bevy_hecs::*; /// let mut world = World::new(); /// let entities = world.spawn_batch((0..1_000).map(|i| (i, "abc"))).collect::>(); /// for i in 0..1_000 { @@ -241,7 +241,7 @@ impl World { /// /// # Example /// ``` - /// # use hecs::*; + /// # use bevy_hecs::*; /// let mut world = World::new(); /// let a = world.spawn((123, true, "abc")); /// let b = world.spawn((456, false)); @@ -268,7 +268,7 @@ impl World { /// /// # Example /// ``` - /// # use hecs::*; + /// # use bevy_hecs::*; /// let mut world = World::new(); /// let a = world.spawn((123, true, "abc")); /// // The returned query must outlive the borrow made by `get` @@ -322,7 +322,7 @@ impl World { /// /// # Example /// ``` - /// # use hecs::*; + /// # use bevy_hecs::*; /// let mut world = World::new(); /// let a = world.spawn(()); /// let b = world.spawn(()); @@ -351,7 +351,7 @@ impl World { /// /// # Example /// ``` - /// # use hecs::*; + /// # use bevy_hecs::*; /// let mut world = World::new(); /// let e = world.spawn((123, "abc")); /// world.insert(e, (456, true)); @@ -452,7 +452,7 @@ impl World { /// /// # Example /// ``` - /// # use hecs::*; + /// # use bevy_hecs::*; /// let mut world = World::new(); /// let e = world.spawn((123, "abc", true)); /// assert_eq!(world.remove::<(i32, &str)>(e), Ok((123, "abc"))); @@ -586,7 +586,7 @@ impl World { /// /// # Example /// ``` - /// # use hecs::*; + /// # use bevy_hecs::*; /// let mut world = World::new(); /// let initial_gen = world.archetypes_generation(); /// world.spawn((123, "abc")); diff --git a/crates/bevy_ecs/hecs/tests/tests.rs b/crates/bevy_ecs/hecs/tests/tests.rs index bed908a70b..b5f5b30aa0 100644 --- a/crates/bevy_ecs/hecs/tests/tests.rs +++ b/crates/bevy_ecs/hecs/tests/tests.rs @@ -14,7 +14,7 @@ // modified by Bevy contributors -use hecs::*; +use bevy_hecs::*; #[test] fn random_access() { diff --git a/crates/bevy_ecs/src/lib.rs b/crates/bevy_ecs/src/lib.rs index 171fe1ae1c..9a5982ee40 100644 --- a/crates/bevy_ecs/src/lib.rs +++ b/crates/bevy_ecs/src/lib.rs @@ -1,4 +1,4 @@ -pub use hecs::{Query as HecsQuery, *}; +pub use bevy_hecs::{Query as HecsQuery, *}; mod resource; mod schedule; mod system; diff --git a/crates/bevy_ecs/src/resource/resource_query.rs b/crates/bevy_ecs/src/resource/resource_query.rs index 5e686aef1e..0a48022d14 100644 --- a/crates/bevy_ecs/src/resource/resource_query.rs +++ b/crates/bevy_ecs/src/resource/resource_query.rs @@ -8,7 +8,7 @@ use core::{ ops::{Deref, DerefMut}, ptr::NonNull, }; -use hecs::smaller_tuples_too; +use bevy_hecs::smaller_tuples_too; use std::marker::PhantomData; /// Shared borrow of a Resource diff --git a/crates/bevy_ecs/src/resource/resources.rs b/crates/bevy_ecs/src/resource/resources.rs index bc7eb0c016..8495e9c58c 100644 --- a/crates/bevy_ecs/src/resource/resources.rs +++ b/crates/bevy_ecs/src/resource/resources.rs @@ -1,7 +1,7 @@ use super::{FetchResource, ResourceQuery}; use crate::system::SystemId; use core::any::TypeId; -use hecs::{Archetype, Ref, RefMut, TypeInfo}; +use bevy_hecs::{Archetype, Ref, RefMut, TypeInfo}; use std::{collections::HashMap, ptr::NonNull}; /// A Resource type diff --git a/crates/bevy_ecs/src/schedule/parallel_executor.rs b/crates/bevy_ecs/src/schedule/parallel_executor.rs index b410f6f16d..0208d739a3 100644 --- a/crates/bevy_ecs/src/schedule/parallel_executor.rs +++ b/crates/bevy_ecs/src/schedule/parallel_executor.rs @@ -5,7 +5,7 @@ use crate::{ }; use crossbeam_channel::{Receiver, Sender}; use fixedbitset::FixedBitSet; -use hecs::{ArchetypesGeneration, World}; +use bevy_hecs::{ArchetypesGeneration, World}; use rayon::ScopeFifo; use std::{ ops::Range, @@ -396,7 +396,7 @@ mod tests { Commands, }; use fixedbitset::FixedBitSet; - use hecs::{Entity, World}; + use bevy_hecs::{Entity, World}; use std::sync::{Arc, Mutex}; #[derive(Default)] diff --git a/crates/bevy_ecs/src/schedule/schedule.rs b/crates/bevy_ecs/src/schedule/schedule.rs index 907b23a3c7..41e658af57 100644 --- a/crates/bevy_ecs/src/schedule/schedule.rs +++ b/crates/bevy_ecs/src/schedule/schedule.rs @@ -2,7 +2,7 @@ use crate::{ resource::Resources, system::{System, SystemId, ThreadLocalExecution}, }; -use hecs::World; +use bevy_hecs::World; use std::{ borrow::Cow, collections::{HashMap, HashSet}, diff --git a/crates/bevy_ecs/src/system/commands.rs b/crates/bevy_ecs/src/system/commands.rs index 6b3995cc0d..9086f83aa7 100644 --- a/crates/bevy_ecs/src/system/commands.rs +++ b/crates/bevy_ecs/src/system/commands.rs @@ -1,6 +1,6 @@ use super::SystemId; use crate::resource::{Resource, Resources}; -use hecs::{Bundle, Component, DynamicBundle, Entity, World}; +use bevy_hecs::{Bundle, Component, DynamicBundle, Entity, World}; use std::sync::{Arc, Mutex}; /// A queued command to mutate the current [World] or [Resources] @@ -327,7 +327,7 @@ impl Commands { mod tests { use super::Commands; use crate::resource::Resources; - use hecs::World; + use bevy_hecs::World; #[test] fn command_buffer() { diff --git a/crates/bevy_ecs/src/system/into_system.rs b/crates/bevy_ecs/src/system/into_system.rs index 28e0e7b8bd..96a4cff449 100644 --- a/crates/bevy_ecs/src/system/into_system.rs +++ b/crates/bevy_ecs/src/system/into_system.rs @@ -4,7 +4,7 @@ use crate::{ resource::{FetchResource, ResourceQuery, Resources, UnsafeClone}, system::{ArchetypeAccess, Commands, System, SystemId, ThreadLocalExecution}, }; -use hecs::{Fetch, Query as HecsQuery, World}; +use bevy_hecs::{Fetch, Query as HecsQuery, World}; use std::borrow::Cow; pub(crate) struct SystemFn @@ -347,7 +347,7 @@ mod tests { resource::{ResMut, Resources}, schedule::Schedule, }; - use hecs::{Entity, With, World}; + use bevy_hecs::{Entity, With, World}; struct A; struct B; diff --git a/crates/bevy_ecs/src/system/query.rs b/crates/bevy_ecs/src/system/query.rs index 776c81c82c..95e4e06c35 100644 --- a/crates/bevy_ecs/src/system/query.rs +++ b/crates/bevy_ecs/src/system/query.rs @@ -1,5 +1,5 @@ use crate::ArchetypeAccess; -use hecs::{ +use bevy_hecs::{ Archetype, Component, ComponentError, Entity, Fetch, Query as HecsQuery, QueryOne, Ref, RefMut, World, }; diff --git a/crates/bevy_ecs/src/system/system.rs b/crates/bevy_ecs/src/system/system.rs index 31a022a2d0..c19bbf0959 100644 --- a/crates/bevy_ecs/src/system/system.rs +++ b/crates/bevy_ecs/src/system/system.rs @@ -1,6 +1,6 @@ use crate::resource::Resources; use fixedbitset::FixedBitSet; -use hecs::{Access, Query, World}; +use bevy_hecs::{Access, Query, World}; use std::{any::TypeId, borrow::Cow, collections::HashSet}; /// Determines the strategy used to run the `run_thread_local` function in a [System] @@ -105,7 +105,7 @@ impl TypeAccess { mod tests { use super::{ArchetypeAccess, TypeAccess}; use crate::resource::{FetchResource, Res, ResMut, ResourceQuery}; - use hecs::World; + use bevy_hecs::World; use std::any::TypeId; struct A; diff --git a/crates/bevy_ecs/src/world/world_builder.rs b/crates/bevy_ecs/src/world/world_builder.rs index 31712844af..d0f67fdd85 100644 --- a/crates/bevy_ecs/src/world/world_builder.rs +++ b/crates/bevy_ecs/src/world/world_builder.rs @@ -1,4 +1,4 @@ -use hecs::{Bundle, Component, DynamicBundle, Entity, World}; +use bevy_hecs::{Bundle, Component, DynamicBundle, Entity, World}; /// Converts a reference to `Self` to a [WorldBuilder] pub trait WorldBuilderSource { diff --git a/crates/bevy_property/bevy_property_derive/src/lib.rs b/crates/bevy_property/bevy_property_derive/src/lib.rs index 567811040b..aa2691e973 100644 --- a/crates/bevy_property/bevy_property_derive/src/lib.rs +++ b/crates/bevy_property/bevy_property_derive/src/lib.rs @@ -299,7 +299,6 @@ pub fn derive_property(input: TokenStream) -> TokenStream { }) } -#[derive(Debug)] struct PropertyDef { type_name: Ident, generics: Generics, diff --git a/tools/publish.sh b/tools/publish.sh new file mode 100644 index 0000000000..99dd6df2e6 --- /dev/null +++ b/tools/publish.sh @@ -0,0 +1,33 @@ +crates=( + bevy_app + bevy_asset + bevy_audio + bevy_core + bevy_derive + bevy_diagnostic + bevy_ecs + bevy_ecs/hecs + bevy_ecs/hecs/macros + bevy_gltf + bevy_input + bevy_math + bevy_pbr + bevy_property + bevy_render + bevy_scene + bevy_sprite + bevy_text + bevy_transform + bevy_type_registry + bevy_ui + bevy_wgpu + bevy_window + bevy_winit +) + +cd crates +for crate in "${crates[@]}" +do + echo "Publishing ${crate}" + (cd $crate; cargo build) +done \ No newline at end of file