diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c3b7c433c..3b33b3cb4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -144,7 +144,7 @@ jobs: wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh sudo ./llvm.sh 21 - sudo apt-get install libc++-21* libc++abi*21* -y --no-install-recommends + sudo apt-get install libc++-21* libc++abi-*21* -y --no-install-recommends echo "CC=clang-21" >> "$GITHUB_ENV" echo "CXX=clang++-21" >> "$GITHUB_ENV" echo "OBJC=clang-21" >> "$GITHUB_ENV" @@ -166,16 +166,6 @@ jobs: version: 15 platform: x64 - - name: Unbreak Python in GHA (MacOS 13 image) - if: matrix.config.os == 'macos' && matrix.config.os-version == 13 - run: | - # TODO: remove this, after it works again - # A workaround for "The `brew link` step did not complete successfully" error. - # See e.g. https://github.com/Homebrew/homebrew-core/issues/165793#issuecomment-1991817938 - find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete - sudo rm -rf /Library/Frameworks/Python.framework/ - brew install --force python3 && brew unlink python3 && brew unlink python3 && brew link --overwrite python3 - - name: Setup Clang (MacOS) if: matrix.config.os == 'macos' run: | diff --git a/io.github.openbrickprotocolfoundation.oopetris.yml b/io.github.openbrickprotocolfoundation.oopetris.yml index 60a4e3d12..640316ad4 100644 --- a/io.github.openbrickprotocolfoundation.oopetris.yml +++ b/io.github.openbrickprotocolfoundation.oopetris.yml @@ -12,10 +12,10 @@ modules: - -Dbuild_installer=true - --libdir=lib - -Dtests=true - - -Dsdl2_image:test=false - --fatal-meson-warnings - -Drun_in_ci=true # note we always want the CI checks in the case we built the flatpak - --force-fallback-for=fmt # note, the freedesktop sdk has this installed, but it is not copiable into the runtime, so we need to build it ourself, to be able to install it correctly + - -Dsdl2_image:test=false # disable failing sdl2_image tests builddir: true build-options: build-args: diff --git a/platforms/android/app/build.gradle b/platforms/android/app/build.gradle index f6e0d140d..3df25ac1b 100644 --- a/platforms/android/app/build.gradle +++ b/platforms/android/app/build.gradle @@ -130,7 +130,7 @@ List getAndroidABIs() { /** * Determine the version * if you specify it explicitly, that will be used, otherwise meson introspect will be called - * @return String + * @returns String */ String getVersion() { String property = project.findProperty('VERSION') @@ -320,7 +320,7 @@ android { } compileSdkVersion 35 - ndkVersion = "29.0.14206865" + ndkVersion = "29.0.14033849" defaultConfig { if (buildAsApplication) { applicationId "com.github.oopetris" diff --git a/src/executables/game/application.cpp b/src/executables/game/application.cpp index 0a6ceb831..109a8c186 100644 --- a/src/executables/game/application.cpp +++ b/src/executables/game/application.cpp @@ -124,7 +124,7 @@ Application::Application(std::shared_ptr&& window, CommandLineArguments& Application::~Application() = default; #if defined(__EMSCRIPTEN__) -void c_loop_entry(void* arg) { +static void c_loop_entry(void* arg) { auto application = reinterpret_cast(arg); application->emscripten_do_process(); application->loop_entry_emscripten(); @@ -376,23 +376,23 @@ void Application::update() { std::visit( helper::Overloaded{ - [this, index](const scenes::Scene::Pop&) { + [this, index](const scenes::Scene::Pop&) -> void { m_scene_stack.erase( m_scene_stack.begin() + static_cast(index) ); }, - [this](const scenes::Scene::Push& push) { + [this](const scenes::Scene::Push& push) -> void { spdlog::info("pushing back scene {}", magic_enum::enum_name(push.target_scene)); m_scene_stack.push_back( scenes::create_scene(*this, push.target_scene, push.layout) ); }, - [this](scenes::Scene::RawPush& raw_push) { + [this](scenes::Scene::RawPush& raw_push) -> void { spdlog::info("pushing back scene {}", raw_push.name); m_scene_stack.push_back(std::move(raw_push.scene)); }, - [this](const scenes::Scene::Switch& scene_switch) { + [this](const scenes::Scene::Switch& scene_switch) -> void { spdlog::info( "switching to scene {}", magic_enum::enum_name(scene_switch.m_target_scene) ); diff --git a/src/executables/meson.build b/src/executables/meson.build index 8b67264af..0cb8bea9c 100644 --- a/src/executables/meson.build +++ b/src/executables/meson.build @@ -12,6 +12,7 @@ if build_application 'oopetris', main_files, dependencies: [liboopetris_graphics_dep, graphic_application_deps], + cpp_args: common_cpp_compiler_args, override_options: { 'warning_level': '3', 'werror': true, diff --git a/src/executables/utility/command_line_arguments.hpp b/src/executables/utility/command_line_arguments.hpp index 22be1a88d..58871af4a 100644 --- a/src/executables/utility/command_line_arguments.hpp +++ b/src/executables/utility/command_line_arguments.hpp @@ -25,14 +25,14 @@ struct CommandLineArguments final { template - CommandLineArguments(std::filesystem::path&& recording_path, T&& value) - : recording_path{ std::move(recording_path) }, - value{ std::forward(value) } { } + CommandLineArguments(std::filesystem::path&& recording_path_a, T&& value_a) + : recording_path{ std::move(recording_path_a) }, + value{ std::forward(value_a) } { } template - CommandLineArguments(std::filesystem::path&& recording_path, const T& value) - : recording_path{ std::move(recording_path) }, - value{ value } { } + CommandLineArguments(std::filesystem::path&& recording_path_a, const T& value_a) + : recording_path{ std::move(recording_path_a) }, + value{ value_a } { } [[nodiscard]] static helper::expected from_args(int argc, char** argv) noexcept { diff --git a/src/game/command_line_arguments.cpp b/src/game/command_line_arguments.cpp index 48f068aa1..fa8c28206 100644 --- a/src/game/command_line_arguments.cpp +++ b/src/game/command_line_arguments.cpp @@ -5,12 +5,12 @@ CommandLineArguments::CommandLineArguments( - std::optional recording_path, - std::optional target_fps, - Level starting_level, - bool silent + std::optional recording_path_a, + std::optional target_fps_a, + Level starting_level_a, + bool silent_a ) - : recording_path{ std::move(recording_path) }, - target_fps{ target_fps }, - starting_level{ starting_level }, - silent{ silent } { } + : recording_path{ std::move(recording_path_a) }, + target_fps{ target_fps_a }, + starting_level{ starting_level_a }, + silent{ silent_a } { } diff --git a/src/game/command_line_arguments.hpp b/src/game/command_line_arguments.hpp index 2abf44026..14ade19df 100644 --- a/src/game/command_line_arguments.hpp +++ b/src/game/command_line_arguments.hpp @@ -23,9 +23,9 @@ struct CommandLineArguments final { bool silent; OOPETRIS_GRAPHICS_EXPORTED CommandLineArguments( - std::optional recording_path, - std::optional target_fps, - Level starting_level = default_starting_level, - bool silent = default_silent + std::optional recording_path_a, + std::optional target_fps_a, + Level starting_level_a = default_starting_level, + bool silent_a = default_silent ); }; diff --git a/src/graphics/rect.hpp b/src/graphics/rect.hpp index cf930672b..43ba75e16 100644 --- a/src/graphics/rect.hpp +++ b/src/graphics/rect.hpp @@ -14,9 +14,9 @@ namespace shapes { Point bottom_right; constexpr AbstractRect() = default; - constexpr AbstractRect(Point top_left, Point bottom_right) // NOLINT(bugprone-easily-swappable-parameters) - : top_left{ top_left }, - bottom_right{ bottom_right } { } + constexpr AbstractRect(Point top_left_a, Point bottom_right_a) // NOLINT(bugprone-easily-swappable-parameters) + : top_left{ top_left_a }, + bottom_right{ bottom_right_a } { } constexpr AbstractRect(T x_pos, T y_pos, T width, T height) : top_left{ x_pos, y_pos }, bottom_right{ x_pos + width - 1, y_pos + height - 1 } { } diff --git a/src/helper/nfd_include.hpp b/src/helper/nfd_include.hpp index 417b9ec3c..c4d5a6330 100644 --- a/src/helper/nfd_include.hpp +++ b/src/helper/nfd_include.hpp @@ -10,8 +10,21 @@ #ifdef _WIN32 #define NFD_DIFFERENT_NATIVE_FUNCTIONS #endif + + +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wundef" + +#endif + #include +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif + + #include #include #include diff --git a/src/input/input_creator.hpp b/src/input/input_creator.hpp index 1c3f44ded..bd95f0b23 100644 --- a/src/input/input_creator.hpp +++ b/src/input/input_creator.hpp @@ -19,17 +19,17 @@ namespace tetrion { std::optional> recording_writer; StartingParameters( - u32 target_fps, - Random::Seed seed, - u32 starting_level, // NOLINT(bugprone-easily-swappable-parameters) - u8 tetrion_index, - std::optional> recording_writer = std::nullopt + u32 target_fps_a, // NOLINT(bugprone-easily-swappable-parameters) + Random::Seed seed_a, + u32 starting_level_a, + u8 tetrion_index_a, + std::optional> recording_writer_a = std::nullopt ) - : target_fps{ target_fps }, - seed{ seed }, - starting_level{ starting_level }, - tetrion_index{ tetrion_index }, - recording_writer{ std::move(recording_writer) } { } + : target_fps{ target_fps_a }, + seed{ seed_a }, + starting_level{ starting_level_a }, + tetrion_index{ tetrion_index_a }, + recording_writer{ std::move(recording_writer_a) } { } }; } // namespace tetrion diff --git a/src/input/touch_input.hpp b/src/input/touch_input.hpp index 26d1de72f..3e99b76ca 100644 --- a/src/input/touch_input.hpp +++ b/src/input/touch_input.hpp @@ -27,7 +27,8 @@ namespace input { const SDL_Event& event ) const override; - [[nodiscard]] OOPETRIS_GRAPHICS_EXPORTED std::string describe_navigation_event(NavigationEvent event + [[nodiscard]] OOPETRIS_GRAPHICS_EXPORTED std::string describe_navigation_event( + NavigationEvent event ) const override; [[nodiscard]] OOPETRIS_GRAPHICS_EXPORTED std::optional get_pointer_event( @@ -62,8 +63,12 @@ namespace input { Uint32 timestamp; float x; float y; - explicit PressedState(Uint32 timestamp, float x_pos, float y_pos) //NOLINT(bugprone-easily-swappable-parameters) - : timestamp{ timestamp }, + explicit PressedState( + Uint32 timestamp_a, //NOLINT(bugprone-easily-swappable-parameters) + float x_pos, + float y_pos + ) + : timestamp{ timestamp_a }, x{ x_pos }, y{ y_pos } { } }; @@ -97,7 +102,8 @@ namespace input { OOPETRIS_GRAPHICS_EXPORTED void handle_event(const SDL_Event& event) override; OOPETRIS_GRAPHICS_EXPORTED void update(SimulationStep simulation_step_index) override; - [[nodiscard]] OOPETRIS_GRAPHICS_EXPORTED std::optional get_menu_event(const SDL_Event& event + [[nodiscard]] OOPETRIS_GRAPHICS_EXPORTED std::optional get_menu_event( + const SDL_Event& event ) const override; [[nodiscard]] OOPETRIS_GRAPHICS_EXPORTED std::string describe_menu_event(MenuEvent event) const override; @@ -177,14 +183,13 @@ namespace nlohmann { ::json::check_for_no_additional_keys( - obj, - { - "type", - "move_x_threshold", - "move_y_threshold", - "rotation_duration_threshold", - "drop_duration_threshold", - } + obj, { + "type", + "move_x_threshold", + "move_y_threshold", + "rotation_duration_threshold", + "drop_duration_threshold", + } ); const auto move_x_threshold = json_helper::get_number(obj, "move_x_threshold"); @@ -209,12 +214,14 @@ namespace nlohmann { static void to_json(json& obj, const input::TouchSettings& settings) { - obj = nlohmann::json::object({ - { "move_x_threshold", settings.move_x_threshold }, - { "move_y_threshold", settings.move_y_threshold }, - { "rotation_duration_threshold", settings.rotation_duration_threshold }, - { "drop_duration_threshold", settings.drop_duration_threshold } - }); + obj = nlohmann::json::object( + { + { "move_x_threshold", settings.move_x_threshold }, + { "move_y_threshold", settings.move_y_threshold }, + { "rotation_duration_threshold", settings.rotation_duration_threshold }, + { "drop_duration_threshold", settings.drop_duration_threshold } + } + ); } }; } // namespace nlohmann diff --git a/src/libs/core/helper/color.hpp b/src/libs/core/helper/color.hpp index b47601a64..580c4b4d9 100644 --- a/src/libs/core/helper/color.hpp +++ b/src/libs/core/helper/color.hpp @@ -223,9 +223,9 @@ struct Color { const FloatType offset = value - chroma; - const auto finish_value = [offset](FloatType value) -> u8 { + const auto finish_value = [offset](FloatType f_value) -> u8 { const auto result = - std::clamp(value + offset, static_cast(0.0), static_cast(1.0)) + std::clamp(f_value + offset, static_cast(0.0), static_cast(1.0)) * static_cast(0xFF); return static_cast(round_constexpr(result)); diff --git a/src/libs/core/helper/date.cpp b/src/libs/core/helper/date.cpp index 1af602ac7..301e3bf5d 100644 --- a/src/libs/core/helper/date.cpp +++ b/src/libs/core/helper/date.cpp @@ -87,7 +87,18 @@ date::ISO8601Date::format_tm_struct(std::tm time_struct, const char* format_stri static constexpr auto buffer_size = usize{ 100 }; std::array buffer{}; +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif + const auto result = std::strftime(buffer.data(), buffer.size(), format_string, &time_struct); + +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif + + if (result == 0) { return helper::unexpected{ "error calling std::strftime" }; } diff --git a/src/libs/recordings/utility/additional_information.hpp b/src/libs/recordings/utility/additional_information.hpp index 57fbd06d2..16feca032 100644 --- a/src/libs/recordings/utility/additional_information.hpp +++ b/src/libs/recordings/utility/additional_information.hpp @@ -97,14 +97,14 @@ namespace recorder { return false; } - const auto& other = this->as>(); + const auto& nested_other = this->as>(); - if (other.size() != value.size()) { + if (nested_other.size() != value.size()) { return false; } - for (decltype(other.size()) i = 0; i < other.size(); ++i) { - if (other.at(i) != value.at(i)) { + for (decltype(nested_other.size()) i = 0; i < nested_other.size(); ++i) { + if (nested_other.at(i) != value.at(i)) { return false; } } diff --git a/src/libs/recordings/utility/recording.cpp b/src/libs/recordings/utility/recording.cpp index 7c621ac0f..9fd11033a 100644 --- a/src/libs/recordings/utility/recording.cpp +++ b/src/libs/recordings/utility/recording.cpp @@ -4,9 +4,12 @@ #include -recorder::TetrionHeader::TetrionHeader(Random::Seed seed, u32 starting_level) - : seed{ seed }, - starting_level{ starting_level } { } +recorder::TetrionHeader::TetrionHeader( + Random::Seed seed_a, //NOLINT(bugprone-easily-swappable-parameters) + u32 starting_level_a +) + : seed{ seed_a }, + starting_level{ starting_level_a } { } [[nodiscard]] const std::vector& recorder::Recording::tetrion_headers() const { diff --git a/src/libs/recordings/utility/recording.hpp b/src/libs/recordings/utility/recording.hpp index 2faff8f76..14b32b2ee 100644 --- a/src/libs/recordings/utility/recording.hpp +++ b/src/libs/recordings/utility/recording.hpp @@ -37,7 +37,7 @@ namespace recorder { Random::Seed seed; u32 starting_level; - OOPETRIS_RECORDINGS_EXPORTED TetrionHeader(Random::Seed seed, u32 starting_level); + OOPETRIS_RECORDINGS_EXPORTED TetrionHeader(Random::Seed seed_a, u32 starting_level_a); }; struct Recording { diff --git a/src/libs/recordings/utility/tetrion_core_information.hpp b/src/libs/recordings/utility/tetrion_core_information.hpp index 8f7df5a60..44b7662e7 100644 --- a/src/libs/recordings/utility/tetrion_core_information.hpp +++ b/src/libs/recordings/utility/tetrion_core_information.hpp @@ -11,15 +11,15 @@ struct TetrionCoreInformation { MinoStack mino_stack; TetrionCoreInformation( - u8 tetrion_index, // NOLINT(bugprone-easily-swappable-parameters) - u32 level, - u64 score, - u32 lines_cleared, - MinoStack mino_stack + u8 tetrion_index_a, // NOLINT(bugprone-easily-swappable-parameters) + u32 level_a, + u64 score_a, + u32 lines_cleared_a, + MinoStack mino_stack_a ) - : tetrion_index{ tetrion_index }, - level{ level }, - score{ score }, - lines_cleared{ lines_cleared }, - mino_stack{ std::move(mino_stack) } { }; + : tetrion_index{ tetrion_index_a }, + level{ level_a }, + score{ score_a }, + lines_cleared{ lines_cleared_a }, + mino_stack{ std::move(mino_stack_a) } { }; }; diff --git a/src/lobby/credentials/secret.hpp b/src/lobby/credentials/secret.hpp index 5d3330977..71b231b3e 100644 --- a/src/lobby/credentials/secret.hpp +++ b/src/lobby/credentials/secret.hpp @@ -13,7 +13,18 @@ #if defined(__linux__) +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wshadow" +#endif + #include + +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif + + #elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) #include @@ -52,7 +63,8 @@ namespace secret { OOPETRIS_GRAPHICS_EXPORTED SecretStorage(SecretStorage&& other) noexcept; SecretStorage& operator=(SecretStorage&& other) noexcept = delete; - [[nodiscard]] OOPETRIS_GRAPHICS_EXPORTED helper::expected load(const std::string& key + [[nodiscard]] OOPETRIS_GRAPHICS_EXPORTED helper::expected load( + const std::string& key ) const; [[nodiscard]] OOPETRIS_GRAPHICS_EXPORTED std::optional diff --git a/src/lobby/curl_client.hpp b/src/lobby/curl_client.hpp index 60505fa06..189f6b220 100644 --- a/src/lobby/curl_client.hpp +++ b/src/lobby/curl_client.hpp @@ -4,16 +4,17 @@ #include "./client.hpp" -#if defined(__3DS__) +#if defined(__GNUC__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpedantic" +#pragma GCC diagnostic ignored "-Wundef" #endif #include -#if defined(__3DS__) +#if defined(__GNUC__) #pragma GCC diagnostic pop #endif diff --git a/src/lobby/httplib_client.hpp b/src/lobby/httplib_client.hpp index 73a785541..5bb1332c2 100644 --- a/src/lobby/httplib_client.hpp +++ b/src/lobby/httplib_client.hpp @@ -6,6 +6,8 @@ #pragma GCC diagnostic ignored "-Wold-style-cast" #pragma GCC diagnostic ignored "-Warray-bounds" #pragma GCC diagnostic ignored "-Wunused-parameter" +#pragma GCC diagnostic ignored "-Wundef" +#pragma GCC diagnostic ignored "-Wredundant-decls" #elif defined(_MSC_VER) #pragma warning(disable : 4100) #endif diff --git a/src/scenes/scene.hpp b/src/scenes/scene.hpp index 407782c46..55a2f68be 100644 --- a/src/scenes/scene.hpp +++ b/src/scenes/scene.hpp @@ -31,27 +31,27 @@ namespace scenes { std::string name; std::unique_ptr scene; - RawSwitch(std::string name, std::unique_ptr&& scene) - : name{ std::move(name) }, - scene{ std::move(scene) } { } + RawSwitch(std::string name_a, std::unique_ptr&& scene_a) + : name{ std::move(name_a) }, + scene{ std::move(scene_a) } { } }; struct Push { SceneId target_scene; ui::Layout layout; - Push(const SceneId target_scene, const ui::Layout& layout) - : target_scene{ target_scene }, - layout{ layout } { } + Push(const SceneId target_scene_a, const ui::Layout& layout_a) + : target_scene{ target_scene_a }, + layout{ layout_a } { } }; struct RawPush { std::string name; std::unique_ptr scene; - RawPush(std::string name, std::unique_ptr&& scene) - : name{ std::move(name) }, - scene{ std::move(scene) } { } + RawPush(std::string name_a, std::unique_ptr&& scene_a) + : name{ std::move(name_a) }, + scene{ std::move(scene_a) } { } }; struct Pop { }; diff --git a/src/scenes/settings_menu/settings_menu.cpp b/src/scenes/settings_menu/settings_menu.cpp index 01d62b275..b0982dc62 100644 --- a/src/scenes/settings_menu/settings_menu.cpp +++ b/src/scenes/settings_menu/settings_menu.cpp @@ -85,8 +85,8 @@ namespace scenes { service_provider->music_manager().add_volume_listener( listener_name, [this, scroll_layout_index, slider_index](std::optional) { - auto* scroll_layout = this->m_main_layout.get(scroll_layout_index); - scroll_layout->get(slider_index)->on_change(); + auto* volume_scroll_layout = this->m_main_layout.get(scroll_layout_index); + volume_scroll_layout->get(slider_index)->on_change(); if (auto volume = this->m_service_provider->music_manager().get_volume(); volume.has_value()) { this->m_settings.volume = static_cast(volume.value()); diff --git a/src/ui/layouts/scroll_layout.cpp b/src/ui/layouts/scroll_layout.cpp index 8e46ce698..ddeda9082 100644 --- a/src/ui/layouts/scroll_layout.cpp +++ b/src/ui/layouts/scroll_layout.cpp @@ -3,7 +3,7 @@ #include "input/input.hpp" #include "scroll_layout.hpp" -ui::ItemSize::ItemSize(const u32 height, ItemSizeType type) : height{ height }, type{ type } { } +ui::ItemSize::ItemSize(const u32 height_a, ItemSizeType type_a) : height{ height_a }, type{ type_a } { } [[nodiscard]] u32 ui::ItemSize::get_height() const { @@ -14,34 +14,36 @@ ui::ItemSize::ItemSize(const u32 height, ItemSizeType type) : height{ height }, return type; } -ui::AbsolutItemSize::AbsolutItemSize(const u32 height) : ItemSize{ height, ItemSizeType::Absolut } { } +ui::AbsolutItemSize::AbsolutItemSize(const u32 height_a) : ItemSize{ height_a, ItemSizeType::Absolut } { } -ui::RelativeItemSize::RelativeItemSize(const shapes::URect& rect, const double height) - : ItemSize{ static_cast(height * rect.height()), ItemSizeType::Relative } { +ui::RelativeItemSize::RelativeItemSize(const shapes::URect& rect, const double height_d) + : ItemSize{ static_cast(height_d * rect.height()), ItemSizeType::Relative } { // no checks for upper cases, since it theoretically can also be larger than the whole screen! - assert(height >= 0.0 && "height has to be in correct percentage range!"); + assert(height_d >= 0.0 && "height has to be in correct percentage range!"); } -ui::RelativeItemSize::RelativeItemSize(const Window* window, const double height) - : RelativeItemSize{ window->screen_rect(), height } { } -ui::RelativeItemSize::RelativeItemSize(const Window& window, const double height) - : RelativeItemSize{ window.screen_rect(), height } { } -ui::RelativeItemSize::RelativeItemSize(const Layout& layout, const double height) - : RelativeItemSize{ layout.get_rect(), height } { } +ui::RelativeItemSize::RelativeItemSize(const Window* window, const double height_d) + : RelativeItemSize{ window->screen_rect(), height_d } { } +ui::RelativeItemSize::RelativeItemSize(const Window& window, const double height_d) + : RelativeItemSize{ window.screen_rect(), height_d } { } +ui::RelativeItemSize::RelativeItemSize(const Layout& layout, const double height_d) + : RelativeItemSize{ layout.get_rect(), height_d } { } ui::ScrollLayout::ScrollLayout( - ServiceProvider* service_provider, - u32 focus_id, - Margin gap, - std::pair margin, - const Layout& layout, - bool is_top_level - ) - : FocusLayout{ - layout, focus_id, FocusOptions{ .wrap_around=is_top_level, .allow_tab=is_top_level }, is_top_level}, // if on top, we support tab and wrap around, otherwise not - m_gap{ gap }, - m_texture{ std::nullopt }, - m_service_provider{ service_provider }, - m_step_size{ static_cast(layout.get_rect().height() * 0.05) } { + ServiceProvider* service_provider, + u32 focus_id, + Margin gap, + std::pair margin, + const Layout& layout, + bool is_top_level +) + : FocusLayout{ + layout, focus_id, FocusOptions{ .wrap_around = is_top_level, .allow_tab = is_top_level }, + is_top_level +}, // if on top, we support tab and wrap around, otherwise not + m_gap{ gap }, + m_texture{ std::nullopt }, + m_service_provider{ service_provider }, + m_step_size{ static_cast(layout.get_rect().height() * 0.05) } { const auto layout_rect = layout.get_rect(); const auto absolut_margin = std::pair{ static_cast(margin.first * layout_rect.width()), diff --git a/src/ui/layouts/scroll_layout.hpp b/src/ui/layouts/scroll_layout.hpp index c4f29eace..eac77ad2c 100644 --- a/src/ui/layouts/scroll_layout.hpp +++ b/src/ui/layouts/scroll_layout.hpp @@ -20,7 +20,7 @@ namespace ui { ItemSizeType type; protected: - ItemSize(u32 height, ItemSizeType type); + ItemSize(u32 height_a, ItemSizeType type_a); public: [[nodiscard]] OOPETRIS_GRAPHICS_EXPORTED u32 get_height() const; @@ -29,15 +29,15 @@ namespace ui { }; struct AbsolutItemSize : public ItemSize { - OOPETRIS_GRAPHICS_EXPORTED explicit AbsolutItemSize(u32 height); + OOPETRIS_GRAPHICS_EXPORTED explicit AbsolutItemSize(u32 height_a); }; struct RelativeItemSize : public ItemSize { - OOPETRIS_GRAPHICS_EXPORTED RelativeItemSize(const shapes::URect& rect, double height); - OOPETRIS_GRAPHICS_EXPORTED RelativeItemSize(const Window* window, double height); - OOPETRIS_GRAPHICS_EXPORTED RelativeItemSize(const Window& window, double height); - OOPETRIS_GRAPHICS_EXPORTED RelativeItemSize(const Layout& layout, double height); + OOPETRIS_GRAPHICS_EXPORTED RelativeItemSize(const shapes::URect& rect, double height_d); + OOPETRIS_GRAPHICS_EXPORTED RelativeItemSize(const Window* window, double height_d); + OOPETRIS_GRAPHICS_EXPORTED RelativeItemSize(const Window& window, double height_d); + OOPETRIS_GRAPHICS_EXPORTED RelativeItemSize(const Layout& layout, double height_d); }; diff --git a/subprojects/cpp-httplib.wrap b/subprojects/cpp-httplib.wrap index 1bfbded97..8a2a56cd1 100644 --- a/subprojects/cpp-httplib.wrap +++ b/subprojects/cpp-httplib.wrap @@ -1,11 +1,10 @@ [wrap-file] -directory = cpp-httplib-0.25.0 -source_url = https://github.com/yhirose/cpp-httplib/archive/refs/tags/v0.25.0.tar.gz -source_filename = cpp-httplib-0.25.0.tar.gz -source_hash = ac7c59fa72325d4cb9f73af266312d82632ac35a5c4c8a1be620c1f946ec9cea -source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/cpp-httplib_0.25.0-1/cpp-httplib-0.25.0.tar.gz -wrapdb_version = 0.25.0-1 -diff_files = cpp-httplib-0.25.0_mingw.diff +directory = cpp-httplib-0.51.0 +source_url = https://github.com/yhirose/cpp-httplib/archive/refs/tags/v0.51.0.tar.gz +source_filename = cpp-httplib-0.51.0.tar.gz +source_hash = d740ced75352f44e9d66d08806dc231b5621bb3592b5a5d5b2bd890a9a9d86cc +source_fallback_url = https://wrapdb.mesonbuild.com/v2/cpp-httplib_0.51.0-1/get_source/cpp-httplib-0.51.0.tar.gz +wrapdb_version = 0.51.0-1 [provide] -cpp-httplib = cpp_httplib_dep +dependency_names = cpp-httplib diff --git a/subprojects/discord-social-sdk.wrap b/subprojects/discord-social-sdk.wrap index 0122eb3c7..b14fd15c6 100644 --- a/subprojects/discord-social-sdk.wrap +++ b/subprojects/discord-social-sdk.wrap @@ -1,10 +1,10 @@ [wrap-file] directory = discord_social_sdk -source_url = https://oopetris.totto.lt/static/assets/discord/DiscordSocialSdk-1.4.9649.zip -source_filename = DiscordSocialSdk-1.4.9649.zip -source_hash = 55af4030abf3286ee0a8e562c30cd839a605063eb5e987aea110bfc81bc39312 +source_url = https://oopetris.totto.lt/static/assets/discord/DiscordSocialSdk-1.10.18247.zip +source_filename = DiscordSocialSdk-1.10.18247.zip +source_hash = 505bfba1a8ae3277ff2f8a04f586d39f8f22ab31467a702a540901ab1253e857 patch_directory = discord_social_sdk -diff_files = discord_social_sdk-1.4.9649_mingw.diff +diff_files = discord_social_sdk-1.10.18247_mingw.diff [provide] discord-social-sdk = discord_social_sdk_dep diff --git a/subprojects/packagefiles/cpp-httplib-0.25.0_mingw.diff b/subprojects/packagefiles/cpp-httplib-0.26.0_mingw.diff similarity index 100% rename from subprojects/packagefiles/cpp-httplib-0.25.0_mingw.diff rename to subprojects/packagefiles/cpp-httplib-0.26.0_mingw.diff diff --git a/subprojects/packagefiles/discord_social_sdk-1.4.9649_mingw.diff b/subprojects/packagefiles/discord_social_sdk-1.10.18247_mingw.diff similarity index 100% rename from subprojects/packagefiles/discord_social_sdk-1.4.9649_mingw.diff rename to subprojects/packagefiles/discord_social_sdk-1.10.18247_mingw.diff diff --git a/subprojects/packagefiles/discord_social_sdk/meson.build b/subprojects/packagefiles/discord_social_sdk/meson.build index d16b6b897..a37e38c6b 100644 --- a/subprojects/packagefiles/discord_social_sdk/meson.build +++ b/subprojects/packagefiles/discord_social_sdk/meson.build @@ -2,7 +2,7 @@ project( 'discord-social-sdk', 'cpp', 'c', - version: '1.4.9649', + version: '1.10.18247', meson_version: '>=1.4.0', default_options: { 'cpp_std': ['c++17'], @@ -66,6 +66,8 @@ if not meson.is_cross_build() elif host_machine.system() == 'windows' if host_machine.cpu_family() == 'x86_64' lib_base_dir = get_option('default_library') == 'static' ? 'bin' : 'lib' + elif host_machine.cpu_family() == 'aarch64' + lib_base_dir = (get_option('default_library') == 'static' ? 'bin' : 'lib') / 'arm64' else error('unsupported architecture for windows: ' + host_machine.cpu_family()) endif @@ -85,6 +87,21 @@ if not meson.is_cross_build() required: true, ) + + if host_machine.system() == 'linux' + install_lib_dir = get_option('prefix') / get_option('libdir') + + discord_partner_sdk_file = files( + meson.project_source_root() / lib_dir / 'libdiscord_partner_sdk.so' + ) + + install_data( + discord_partner_sdk_file, + install_dir: install_lib_dir, + install_tag: 'runtime', + ) + endif + ## NOTE: this is a static library, as it doesn't export the symbols correctly, so on windows the dll would fail to link discord_social_sdk_lib = static_library( 'discord_social_sdk', diff --git a/subprojects/packagefiles/expected-1.1.0_installable.diff b/subprojects/packagefiles/expected-1.3.1_installable.diff similarity index 100% rename from subprojects/packagefiles/expected-1.1.0_installable.diff rename to subprojects/packagefiles/expected-1.3.1_installable.diff diff --git a/subprojects/packagefiles/spdlog_1.17.0_std_format_detection_fix.diff b/subprojects/packagefiles/spdlog_1.17.0_std_format_detection_fix.diff new file mode 100644 index 000000000..f86d0901b --- /dev/null +++ b/subprojects/packagefiles/spdlog_1.17.0_std_format_detection_fix.diff @@ -0,0 +1,22 @@ +diff --git a/meson.build b/meson.build +index c842472..92099e0 100644 +--- a/meson.build ++++ b/meson.build +@@ -3,7 +3,7 @@ project( + 'cpp', + version: '1.17.0', + license: 'MIT', +- meson_version: '>=0.56.0', ++ meson_version: '>=0.59.0', + ) + + inc = include_directories('include') +@@ -14,7 +14,7 @@ spdlog_dependencies = [thread_dep] + spdlog_compile_args = [] + override_cpp = meson.version().version_compare('>=1.3.0') ? 'cpp_std=gnu++17,c++17' : 'cpp_std=gnu++17' + +-if meson.get_compiler('cpp').has_header_symbol( ++if get_option('std_format').allowed() and meson.get_compiler('cpp').has_header_symbol( + 'format', + '__cpp_lib_format', + required: get_option('std_format'), diff --git a/subprojects/spdlog.wrap b/subprojects/spdlog.wrap index 815f8f18a..9b7b4bcf8 100644 --- a/subprojects/spdlog.wrap +++ b/subprojects/spdlog.wrap @@ -9,7 +9,7 @@ patch_url = https://wrapdb.mesonbuild.com/v2/spdlog_1.17.0-1/get_patch patch_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/spdlog_1.17.0-1/spdlog_1.17.0-1_patch.zip patch_hash = 295bcca990facdca84256b60aaa86ba2e2320895cad30bee997d7a463a30b40c wrapdb_version = 1.17.0-1 -diff_files = spdlog_1.17.0_fmt_12.0.0_compatibility.diff, spdlog_1.17.0_no_tls_option.diff, spdlog_1.17.0_nintendo_time_fix.diff +diff_files = spdlog_1.17.0_fmt_12.0.0_compatibility.diff, spdlog_1.17.0_no_tls_option.diff, spdlog_1.17.0_nintendo_time_fix.diff, spdlog_1.17.0_std_format_detection_fix.diff [provide] diff --git a/subprojects/tl-expected.wrap b/subprojects/tl-expected.wrap index 0f6610fec..0122fcda8 100644 --- a/subprojects/tl-expected.wrap +++ b/subprojects/tl-expected.wrap @@ -8,8 +8,7 @@ patch_filename = tl-expected_1.3.1-1_patch.zip patch_url = https://wrapdb.mesonbuild.com/v2/tl-expected_1.3.1-1/get_patch patch_hash = 91cfeae04ba6ea05792e68a37781236a7045b9e2e4e0c8b7093fd8c3e43b0bad wrapdb_version = 1.3.1-1 - -diff_files = expected-1.1.0_installable.diff +diff_files = expected-1.3.1_installable.diff [provide] dependency_names = tl-expected diff --git a/tests/core/color.cpp b/tests/core/color.cpp index ae4b42a12..b6d8c1d4e 100644 --- a/tests/core/color.cpp +++ b/tests/core/color.cpp @@ -35,18 +35,18 @@ operator==(const HSVColor& value1, const HSVColor& value2) { //NOLINT(misc-use-i // make colors printable -void PrintTo(const Color& color, std::ostream* os) { //NOLINT(misc-use-internal-linkage) +static void PrintTo(const Color& color, std::ostream* os) { //NOLINT(misc-use-internal-linkage) *os << color.to_string(); } -void PrintTo(const HSVColor& color, std::ostream* os) { //NOLINT(misc-use-internal-linkage) +static void PrintTo(const HSVColor& color, std::ostream* os) { //NOLINT(misc-use-internal-linkage) *os << color.to_string(); } namespace color { - void PrintTo(const SerializeMode& value, std::ostream* os) { //NOLINT(misc-use-internal-linkage) + static void PrintTo(const SerializeMode& value, std::ostream* os) { //NOLINT(misc-use-internal-linkage) *os << magic_enum::enum_name(value); } diff --git a/tests/graphics/sdl_key.cpp b/tests/graphics/sdl_key.cpp index 26c610ba2..e14e6e152 100644 --- a/tests/graphics/sdl_key.cpp +++ b/tests/graphics/sdl_key.cpp @@ -13,12 +13,12 @@ namespace sdl { // make keys printable - void PrintTo(const Key& key, std::ostream* os) { //NOLINT(misc-use-internal-linkage) + static void PrintTo(const Key& key, std::ostream* os) { //NOLINT(misc-use-internal-linkage) *os << key.to_string(); } - std::ostream& operator<<(std::ostream& os, const Key& value) { //NOLINT(misc-use-internal-linkage) + static std::ostream& operator<<(std::ostream& os, const Key& value) { //NOLINT(misc-use-internal-linkage) os << value.to_string(); return os; } diff --git a/tools/dependencies/meson.build b/tools/dependencies/meson.build index e05e6e115..fe1056e47 100644 --- a/tools/dependencies/meson.build +++ b/tools/dependencies/meson.build @@ -378,16 +378,44 @@ if build_application spdlog_no_tls = false + if (meson.is_cross_build() and host_machine.system() == '3ds') spdlog_no_tls = true endif + spdlog_std_format = 'auto' + + if not cpp.has_header_symbol( + 'format', + '__cpp_lib_format', + args: core_lib.get('compile_args'), + ) or not cpp.compiles( + ''' + #include + int main(void) { + /* If it's not defined as a macro, try to use as a symbol */ + #ifndef __cpp_lib_format + __cpp_lib_format; + #else + #if __cpp_lib_format < 202207L + #error "fmt not supported" + #endif + #endif + return 0; + } + ''', + args: core_lib.get('compile_args'), + ) + spdlog_std_format = 'disabled' + endif + spdlog_dep = dependency( 'spdlog', required: true, default_options: { 'tests': 'disabled', 'no_tls': spdlog_no_tls, + 'std_format': spdlog_std_format, }, ) graphics_lib += { @@ -399,8 +427,12 @@ if build_application required: false, allow_fallback: true, default_options: { - 'openssl': 'enabled', + 'tls': 'enabled', + 'tls_backend': 'openssl', 'zlib': 'enabled', + 'brotli': 'auto', + 'zstd': 'auto', + 'test': false, }, ) diff --git a/tools/options/meson.build b/tools/options/meson.build index 2071d2f80..e34af035f 100644 --- a/tools/options/meson.build +++ b/tools/options/meson.build @@ -1,15 +1,86 @@ oopetris_author = 'Coder2k' oopetris_name = 'OOPetris' +cpp = meson.get_compiler('cpp') + +internal_cpp_compiler_args = cpp.get_supported_arguments( + '-Wassign-enum', + '-Wenum-conversion', + '-Wenum-switch', + '-fstrict-enums', + '-Wenum-identifier', + '-Wenum-compare', + '-Wenum-enum-conversion', + '-Wenum-float-conversion', + '-Wenum-too-large', + '-Wenum-compare-switch', + '-Wenum-compare-conditional', + '-fno-strict-aliasing', + '-Wpointer-arith', + '-Wmissing-declarations', + '-Wformat=2', + '-Wstrict-prototypes', + '-Wmissing-prototypes', + '-Wnested-externs', + '-Wold-style-definition', + '-Wundef', + '-Wunused', + '-Wcast-align', + '-Wmissing-format-attribute', + '-Wmissing-include-dirs', + '-Wlogical-op', + '-Wignored-qualifiers', + '-Werror=redundant-decls', + '-Werror=implicit', + '-Werror=nonnull', + '-Werror=init-self', + '-Werror=main', + '-Werror=missing-braces', + '-Werror=sequence-point', + '-Werror=return-type', + '-Werror=trigraphs', + '-Werror=array-bounds', + '-Werror=write-strings', + '-Werror=address', + '-Werror=int-to-pointer-cast', + '-Werror=pointer-to-int-cast', + '-Werror=empty-body', + '-Werror=write-strings', + '-Werror=strict-aliasing', + '-Wno-sign-compare', + '-Wno-cast-function-type', + '-Wno-unused-parameter', + '-Wno-missing-field-initializers', + '-Wno-type-limits', + '-Wshadow', + '-Wfloat-conversion', +) + +common_cpp_compiler_args = [] + +foreach internal_cpp_compiler_arg : internal_cpp_compiler_args + + # cpp.get_supported_arguments reports true, but it is not really smart and the actual compiler doesn't accept this :( + ##TODO: maybe file a meson bug? + if internal_cpp_compiler_arg not in ['-Werror=implicit', '-Werror=pointer-to-int-cast'] + common_cpp_compiler_args += internal_cpp_compiler_arg + endif + +endforeach + +if cpp.get_id() == 'gcc' + common_cpp_compiler_args += cpp.get_supported_arguments('-Wno-missing-braces') +endif + core_lib = { 'inc_dirs': [], - 'compile_args': ['-DOOPETRIS_VERSION=' + meson.project_version()], + 'compile_args': ['-DOOPETRIS_VERSION=' + meson.project_version()] + common_cpp_compiler_args, 'deps': [], } recordings_lib = { 'inc_dirs': [], - 'compile_args': [], + 'compile_args': [] + common_cpp_compiler_args, 'deps': [], } @@ -19,7 +90,7 @@ graphics_lib = { '-DOOPETRIS_VERSION=' + meson.project_version(), '-DOOPETRIS_NAME=' + oopetris_name, '-DOOPETRIS_AUTHOR=' + oopetris_author, - ], + ] + common_cpp_compiler_args, 'deps': [], } @@ -266,6 +337,8 @@ elif cpp.get_id() == 'clang' endif + message('Building C++ with libc++') + else # TODO: once clang with libstdc++ (gcc c++ stdlib) supports std::expected, remove this special behaviour allow_tl_expected_fallback = true diff --git a/wrapper/java b/wrapper/java index 209d69fee..a747e4c33 160000 --- a/wrapper/java +++ b/wrapper/java @@ -1 +1 @@ -Subproject commit 209d69fee297430461f39d633c7c1160df823816 +Subproject commit a747e4c33e6a67b346ece586299b377a751a0103