Change debug feature to logging to disambiguate from un-optimized builds

This commit is contained in:
Tobias Berger 2022-09-21 14:13:33 +02:00
parent e3038ae907
commit 81bc9584b3
Signed by: toby
GPG key ID: 2D05EFAB764D6A88
6 changed files with 46 additions and 46 deletions

View file

@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
os: [windows-2022, ubuntu-22.04, macos-12]
features: ["debug,globe_view", "globe_view", "debug,render", "render", "debug", ""]
features: ["logging,globe_view", "globe_view", "logging,render", "render", "logging", ""]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
@ -31,21 +31,21 @@ jobs:
run: |
cargo build --release --no-default-features --features=${{ matrix.features }}
- name: Upload debug & globe_view binary (Unix)
- name: Upload logging & globe_view binary (Unix)
uses: actions/upload-artifact@v3
if: ${{ matrix.os != 'windows-2022' && matrix.features == 'debug,globe_view' }}
if: ${{ matrix.os != 'windows-2022' && matrix.features == 'logging,globe_view' }}
with:
name: worlds-rs-${{ matrix.os }}-debug-globe_view
name: worlds-rs-${{ matrix.os }}-logging-globe_view
path: |
target/release/worlds-sim-rust
- name: Upload debug & render binary (Unix)
- name: Upload logging & render binary (Unix)
uses: actions/upload-artifact@v3
if: ${{ matrix.os != 'windows-2022' && matrix.features == 'debug,render' }}
if: ${{ matrix.os != 'windows-2022' && matrix.features == 'logging,render' }}
with:
name: worlds-rs-${{ matrix.os }}-debug-render
name: worlds-rs-${{ matrix.os }}-logging-render
path: |
target/release/worlds-sim-rust
- name: Upload non-debug binary (Unix)
- name: Upload non-logging binary (Unix)
uses: actions/upload-artifact@v3
if: ${{ matrix.os != 'windows-2022' && !contains(matrix.features, ',') && matrix.features != '' }}
with:
@ -60,21 +60,21 @@ jobs:
path: |
target/release/worlds-sim-rust
- name: Upload debug & globe_view binary (Windows)
- name: Upload logging & globe_view binary (Windows)
uses: actions/upload-artifact@v3
if: ${{ matrix.os == 'windows-2022' && matrix.features == 'debug,globe_view' }}
if: ${{ matrix.os == 'windows-2022' && matrix.features == 'logging,globe_view' }}
with:
name: worlds-rs-${{ matrix.os }}-debug-globe_view
name: worlds-rs-${{ matrix.os }}-logging-globe_view
path: |
target/release/worlds-sim-rust.exe
- name: Upload debug & render binary (Windows)
- name: Upload logging & render binary (Windows)
uses: actions/upload-artifact@v3
if: ${{ matrix.os == 'windows-2022' && matrix.features == 'debug,render' }}
if: ${{ matrix.os == 'windows-2022' && matrix.features == 'logging,render' }}
with:
name: worlds-rs-${{ matrix.os }}-debug-render
name: worlds-rs-${{ matrix.os }}-logging-render
path: |
target/release/worlds-sim-rust.exe
- name: Upload non-debug binary (Windows)
- name: Upload non-logging binary (Windows)
uses: actions/upload-artifact@v3
if: ${{ matrix.os == 'windows-2022' && !contains(matrix.features, ',') && matrix.features != '' }}
with:

View file

@ -5,10 +5,10 @@ edition = "2021"
resolver = "2"
[features]
debug = ["planet/debug"]
logging = ["planet/logging"]
globe_view = ["planet/globe_view", "render"]
render = ["bevy/bevy_asset", "bevy/bevy_winit", "bevy/x11", "bevy/wayland", "bevy/render", "planet/render", "dep:bevy_pancam"]
default = ["render", "debug"]
default = ["render", "logging"]
[dependencies.planet]
path = "planet"

View file

@ -4,10 +4,10 @@ version = "0.1.0"
edition = "2021"
[features]
debug = []
logging = []
globe_view = ["render"]
render = ["bevy/render"]
default = ["render", "debug", "globe_view"]
default = ["render", "logging", "globe_view"]
[dependencies.rand]
version = "0.8.5"

View file

@ -1,6 +1,6 @@
#[cfg(all(feature = "debug", feature = "render"))]
#[cfg(all(feature = "logging", feature = "render"))]
use bevy::log::debug;
#[cfg(feature = "debug")]
#[cfg(feature = "logging")]
use bevy::utils::default;
#[cfg(all(feature = "render", feature = "globe_view"))]
use std::f32::consts::PI;
@ -142,7 +142,7 @@ impl WorldManager {
return Err(SaveError::MissingWorld);
},
};
#[cfg(feature = "debug")]
#[cfg(feature = "logging")]
let serialized = match ron::ser::to_string_pretty(world, default()) {
Ok(serialized) => serialized,
Err(err) => {
@ -150,7 +150,7 @@ impl WorldManager {
},
};
#[cfg(not(feature = "debug"))]
#[cfg(not(feature = "logging"))]
let serialized = match ron::to_string(world) {
Ok(serialized) => serialized,
Err(err) => {
@ -210,7 +210,7 @@ impl WorldManager {
#[cfg(feature = "render")]
pub fn toggle_rainfall(&mut self) {
#[cfg(feature = "debug")]
#[cfg(feature = "logging")]
if self.rainfall_visible {
debug!("Turning rainfall off");
} else {
@ -221,7 +221,7 @@ impl WorldManager {
#[cfg(feature = "render")]
pub fn toggle_temperature(&mut self) {
#[cfg(feature = "debug")]
#[cfg(feature = "logging")]
if self.temperature_visible {
debug!("Turning temperature off");
} else {
@ -237,7 +237,7 @@ impl WorldManager {
.unwrap()
+ 1)
% PlanetView::ITEM_COUNT;
#[cfg(feature = "debug")]
#[cfg(feature = "logging")]
debug!(
"Cycling view from {:#?} to {:#?}",
self.view,
@ -248,7 +248,7 @@ impl WorldManager {
#[cfg(feature = "render")]
pub fn toggle_contours(&mut self) {
#[cfg(feature = "debug")]
#[cfg(feature = "logging")]
if self.contours {
debug!("Turning terrain contours off");
} else {
@ -440,7 +440,7 @@ impl WorldManager {
for x in 0..world.width as usize {
let factor_y = (1.0 - f32::cos(PI * y as f32 / (world.height * 2) as f32)) / 2.0;
let real_y = f32::floor(world.height as f32 * factor_y) as usize;
#[cfg(feature = "debug")]
#[cfg(feature = "logging")]
assert!(
real_y < world.height as usize,
"Trying to get cell off of planet. {}/{}",

View file

@ -38,7 +38,7 @@ pub(crate) mod plugins;
pub(crate) mod resources;
pub(crate) mod ui_helpers;
#[cfg(all(feature = "debug", feature = "render"))]
#[cfg(all(feature = "logging", feature = "render"))]
use bevy::{
diagnostic::{Diagnostics, FrameTimeDiagnosticsPlugin},
log::debug,
@ -126,7 +126,7 @@ fn refresh_map_texture(
world_manager: &WorldManager,
) {
let world = world_manager.world();
#[cfg(feature = "debug")]
#[cfg(feature = "logging")]
debug!("refreshing world texture");
let map_image_handle = images.get_handle(
world_manager
@ -210,7 +210,7 @@ fn handle_toolbar_button(
*color = PRESSED_BUTTON.into();
match toolbar_button {
ToolbarButton::Rainfall => {
#[cfg(feature = "debug")]
#[cfg(feature = "logging")]
debug!("Toggling rainfall");
world_manager.toggle_rainfall();
refresh_map_texture(
@ -221,7 +221,7 @@ fn handle_toolbar_button(
);
},
ToolbarButton::Temperature => {
#[cfg(feature = "debug")]
#[cfg(feature = "logging")]
debug!("Toggling temperature");
world_manager.toggle_temperature();
refresh_map_texture(
@ -232,7 +232,7 @@ fn handle_toolbar_button(
);
},
ToolbarButton::PlanetView => {
#[cfg(feature = "debug")]
#[cfg(feature = "logging")]
debug!("Cycling planet view");
world_manager.cycle_view();
refresh_map_texture(
@ -243,7 +243,7 @@ fn handle_toolbar_button(
);
},
ToolbarButton::Contours => {
#[cfg(feature = "debug")]
#[cfg(feature = "logging")]
debug!("Toggling contours");
world_manager.toggle_contours();
refresh_map_texture(
@ -254,7 +254,7 @@ fn handle_toolbar_button(
);
},
ToolbarButton::GenerateWorld => {
#[cfg(feature = "debug")]
#[cfg(feature = "logging")]
debug!("Generating new world");
_ = world_manager
.new_world()
@ -267,12 +267,12 @@ fn handle_toolbar_button(
);
},
ToolbarButton::SaveWorld => {
#[cfg(feature = "debug")]
#[cfg(feature = "logging")]
debug!("Saving world");
_ = world_manager.save_world("planet.ron");
},
ToolbarButton::LoadWorld => {
#[cfg(feature = "debug")]
#[cfg(feature = "logging")]
debug!("Loading world");
_ = world_manager.load_world("planet.ron", &mut images);
refresh_map_texture(
@ -284,7 +284,7 @@ fn handle_toolbar_button(
},
#[cfg(feature = "globe_view")]
ToolbarButton::GlobeView => {
#[cfg(feature = "debug")]
#[cfg(feature = "logging")]
debug!("Toggling globe view");
let mut camera_3d = camera_3d_query.single_mut();
camera_3d.is_active = !camera_3d.is_active;
@ -347,7 +347,7 @@ fn rotate_globe(mut globe_transform: Query<'_, '_, &mut Transform, With<Handle<M
#[cfg(feature = "render")]
fn update_info_panel(
#[cfg(feature = "debug")] diagnostics: Res<'_, Diagnostics>,
#[cfg(feature = "logging")] diagnostics: Res<'_, Diagnostics>,
cursor_position: Res<'_, CursorMapPosition>,
world_manager: Res<'_, WorldManager>,
mut text: Query<'_, '_, &mut Text, With<InfoPanel>>,
@ -360,7 +360,7 @@ fn update_info_panel(
{
let cell = &world.terrain[cursor_position.y as usize][cursor_position.x as usize];
#[cfg(feature = "debug")]
#[cfg(feature = "logging")]
{
format!(
"FPS: ~{}\nMouse position: {}\nAltitude: {}\nRainfall: {}\nTemperature: {}\n\n{}",
@ -386,7 +386,7 @@ fn update_info_panel(
)
}
#[cfg(not(feature = "debug"))]
#[cfg(not(feature = "logging"))]
{
format!(
"Mouse position: {}\nAltitude: {}\nRainfall: {}\nTemperature: {}\n{}",
@ -408,7 +408,7 @@ fn update_info_panel(
)
}
} else {
#[cfg(feature = "debug")]
#[cfg(feature = "logging")]
{
format!(
"FPS: ~{}\nMouse position: {}\nOut of bounds",
@ -420,7 +420,7 @@ fn update_info_panel(
)
}
#[cfg(not(feature = "debug"))]
#[cfg(not(feature = "logging"))]
{
format!("Mouse position: {}\nOut of bounds", *cursor_position)
}
@ -644,9 +644,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
}
_ = app.insert_resource(LogSettings {
#[cfg(feature = "debug")]
#[cfg(feature = "logging")]
level: Level::DEBUG,
#[cfg(not(feature = "debug"))]
#[cfg(not(feature = "logging"))]
level: Level::WARN,
..default()
});

View file

@ -61,7 +61,7 @@ impl PluginGroup for WorldPlugins {
}
_ = group.add(DiagnosticsPlugin::default());
#[cfg(all(feature = "debug"))]
#[cfg(all(feature = "logging"))]
{
use bevy::diagnostic::FrameTimeDiagnosticsPlugin;
_ = group.add(FrameTimeDiagnosticsPlugin::default());