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

View file

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

View file

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

View file

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

View file

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