Skip to content

Commit

Permalink
remove custom define "DEBUG_BUILD" and use standard define NDEBUG
Browse files Browse the repository at this point in the history
  • Loading branch information
Totto16 committed May 24, 2024
1 parent f871505 commit 27da4cf
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 23 deletions.
10 changes: 5 additions & 5 deletions src/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "helper/console_helpers.hpp"
#endif

#ifdef DEBUG_BUILD
#if !defined(NDEBUG)
#include "graphics/text.hpp"
#endif

Expand Down Expand Up @@ -58,7 +58,7 @@ Application::Application(std::shared_ptr<Window>&& window, const std::vector<std
void Application::run() {
m_event_dispatcher.register_listener(this);

#ifdef DEBUG_BUILD
#if !defined(NDEBUG)
auto start_time = SDL_GetPerformanceCounter();
const auto update_time = SDL_GetPerformanceFrequency() / 2; //0.5 s
const auto count_per_s = static_cast<double>(SDL_GetPerformanceFrequency());
Expand All @@ -84,7 +84,7 @@ void Application::run() {
render();
m_renderer.present();

#ifdef DEBUG_BUILD
#if !defined(NDEBUG)
++frame_counter;

const Uint64 current_time = SDL_GetPerformanceCounter();
Expand Down Expand Up @@ -244,7 +244,7 @@ void Application::render() const {
for (const auto& scene : m_scene_stack) {
scene->render(*this);
}
#ifdef DEBUG_BUILD
#if !defined(NDEBUG)
m_fps_text->render(*this);
#endif
}
Expand All @@ -266,7 +266,7 @@ void Application::initialize() {

this->load_resources();

#ifdef DEBUG_BUILD
#if !defined(NDEBUG)
m_fps_text = std::make_unique<ui::Label>(
this, "FPS: ?", font_manager().get(FontId::Default), Color::white(),
std::pair<double, double>{ 0.95, 0.95 },
Expand Down
2 changes: 1 addition & 1 deletion src/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct Application final : public EventListener, public ServiceProvider {
std::unique_ptr<FontManager> m_font_manager;


#ifdef DEBUG_BUILD
#if !defined(NDEBUG)
std::unique_ptr<ui::Label> m_fps_text{ nullptr };
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/discord/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void DiscordInstance::after_setup() {


core->SetLogHook(
#ifdef DEBUG_BUILD
#if !defined(NDEBUG)
discord::LogLevel::Debug
#else
discord::LogLevel::Error
Expand Down
2 changes: 1 addition & 1 deletion src/game/tetrion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ void Tetrion::lock_active_tetromino(const SimulationStep simulation_step_index)
reset_lock_delay(simulation_step_index);

// save a snapshot on every freeze (only in debug builds)
#ifdef DEBUG_BUILD
#if !defined(NDEBUG)
if (m_recording_writer) {
spdlog::debug("adding snapshot at step {}", simulation_step_index);
(*m_recording_writer)->add_snapshot(m_tetrion_index, simulation_step_index, core_information());
Expand Down
3 changes: 2 additions & 1 deletion src/helper/parse_json.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@

#pragma once

#ifdef DEBUG_BUILD
#if !defined(NDEBUG)
// better json error messages, see https://json.nlohmann.me/api/macros/json_diagnostics/
#define JSON_DIAGNOSTICS 1 // NOLINT(cppcoreguidelines-macro-usage)
#endif

#include <nlohmann/json.hpp>

#include "helper/expected.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int main(int argc, char** argv) {
auto combined_logger = std::make_shared<spdlog::logger>("combined_logger", begin(sinks), end(sinks));
spdlog::set_default_logger(combined_logger);

#ifdef DEBUG_BUILD
#if !defined(NDEBUG)
spdlog::set_level(spdlog::level::debug);
#else
spdlog::set_level(spdlog::level::err);
Expand Down
2 changes: 1 addition & 1 deletion src/manager/music_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ void MusicManager::hook_music_finished() {


[[nodiscard]] helper::optional<double> MusicManager::get_volume() const {
#ifdef DEBUG_BUILD
#if !defined(NDEBUG)
int result = Mix_VolumeMusic(-1);
if (result == 0) {
return helper::nullopt;
Expand Down
2 changes: 1 addition & 1 deletion src/scenes/about_page/about_page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace scenes {

auto focus_helper = ui::FocusHelper{ 1 };

#ifdef DEBUG_BUILD
#if !defined(NDEBUG)
m_main_grid.add<ui::Label>(
service_provider, fmt::format("Git Commit: {}", utils::git_commit()),
service_provider->font_manager().get(FontId::Default), Color::white(),
Expand Down
2 changes: 1 addition & 1 deletion src/ui/layouts/focus_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ ui::FocusLayout::handle_event_result(const helper::optional<ui::Widget::InnerSta
}
}

#ifdef DEBUG_BUILD
#if !defined(NDEBUG)
// this works, since result is sorted already
const auto duplicates = std::ranges::adjacent_find(result);
if (duplicates != result.cend()) {
Expand Down
10 changes: 0 additions & 10 deletions tools/options/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,3 @@ elif cpp.get_id() == 'clang'
endif

endif

if (
get_option('buildtype') == 'debug'
or get_option('buildtype') == 'debugoptimized'
)
#TODO: replace with ! NDEBUG in cpp files and remove this
core_lib += {
'compile_args': [core_lib.get('compile_args'), '-DDEBUG_BUILD'],
}
endif

0 comments on commit 27da4cf

Please sign in to comment.