Update CMake configuration and .clangd settings for improved build management
- Removed unnecessary compile flags from .clangd to streamline configuration. - Added YAZE_BUILD_LIB option in CMakeLists.txt for conditional library building in minimal builds. - Enhanced SDL2 CMake configuration to set include directories for bundled SDL, ensuring proper integration. - Updated test CMakeLists.txt to conditionally link yaze_c and ImGuiTestEngine based on build options, improving modularity and flexibility. - Refactored test_editor.cc and test_editor.h to conditionally include ImGuiTestEngine headers and manage engine initialization based on availability.
This commit is contained in:
@@ -46,7 +46,6 @@ add_executable(
|
||||
zelda3/test_dungeon_objects.cc
|
||||
${ASAR_STATIC_SRC}
|
||||
${IMGUI_SRC}
|
||||
${IMGUI_TEST_ENGINE_SOURCES}
|
||||
${YAZE_SRC_FILES}
|
||||
)
|
||||
|
||||
@@ -78,9 +77,13 @@ target_link_libraries(
|
||||
${PNG_LIBRARIES}
|
||||
${OPENGL_LIBRARIES}
|
||||
${CMAKE_DL_LIBS}
|
||||
yaze_c
|
||||
)
|
||||
|
||||
# Conditionally link yaze_c only when library is built
|
||||
if(YAZE_BUILD_LIB)
|
||||
target_link_libraries(extract_vanilla_values yaze_c)
|
||||
endif()
|
||||
|
||||
target_include_directories(
|
||||
yaze_test PUBLIC
|
||||
app/
|
||||
@@ -103,14 +106,23 @@ target_link_libraries(
|
||||
${PNG_LIBRARIES}
|
||||
${OPENGL_LIBRARIES}
|
||||
${CMAKE_DL_LIBS}
|
||||
yaze_c
|
||||
ImGuiTestEngine
|
||||
ImGui
|
||||
gmock_main
|
||||
gmock
|
||||
gtest_main
|
||||
gtest
|
||||
)
|
||||
|
||||
# Conditionally link yaze_c only when library is built
|
||||
if(YAZE_BUILD_LIB)
|
||||
target_link_libraries(yaze_test yaze_c)
|
||||
endif()
|
||||
|
||||
# Conditionally link ImGuiTestEngine only when UI tests are enabled
|
||||
if(YAZE_ENABLE_UI_TESTS)
|
||||
target_link_libraries(yaze_test ${IMGUI_TEST_ENGINE_TARGET})
|
||||
target_compile_definitions(yaze_test PRIVATE ${IMGUI_TEST_ENGINE_DEFINITIONS})
|
||||
endif()
|
||||
# ROM Testing Configuration
|
||||
if(YAZE_ENABLE_ROM_TESTS)
|
||||
target_compile_definitions(yaze_test PRIVATE
|
||||
@@ -119,7 +131,7 @@ if(YAZE_ENABLE_ROM_TESTS)
|
||||
)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(yaze_test PRIVATE "IMGUI_ENABLE_TEST_ENGINE")
|
||||
# ImGui Test Engine definitions are now handled conditionally above
|
||||
|
||||
# Platform-specific definitions
|
||||
if(UNIX AND NOT APPLE)
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "testing.h"
|
||||
#include "yaze.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace test {
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
#include "imgui/backends/imgui_impl_sdl2.h"
|
||||
#include "imgui/backends/imgui_impl_sdlrenderer2.h"
|
||||
#include "imgui/imgui.h"
|
||||
|
||||
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||
#include "imgui_test_engine/imgui_te_context.h"
|
||||
#include "imgui_test_engine/imgui_te_engine.h"
|
||||
#include "imgui_test_engine/imgui_te_imconfig.h"
|
||||
#include "imgui_test_engine/imgui_te_ui.h"
|
||||
#endif
|
||||
|
||||
namespace yaze {
|
||||
namespace test {
|
||||
@@ -25,13 +28,19 @@ absl::Status TestEditor::Update() {
|
||||
|
||||
static bool show_demo_window = true;
|
||||
|
||||
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||
ImGuiTestEngine_ShowTestEngineWindows(engine_, &show_demo_window);
|
||||
#else
|
||||
ImGui::Text("ImGui Test Engine not available in this build");
|
||||
(void)show_demo_window; // Suppress unused variable warning
|
||||
#endif
|
||||
|
||||
ImGui::End();
|
||||
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||
void TestEditor::RegisterTests(ImGuiTestEngine* engine) {
|
||||
engine_ = engine;
|
||||
ImGuiTest* test = IM_REGISTER_TEST(engine, "demo_test", "test1");
|
||||
@@ -41,6 +50,7 @@ void TestEditor::RegisterTests(ImGuiTestEngine* engine) {
|
||||
ctx->ItemCheck("Node/Checkbox");
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO: Fix the window/controller management
|
||||
int RunIntegrationTest() {
|
||||
@@ -50,11 +60,15 @@ int RunIntegrationTest() {
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
|
||||
// Initialize Test Engine
|
||||
// Initialize Test Engine (if available)
|
||||
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||
ImGuiTestEngine* engine = ImGuiTestEngine_CreateContext();
|
||||
ImGuiTestEngineIO& test_io = ImGuiTestEngine_GetIO(engine);
|
||||
test_io.ConfigVerboseLevel = ImGuiTestVerboseLevel_Info;
|
||||
test_io.ConfigVerboseLevelOnError = ImGuiTestVerboseLevel_Debug;
|
||||
#else
|
||||
void* engine = nullptr; // Placeholder when test engine is disabled
|
||||
#endif
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
|
||||
@@ -65,8 +79,10 @@ int RunIntegrationTest() {
|
||||
ImGui_ImplSDLRenderer2_Init(yaze::core::Renderer::Get().renderer());
|
||||
|
||||
yaze::test::TestEditor test_editor;
|
||||
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||
test_editor.RegisterTests(engine);
|
||||
ImGuiTestEngine_Start(engine, ImGui::GetCurrentContext());
|
||||
#endif
|
||||
controller.set_active(true);
|
||||
|
||||
// Set the default style
|
||||
@@ -85,7 +101,9 @@ int RunIntegrationTest() {
|
||||
controller.DoRender();
|
||||
}
|
||||
|
||||
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||
ImGuiTestEngine_Stop(engine);
|
||||
#endif
|
||||
controller.OnExit();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,11 @@
|
||||
#define YAZE_TEST_INTEGRATION_TEST_EDITOR_H
|
||||
|
||||
#include "app/editor/editor.h"
|
||||
|
||||
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||
#include "imgui_test_engine/imgui_te_context.h"
|
||||
#include "imgui_test_engine/imgui_te_engine.h"
|
||||
#endif
|
||||
|
||||
namespace yaze {
|
||||
namespace test {
|
||||
@@ -44,10 +47,16 @@ class TestEditor : public yaze::editor::Editor {
|
||||
return absl::UnimplementedError("Not implemented");
|
||||
}
|
||||
|
||||
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||
void RegisterTests(ImGuiTestEngine* engine);
|
||||
#endif
|
||||
|
||||
private:
|
||||
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||
ImGuiTestEngine* engine_;
|
||||
#else
|
||||
void* engine_; // Placeholder when test engine is disabled
|
||||
#endif
|
||||
};
|
||||
|
||||
int RunIntegrationTest();
|
||||
|
||||
Reference in New Issue
Block a user