From e523ce94da81c2b6edc264cd76b1107d298501fe Mon Sep 17 00:00:00 2001 From: scawful Date: Sat, 11 Oct 2025 13:29:24 -0400 Subject: [PATCH] chore(cmake): enhance test support linkage and file dialog functionality - Improved the CMake configuration to conditionally link the yaze_test_support library for the yaze target when tests are enabled, providing clearer feedback on linkage status. - Updated the file dialog implementation to include specific filters for ROM files and all files, enhancing user experience during file selection. - Added status messages to inform users about the linkage of test support and potential issues if the target is not found. Benefits: - Enhanced clarity and maintainability of the CMake configuration. - Improved user interaction with file dialogs through better filtering options. --- src/app/app.cmake | 5 +++++ src/app/platform/file_dialog_nfd.cc | 11 ++++++----- src/app/test/test.cmake | 12 +++++------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/app/app.cmake b/src/app/app.cmake index 7ec27985..47a47f5a 100644 --- a/src/app/app.cmake +++ b/src/app/app.cmake @@ -44,6 +44,11 @@ target_link_libraries(yaze PRIVATE # Link test support if tests are enabled (yaze_editor needs TestManager) if(YAZE_BUILD_TESTS AND TARGET yaze_test_support) target_link_libraries(yaze PRIVATE yaze_test_support) + message(STATUS "✓ yaze executable linked to yaze_test_support") +else() + if(YAZE_BUILD_TESTS) + message(WARNING "yaze needs yaze_test_support but TARGET yaze_test_support not found") + endif() endif() # Platform-specific settings diff --git a/src/app/platform/file_dialog_nfd.cc b/src/app/platform/file_dialog_nfd.cc index e3c85e5d..deb4e079 100644 --- a/src/app/platform/file_dialog_nfd.cc +++ b/src/app/platform/file_dialog_nfd.cc @@ -11,7 +11,8 @@ namespace util { std::string FileDialogWrapper::ShowOpenFileDialog() { nfdchar_t* outPath = nullptr; - nfdresult_t result = NFD_OpenDialog(nullptr, nullptr, &outPath); + nfdfilteritem_t filterItem[2] = {{"ROM Files", "sfc,smc"}, {"All Files", "*"}}; + nfdresult_t result = NFD_OpenDialog(&outPath, filterItem, 2, nullptr); if (result == NFD_OKAY) { std::string path(outPath); @@ -24,7 +25,7 @@ std::string FileDialogWrapper::ShowOpenFileDialog() { std::string FileDialogWrapper::ShowOpenFolderDialog() { nfdchar_t* outPath = nullptr; - nfdresult_t result = NFD_PickFolder(nullptr, &outPath); + nfdresult_t result = NFD_PickFolder(&outPath, nullptr); if (result == NFD_OKAY) { std::string path(outPath); @@ -41,11 +42,11 @@ std::string FileDialogWrapper::ShowSaveFileDialog(const std::string& default_nam nfdfilteritem_t filterItem[1] = {{default_extension.empty() ? "All Files" : default_extension.c_str(), default_extension.empty() ? "*" : default_extension.c_str()}}; - nfdresult_t result = NFD_SaveDialog(default_extension.empty() ? nullptr : filterItem, + nfdresult_t result = NFD_SaveDialog(&outPath, + default_extension.empty() ? nullptr : filterItem, default_extension.empty() ? 0 : 1, nullptr, - default_name.c_str(), - &outPath); + default_name.c_str()); if (result == NFD_OKAY) { std::string path(outPath); diff --git a/src/app/test/test.cmake b/src/app/test/test.cmake index 5485123a..3f5f5d04 100644 --- a/src/app/test/test.cmake +++ b/src/app/test/test.cmake @@ -51,11 +51,9 @@ else() message(STATUS "○ z3ed test suites disabled (yaze_agent not built)") endif() -# Link yaze_editor back to yaze_test_support (for TestManager usage in editor_manager.cc) -# Use PRIVATE linkage to avoid propagating test dependencies to editor consumers -if(TARGET yaze_editor) - target_link_libraries(yaze_editor PRIVATE yaze_test_support) - message(STATUS "✓ yaze_editor linked to yaze_test_support for TestManager access") -endif() +message(STATUS "✓ yaze_test_support library configured") -message(STATUS "✓ yaze_test_support library configured") \ No newline at end of file +# Note: yaze_editor needs yaze_test_support for TestManager, but we can't link it here +# because this happens BEFORE yaze and yaze_emu are configured. +# Instead, each executable (yaze, yaze_emu) must explicitly link yaze_test_support +# in their respective .cmake files (app.cmake, emu.cmake). \ No newline at end of file