Skip to content

Conversation

@TimJentzsch
Copy link
Collaborator

@TimJentzsch TimJentzsch commented Dec 31, 2024

Objective

Closes #201.

Allows users to quickly try out different configurations without modifying Cargo.toml.

For us, it's most useful for finding the best default config for the web profiles.

Solution

Add support for --config argument for bevy build and bevy run, analogue to the cargo counterpart.
This essentially allows you to modify the Cargo.toml without editing the file, e.g. --config "profile.web.debug=false".

We already exploit cargo's --config arg to configure our default web compilation profiles.
So we have to ensure that the user-provided args overwrite our default ones.

To do this, we change the default web profiles to be prepended to the user-provided --config args, instead of converting them to --config arguments directly.
Since --config is resolved left-to-right, the defaults will be overwritten by the user.

Testing

Try for example:

bevy build --config "profile.web.debug=false" --config 'profile.web.inherits= "release"' web

Now instead of

Finished `web` profile [unoptimized + debuginfo] target(s)

you should get

Finished `web` profile [optimized] target(s)

Debug info removed and optimizations enabled!
(Of course this can be done easier via bevy build --release web, but like this it's easier to benchmark different compilation profiles to choose the best default)

@TimJentzsch TimJentzsch added C-Feature Make something new possible A-Run Related to the bevy run command A-Build Related to the bevy build command labels Dec 31, 2024
@TimJentzsch TimJentzsch added the S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged label Jan 18, 2025
@TimJentzsch TimJentzsch marked this pull request as ready for review January 18, 2025 12:49
@TimJentzsch TimJentzsch added S-Needs-Review The PR needs to be reviewed before it can be merged D-Straightforward Simple bug fixes and API improvements, docs, test and examples and removed S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Jan 18, 2025
Copy link
Collaborator

@DaAlbrecht DaAlbrecht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works like a charm! Tested with config options as arguments or by passing a file.
If the comment about the cargo build options is resolved this can be merged IMO 😊

@DaAlbrecht
Copy link
Collaborator

Perhaps a test case for add_values_separately would be nice

Copy link
Collaborator

@DaAlbrecht DaAlbrecht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@TimJentzsch TimJentzsch merged commit 10d0dbc into main Jan 19, 2025
8 checks passed
@TimJentzsch TimJentzsch deleted the 201-config-arg branch January 19, 2025 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Build Related to the bevy build command A-Run Related to the bevy run command C-Feature Make something new possible D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review The PR needs to be reviewed before it can be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support --config argument for bevy build and bevy run

3 participants