Skip to content

Work with modern GCC#151

Open
scivision wants to merge 6 commits intoplibither8:masterfrom
fortran-gaming:de
Open

Work with modern GCC#151
scivision wants to merge 6 commits intoplibither8:masterfrom
fortran-gaming:de

Conversation

@scivision
Copy link
Contributor

  • apply warning flags to debug builds - avoids problem with new compiler and flag bugs
  • simplify CI settings by using JSON
  • use std::filesystem canonically
  • consistent use of "class point2D_t;" this was stopping GCC from building

Copilot AI review requested due to automatic review settings March 2, 2026 22:22
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the project build/configuration to better support modern GCC and simplifies CI by switching to CMake presets/workflows, along with a few C++ source fixes/cleanups.

Changes:

  • Add CMakePresets.json and update CI to use cmake --workflow instead of the old ctest -S setup.cmake.
  • Adjust warning flags to apply to Debug/RelWithDebInfo builds and update install rules in CMakeLists.txt.
  • Modernize some C++ code paths (filesystem usage, error handling), and fix point2D_t forward declaration consistency.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/saveresource.cpp Uses std::filesystem for save path + directory creation and adds basic error reporting.
src/loadresource.cpp Comment whitespace/formatting adjustments only.
src/headers/gameboard.hpp Forward declaration updated to class point2D_t; to match definition.
src/global.cpp Wraps system("clear"/"cls") to report failure.
setup.cmake Removed legacy CTest script-based CI entry point.
meson.build Removed Meson build configuration.
CMakePresets.json Adds configure/build/test/workflow presets for Debug/Release pipelines.
CMakeLists.txt Updates compiler warning flags and modifies install behavior/paths.
.github/workflows/ci.yml Switches CI to CMake workflow presets and expands trigger paths.
Comments suppressed due to low confidence (1)

meson.build:1

  • Removing meson.build drops Meson as a supported build system; the PR description doesn't mention this deprecation/removal. Either keep Meson support or explicitly note the removal (and any migration guidance) in the PR description/README to avoid surprising downstream users.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

const auto path_to_file_gd_state = "../data/SavedGameFiles/" + filename;
std::remove(path_to_file_gd_state.c_str());
const auto path_to_file_gd_state = directory_path / filename;
std::filesystem::remove(path_to_file_gd_state);
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

std::filesystem::remove(path_to_file_gd_state) can throw std::filesystem::filesystem_error on permissions/IO issues. Since this function already uses std::error_code for create_directories, use the remove(path, ec) overload (or catch exceptions) to avoid terminating the program when deletion fails.

Suggested change
std::filesystem::remove(path_to_file_gd_state);
std::filesystem::remove(path_to_file_gd_state, ec);
if (ec) {
std::cerr << path_to_file_gd_state << " " << ec.message() << "\n";
return;
}

Copilot uses AI. Check for mistakes.
Comment on lines +58 to +63
if(system("cls")) {
#else
system("clear");
if(system("clear")) {
#endif
std::cerr << "Failed to clear screen: " << std::error_code(errno, std::generic_category()).message() << "\n";
}
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

system() failure reporting here is misleading: a non-zero return value usually indicates the command exited with an error status and does not necessarily set errno. Capture the return code from system() and report it (and only consult errno when system() returns -1).

Copilot uses AI. Check for mistakes.

install(TARGETS 2048
RUNTIME DESTINATION bin)
install(TARGETS 2048)
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

install(TARGETS 2048) no longer specifies destinations; CMake will install into the default/current directory under the prefix, which changes the previously explicit RUNTIME DESTINATION bin behavior. Specify destinations (e.g., RUNTIME/BUNDLE/LIBRARY/ARCHIVE) to keep installs predictable across platforms.

Suggested change
install(TARGETS 2048)
install(TARGETS 2048
RUNTIME DESTINATION bin)

Copilot uses AI. Check for mistakes.
- "**.hpp"
- "**.cmake"
- "**/CMakeLists.txt"
- ".github/workflows/ci.yml"
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

The push path filter does not include CMakePresets.json, so changes to presets/workflows won't trigger CI on push. Add CMakePresets.json (and any other build config files you rely on) to the on.push.paths list if you want CI to validate those changes.

Suggested change
- ".github/workflows/ci.yml"
- ".github/workflows/ci.yml"
- "CMakePresets.json"

Copilot uses AI. Check for mistakes.
- uses: actions/checkout@v2
- &checkout
uses: actions/checkout@v6

Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

CI uses cmake --workflow ..., which requires a relatively recent CMake with workflow preset support. Ensure the GitHub runners' CMake meets that requirement (or add a setup step to install/pin a suitable CMake version), otherwise the workflow may start failing without any code changes.

Suggested change
- uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.27.0'

Copilot uses AI. Check for mistakes.
Comment on lines +104 to +107
const auto path_to_file_gd_state = directory_path / filename;
std::filesystem::remove(path_to_file_gd_state);

saveToFilePreviousGameStateData(path_to_file_gd_state, gb);
saveToFilePreviousGameStateData(path_to_file_gd_state.string(), gb);
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

directory_path / filename will ignore directory_path when filename is an absolute path (or contains a root name), which lets user input save/remove files outside ../data/SavedGameFiles/. Since the filename comes from stdin, restrict it to a relative basename (or reject absolute paths / parent traversal) before constructing the filesystem path.

Copilot uses AI. Check for mistakes.

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data
DESTINATION ${CMAKE_INSTALL_PREFIX})
DESTINATION ${CMAKE_INSTALL_PREFIX}/data)
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

DESTINATION ${CMAKE_INSTALL_PREFIX}/data bakes the configured install prefix into the install rules and ignores cmake --install --prefix ... (and may attempt to install into a system location). Use a relative destination like DESTINATION data (or DESTINATION .) so the chosen prefix at install time is respected.

Suggested change
DESTINATION ${CMAKE_INSTALL_PREFIX}/data)
DESTINATION data)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants