Skip to content

use correct config scope for release and custom cli profiles #404

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

DaAlbrecht
Copy link
Collaborator

@DaAlbrecht DaAlbrecht commented May 1, 2025

Fixes: https://discord.com/channels/691052431525675048/1278871953721262090/1367460269412057149

Before

bevy build --release
bevy build --profile release

# Become these cargo commands:
cargo build --features native --profile release
cargo build --features native,native_dev --profile release

Now

Build:

❯ bevy build -r web -v
DEBUG Using defaults from bevy_cli config:
      features = []
      default_features = false
      rustflags = ["--cfg", 'getrandom_backend="wasm_js"']
 INFO Compiling to WebAssembly...
DEBUG Running: `cargo build --config profile.web.inherits="dev" --no-default-features --profile web-release --target wasm32-unknown-unknown`
DEBUG With env: RUSTFLAGS=--cfg getrandom_backend="wasm_js"
    Finished `web-release` profile [optimized] target(s) in 0.12s
 INFO Bundling JavaScript bindings...
DEBUG Running: `wasm-bindgen --no-typescript --out-name bevy_new_2d --out-dir 
bevy_new_2d/target/wasm32-unknown-unknown/web-release --target web 
bevy_new_2d/target/wasm32-unknown-unknown/web-release/bevy_new_2d.wasm`
 INFO No custom `web` folder found, using defaults.
❯ bevy build --profile web-release -v
DEBUG Using defaults from bevy_cli config:
      features = []
      default_features = false
      rustflags = ["--cfg", 'getrandom_backend="wasm_js"']
 INFO Compiling to WebAssembly...
DEBUG Running: `cargo build --config profile.web.inherits="dev" --no-default-features --profile web-release --target wasm32-unknown-unknown`
DEBUG With env: RUSTFLAGS=--cfg getrandom_backend="wasm_js"
    Finished `web-release` profile [optimized] target(s) in 0.12s
 INFO Bundling JavaScript bindings...
DEBUG Running: `wasm-bindgen --no-typescript --out-name bevy_new_2d --out-dir 
bevy_new_2d/target/wasm32-unknown-unknown/web-release --target web /
bevy_new_2d/target/wasm32-unknown-unknown/web-release/bevy_new_2d.wasm`
 INFO No custom `web` folder found, using defaults.

Run:

❯ bevy run --profile web-release -v
DEBUG Using defaults from bevy_cli config:
      features = []
      default_features = false
      rustflags = ["--cfg", 'getrandom_backend="wasm_js"']
 INFO Compiling to WebAssembly...
DEBUG Running: `cargo build --config profile.web.inherits="dev" --bin bevy_new_2d --no-default-features --profile web-release --target wasm32-unknown-unknown`
DEBUG With env: RUSTFLAGS=--cfg getrandom_backend="wasm_js"
    Finished `web-release` profile [optimized] target(s) in 0.12s
 INFO Bundling JavaScript bindings...
DEBUG Running: `wasm-bindgen --no-typescript --out-name bevy_new_2d --out-dir 
bevy_new_2d/target/wasm32-unknown-unknown/web-release --target web 
bevy_new_2d/target/wasm32-unknown-unknown/web-release/bevy_new_2d.wasm`
 INFO No custom `web` folder found, using defaults.
 INFO Open your app at <http://localhost:4000>!
❯ bevy run -r web -v
DEBUG Using defaults from bevy_cli config:
      features = []
      default_features = false
      rustflags = ["--cfg", 'getrandom_backend="wasm_js"']
 INFO Compiling to WebAssembly...
DEBUG Running: `cargo build --config profile.web.inherits="dev" --bin bevy_new_2d --no-default-features --profile web-release --target wasm32-unknown-unknown`
DEBUG With env: RUSTFLAGS=--cfg getrandom_backend="wasm_js"
    Finished `web-release` profile [optimized] target(s) in 0.13s
 INFO Bundling JavaScript bindings...
DEBUG Running: `wasm-bindgen --no-typescript --out-name bevy_new_2d --out-dir 
bevy_new_2d/target/wasm32-unknown-unknown/web-release --target web
/bevy_new_2d/target/wasm32-unknown-unknown/web-release/bevy_new_2d.wasm`
 INFO No custom `web` folder found, using defaults.
 INFO Open your app at <http://localhost:4000>!

@DaAlbrecht DaAlbrecht changed the title set is_web and compilation profile according to profiles use correct config scope for release and custom cli profiles May 1, 2025
@DaAlbrecht DaAlbrecht marked this pull request as ready for review May 1, 2025 20:33
@DaAlbrecht DaAlbrecht added A-CLI Related to the main CLI and not a more specific subcommand 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 labels May 2, 2025
src/build/mod.rs Outdated
args.subcommand = Some(BuildSubcommands::Web(BuildWebArgs::default()));
}
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we integrate this logic directly into the is_release() functions of the args? Then e.g. also the wasm_opt detection works consistently with the config and we don't need to add other feature gated logic here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good call! What do you think now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-CLI Related to the main CLI and not a more specific subcommand 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.

2 participants