From c809738f8b21453585f6119aee3872c902c420cb Mon Sep 17 00:00:00 2001 From: scawful Date: Sat, 11 Oct 2025 14:57:11 -0400 Subject: [PATCH] feat(cmake): enable export of compile commands for LSP support - Added option to export compile commands for clangd and other Language Server Protocol (LSP) tools by setting CMAKE_EXPORT_COMPILE_COMMANDS to ON in CMake. - Updated yaze_test.cc to conditionally include ImGui test engine headers based on the YAZE_ENABLE_IMGUI_TEST_ENGINE flag, improving modularity and organization. Benefits: - Enhanced development experience with better integration of LSP tools. - Improved code organization by managing includes based on feature flags. --- CMakeLists.txt | 3 +++ test/yaze_test.cc | 22 +++++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fa71f68f..c0085d71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,6 +90,9 @@ endif() option(YAZE_SUPPRESS_WARNINGS "Suppress compiler warnings (use -v preset suffix for verbose)" ON) set(YAZE_TEST_ROM_PATH "${CMAKE_BINARY_DIR}/bin/zelda3.sfc" CACHE STRING "Path to test ROM file") +# Export compile commands for clangd/LSP +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + # Platform detection if(CMAKE_SYSTEM_NAME MATCHES "Darwin") set(YAZE_PLATFORM_MACOS ON) diff --git a/test/yaze_test.cc b/test/yaze_test.cc index d19aa743..0b6de14e 100644 --- a/test/yaze_test.cc +++ b/test/yaze_test.cc @@ -17,14 +17,14 @@ #include "imgui/imgui.h" #include "imgui/backends/imgui_impl_sdl2.h" #include "imgui/backends/imgui_impl_sdlrenderer2.h" -#include "imgui_test_engine/imgui_te_context.h" -#include "imgui_test_engine/imgui_te_engine.h" -#include "imgui_test_engine/imgui_te_ui.h" #include "app/core/window.h" #include "app/core/controller.h" #include "app/gfx/backend/sdl2_renderer.h" #ifdef YAZE_ENABLE_IMGUI_TEST_ENGINE +#include "imgui_test_engine/imgui_te_context.h" +#include "imgui_test_engine/imgui_te_engine.h" +#include "imgui_test_engine/imgui_te_ui.h" #include "e2e/canvas_selection_test.h" #include "e2e/framework_smoke_test.h" #include "e2e/dungeon_editor_smoke_test.h" @@ -299,6 +299,9 @@ int main(int argc, char* argv[]) { ImGui_ImplSDL2_InitForSDLRenderer(window.window_.get(), sdl_renderer); ImGui_ImplSDLRenderer2_Init(sdl_renderer); + yaze::core::Controller controller; + +#ifdef YAZE_ENABLE_IMGUI_TEST_ENGINE // Setup test engine ImGuiTestEngine* engine = ImGuiTestEngine_CreateContext(); ImGuiTestEngineIO& test_io = ImGuiTestEngine_GetIO(engine); @@ -311,10 +314,6 @@ int main(int argc, char* argv[]) { if (config.test_speed == ImGuiTestRunSpeed_Normal) speed_name = "Normal"; else if (config.test_speed == ImGuiTestRunSpeed_Cinematic) speed_name = "Cinematic"; std::cout << "Running tests in " << speed_name << " mode" << std::endl; - - yaze::core::Controller controller; - -#ifdef YAZE_ENABLE_IMGUI_TEST_ENGINE // Register smoke test ImGuiTest* smoke_test = IM_REGISTER_TEST(engine, "E2ETest", "FrameworkSmokeTest"); smoke_test->TestFunc = E2ETest_FrameworkSmokeTest; @@ -350,9 +349,11 @@ int main(int argc, char* argv[]) { ImGui::NewFrame(); // Render the UI +#ifdef YAZE_ENABLE_IMGUI_TEST_ENGINE if (config.show_gui) { ImGuiTestEngine_ShowTestEngineWindows(engine, &config.show_gui); } +#endif controller.DoRender(); // End the Dear ImGui frame @@ -370,10 +371,13 @@ int main(int argc, char* argv[]) { SDL_GL_MakeCurrent(backup_current_window, backup_current_context); } +#ifdef YAZE_ENABLE_IMGUI_TEST_ENGINE // Run test engine ImGuiTestEngine_PostSwap(engine); +#endif } +#ifdef YAZE_ENABLE_IMGUI_TEST_ENGINE // Get test result ImGuiTestEngineResultSummary summary; ImGuiTestEngine_GetResultSummary(engine, &summary); @@ -382,6 +386,10 @@ int main(int argc, char* argv[]) { // Cleanup controller.OnExit(); ImGuiTestEngine_DestroyContext(engine); +#else + int result = 0; + controller.OnExit(); +#endif ImGui_ImplSDLRenderer2_Shutdown(); ImGui_ImplSDL2_Shutdown(); ImGui::DestroyContext();