-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Cargo Feature Collections #21472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cargo Feature Collections #21472
Changes from 5 commits
edebd11
81904a1
aebe020
baa2ba8
62a39a1
662581f
5936f9a
f1ec4d7
352f9e1
bae27a0
451249e
1c34c4e
3282c1a
a0de161
e0a6bab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -125,67 +125,173 @@ unsafe_op_in_unsafe_fn = "warn" | |||||
| unused_qualifications = "warn" | ||||||
|
|
||||||
| [features] | ||||||
| default = [ | ||||||
| "std", | ||||||
| default = ["2d", "3d", "ui"] | ||||||
|
|
||||||
| # SECTION: Feature Collections | ||||||
| # High level scoped collections of features that give the "full" bevy experience, | ||||||
| # but scoped to a specific domain. These are then combined together to form the default Bevy feature set. | ||||||
| # These exist to be paired with `default-features = false`, enabling compiling only the subset of Bevy that you | ||||||
| # need. This can cut down compile times and shrink your final binary size. | ||||||
|
|
||||||
| # Features used to build 2D Bevy apps (this includes the bevy_render backend). | ||||||
| # Add this to your app if you would like the "default" 2D Bevy experience. | ||||||
cart marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| 2d = [ | ||||||
| "default_app", | ||||||
| "default_platform", | ||||||
| "2d_api", | ||||||
| "2d_bevy_render", | ||||||
| "ui", | ||||||
| "scene", | ||||||
| "audio", | ||||||
| "picking", | ||||||
| ] | ||||||
|
|
||||||
| # Features used to build 3D Bevy apps (this includes the bevy_render backend). | ||||||
| # Add this to your app if you would like the "default" 3D Bevy experience. | ||||||
cart marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| 3d = [ | ||||||
| "default_app", | ||||||
| "default_platform", | ||||||
| "3d_api", | ||||||
| "3d_bevy_render", | ||||||
| "ui", | ||||||
| "scene", | ||||||
| "audio", | ||||||
| "picking", | ||||||
| ] | ||||||
|
|
||||||
| # Features used to build UI Bevy apps (this includes the bevy_render backend). | ||||||
| # Add this to your app if you would like the "default" Bevy UI experience. | ||||||
|
||||||
| # Add this to your app if you would like the "default" Bevy UI experience. | |
| # Add this to your app if you would like the default Bevy UI experience. |
cart marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
cart marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this collection ever have any other entry? Why not just use bevy_scene?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, will bsn go here? bevy_bsn?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a high likelihood that the next generation scene system will be broken up into bevy_scene (everything but the bsn asset / macro) and bevy_bsn (bsn asset and macro).
cart marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
cart marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
cart marked this conversation as resolved.
Show resolved
Hide resolved
cart marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
cart marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
cart marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
cart marked this conversation as resolved.
Show resolved
Hide resolved
cart marked this conversation as resolved.
Show resolved
Hide resolved
cart marked this conversation as resolved.
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| --- | ||
| title: Cargo Feature Collections | ||
| authors: ["@cart"] | ||
| pull_requests: [21472] | ||
| --- | ||
|
|
||
| Historically, Bevy developers have lived one of two lifestyles: | ||
|
|
||
| 1. Use all of Bevy's default features, potentially compiling many unwanted or unneeded features. | ||
| 2. Disable Bevy's default features and manually define the complete list of features. | ||
|
|
||
| Living in the world of (2) was an exercise in frustration, as the list of bevy features is _massive_ and the features required to accomplish a given task changes regularly across releases. This was an _expert level_ task that required intimate knowledge of engine internals to get right. | ||
|
|
||
| **Bevy 0.18** introduces high-level "cargo feature collections" to the `bevy` crate: `2d`, `3d`, and `ui`. This enables developers to easily select the kind of app they want to build, and only compile the pieces of Bevy needed for that app. | ||
|
|
||
| This means scenarios like using Bevy as a UI framework, without pulling in the rest of the engine, is now as easy as: | ||
|
|
||
| ```toml | ||
| bevy = { version = "0.18", default-features = false, features = ["ui"] } | ||
| ``` | ||
|
|
||
| We've also added mid-level feature collections like `2d_api`, which is Bevy's 2D API _without the default Bevy renderer_. This makes it much easier to swap out the default Bevy renderer for a custom one. | ||
|
|
||
| For example, the `2d` profile looks like this: | ||
|
|
||
| ```toml | ||
| 2d = [ | ||
| "default_app", | ||
| "default_platform", | ||
| "2d_api", | ||
| "2d_bevy_render", | ||
| "ui", | ||
| "scene", | ||
| "audio", | ||
| "picking", | ||
| ] | ||
| ``` | ||
|
|
||
| Someone building a custom 2D renderer now just needs to remove `2d_bevy_render` and provide their own. | ||
|
|
||
| Developers can now define their own high-level cargo feature profiles from these mid-level pieces, making it _much_ easier to define the subset of Bevy you want to build into your app. |
Uh oh!
There was an error while loading. Please reload this page.