Create bevy_platform_support Crate#17250
Conversation
Just re-export it as is, the name is fine and this is less surprising. |
Done! |
|
Marking as blessed due to this comment by @cart. I agree with it too! |
TimJentzsch
left a comment
There was a problem hiding this comment.
I don't really understand the fallback implementation for Instant, but the rest looks good to me
Provide instructions more robust to changing version numbers. Co-Authored-By: TimJentzsch <[email protected]>
I should update the documentation to be more clear on how this works. Basically it's a straight copy of the
For the sake of convenience, I've included an |
BenjaminBrienen
left a comment
There was a problem hiding this comment.
Pretty straightforward and well done!
|
Why not just call it bevy_platform? It is already reserved on crates.io |
Co-Authored-By: TimJentzsch <[email protected]>
Co-Authored-By: Chris Russell <[email protected]>
It could be called that, but that's a pretty prime crate name that'd have a lot of uses. |
|
could you add the new crate (in the correct order by depdendency) in https://github.com/bevyengine/bevy/blob/main/tools/publish.sh? |
Co-Authored-By: François Mockers <[email protected]>
Done! |
Once this PR is merged, we should add the crate to cc @cart :) |
|
Reserved! |
# Objective - Contributes to bevyengine#16877 ## Solution - Initial creation of `bevy_platform_support` crate. - Moved `bevy_utils::Instant` into new `bevy_platform_support` crate. - Moved `portable-atomic`, `portable-atomic-util`, and `critical-section` into new `bevy_platform_support` crate. ## Testing - CI --- ## Showcase Instead of needing code like this to import an `Arc`: ```rust #[cfg(feature = "portable-atomic")] use portable_atomic_util::Arc; #[cfg(not(feature = "portable-atomic"))] use alloc::sync::Arc; ``` We can now use: ```rust use bevy_platform_support::sync::Arc; ``` This applies to many other types, but the goal is overall the same: allowing crates to use `std`-like types without the boilerplate of conditional compilation and platform-dependencies. ## Migration Guide - Replace imports of `bevy_utils::Instant` with `bevy_platform_support::time::Instant` - Replace imports of `bevy::utils::Instant` with `bevy::platform_support::time::Instant` ## Notes - `bevy_platform_support` hasn't been reserved on `crates.io` - ~~`bevy_platform_support` is not re-exported from `bevy` at this time. It may be worthwhile exporting this crate, but I am unsure of a reasonable name to export it under (`platform_support` may be a bit wordy for user-facing).~~ - I've included an implementation of `Instant` which is suitable for `no_std` platforms that are not Wasm for the sake of eliminating feature gates around its use. It may be a controversial inclusion, so I'm happy to remove it if required. - There are many other items (`spin`, `bevy_utils::Sync(Unsafe)Cell`, etc.) which should be added to this crate. I have kept the initial scope small to demonstrate utility without making this too unwieldy. --------- Co-authored-by: TimJentzsch <[email protected]> Co-authored-by: Chris Russell <[email protected]> Co-authored-by: François Mockers <[email protected]>
# Objective - Contributes to bevyengine#16877 ## Solution - Initial creation of `bevy_platform_support` crate. - Moved `bevy_utils::Instant` into new `bevy_platform_support` crate. - Moved `portable-atomic`, `portable-atomic-util`, and `critical-section` into new `bevy_platform_support` crate. ## Testing - CI --- ## Showcase Instead of needing code like this to import an `Arc`: ```rust #[cfg(feature = "portable-atomic")] use portable_atomic_util::Arc; #[cfg(not(feature = "portable-atomic"))] use alloc::sync::Arc; ``` We can now use: ```rust use bevy_platform_support::sync::Arc; ``` This applies to many other types, but the goal is overall the same: allowing crates to use `std`-like types without the boilerplate of conditional compilation and platform-dependencies. ## Migration Guide - Replace imports of `bevy_utils::Instant` with `bevy_platform_support::time::Instant` - Replace imports of `bevy::utils::Instant` with `bevy::platform_support::time::Instant` ## Notes - `bevy_platform_support` hasn't been reserved on `crates.io` - ~~`bevy_platform_support` is not re-exported from `bevy` at this time. It may be worthwhile exporting this crate, but I am unsure of a reasonable name to export it under (`platform_support` may be a bit wordy for user-facing).~~ - I've included an implementation of `Instant` which is suitable for `no_std` platforms that are not Wasm for the sake of eliminating feature gates around its use. It may be a controversial inclusion, so I'm happy to remove it if required. - There are many other items (`spin`, `bevy_utils::Sync(Unsafe)Cell`, etc.) which should be added to this crate. I have kept the initial scope small to demonstrate utility without making this too unwieldy. --------- Co-authored-by: TimJentzsch <[email protected]> Co-authored-by: Chris Russell <[email protected]> Co-authored-by: François Mockers <[email protected]>
Objective
Solution
bevy_platform_supportcrate.bevy_utils::Instantinto newbevy_platform_supportcrate.portable-atomic,portable-atomic-util, andcritical-sectioninto newbevy_platform_supportcrate.Testing
Showcase
Instead of needing code like this to import an
Arc:We can now use:
This applies to many other types, but the goal is overall the same: allowing crates to use
std-like types without the boilerplate of conditional compilation and platform-dependencies.Migration Guide
bevy_utils::Instantwithbevy_platform_support::time::Instantbevy::utils::Instantwithbevy::platform_support::time::InstantNotes
bevy_platform_supporthasn't been reserved oncrates.iobevy_platform_supportis not re-exported frombevyat this time. It may be worthwhile exporting this crate, but I am unsure of a reasonable name to export it under (platform_supportmay be a bit wordy for user-facing).Instantwhich is suitable forno_stdplatforms that are not Wasm for the sake of eliminating feature gates around its use. It may be a controversial inclusion, so I'm happy to remove it if required.spin,bevy_utils::Sync(Unsafe)Cell, etc.) which should be added to this crate. I have kept the initial scope small to demonstrate utility without making this too unwieldy.