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:
3
.clangd
3
.clangd
@@ -3,9 +3,6 @@ CompileFlags:
|
|||||||
- -std=c++23
|
- -std=c++23
|
||||||
- -Wall
|
- -Wall
|
||||||
- -Wextra
|
- -Wextra
|
||||||
- -DYAZE_ENABLE_NFD=1
|
|
||||||
- -DYAZE_ENABLE_IMGUI_TEST_ENGINE=1
|
|
||||||
- -DYAZE_LIB_PNG=1
|
|
||||||
Remove:
|
Remove:
|
||||||
- -mllvm
|
- -mllvm
|
||||||
- -xclang
|
- -xclang
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ if(YAZE_MINIMAL_BUILD)
|
|||||||
set(YAZE_ENABLE_UI_TESTS OFF CACHE BOOL "Disabled for minimal build" FORCE)
|
set(YAZE_ENABLE_UI_TESTS OFF CACHE BOOL "Disabled for minimal build" FORCE)
|
||||||
set(YAZE_BUILD_EMU OFF CACHE BOOL "Disabled for minimal build" FORCE)
|
set(YAZE_BUILD_EMU OFF CACHE BOOL "Disabled for minimal build" FORCE)
|
||||||
set(YAZE_BUILD_Z3ED OFF CACHE BOOL "Disabled for minimal build" FORCE)
|
set(YAZE_BUILD_Z3ED OFF CACHE BOOL "Disabled for minimal build" FORCE)
|
||||||
|
set(YAZE_BUILD_LIB OFF CACHE BOOL "Disabled for minimal build" FORCE)
|
||||||
endif()
|
endif()
|
||||||
set(YAZE_TEST_ROM_PATH "${CMAKE_BINARY_DIR}/bin/zelda3.sfc" CACHE STRING "Path to test ROM file")
|
set(YAZE_TEST_ROM_PATH "${CMAKE_BINARY_DIR}/bin/zelda3.sfc" CACHE STRING "Path to test ROM file")
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,15 @@
|
|||||||
# SDL2
|
# SDL2
|
||||||
if (UNIX OR MINGW OR WIN32)
|
if (UNIX OR MINGW OR WIN32)
|
||||||
add_subdirectory(src/lib/SDL)
|
add_subdirectory(src/lib/SDL)
|
||||||
# When using bundled SDL, use the static target
|
# When using bundled SDL, use the static target and set include directories
|
||||||
set(SDL_TARGETS SDL2-static)
|
set(SDL_TARGETS SDL2-static)
|
||||||
|
set(SDL2_INCLUDE_DIR
|
||||||
|
${CMAKE_SOURCE_DIR}/src/lib/SDL/include
|
||||||
|
${CMAKE_BINARY_DIR}/src/lib/SDL/include
|
||||||
|
${CMAKE_BINARY_DIR}/src/lib/SDL/include-config-${CMAKE_BUILD_TYPE}
|
||||||
|
)
|
||||||
|
# Also set for consistency with bundled SDL
|
||||||
|
set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIR})
|
||||||
else()
|
else()
|
||||||
find_package(SDL2)
|
find_package(SDL2)
|
||||||
# When using system SDL, use the imported targets
|
# When using system SDL, use the imported targets
|
||||||
|
|||||||
@@ -165,6 +165,7 @@ if (YAZE_BUILD_LIB)
|
|||||||
${SDL_TARGETS}
|
${SDL_TARGETS}
|
||||||
${CMAKE_DL_LIBS}
|
${CMAKE_DL_LIBS}
|
||||||
ImGui
|
ImGui
|
||||||
|
Threads::Threads
|
||||||
)
|
)
|
||||||
|
|
||||||
# Conditionally link ImGui Test Engine and set definitions
|
# Conditionally link ImGui Test Engine and set definitions
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ add_executable(
|
|||||||
zelda3/test_dungeon_objects.cc
|
zelda3/test_dungeon_objects.cc
|
||||||
${ASAR_STATIC_SRC}
|
${ASAR_STATIC_SRC}
|
||||||
${IMGUI_SRC}
|
${IMGUI_SRC}
|
||||||
${IMGUI_TEST_ENGINE_SOURCES}
|
|
||||||
${YAZE_SRC_FILES}
|
${YAZE_SRC_FILES}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -78,9 +77,13 @@ target_link_libraries(
|
|||||||
${PNG_LIBRARIES}
|
${PNG_LIBRARIES}
|
||||||
${OPENGL_LIBRARIES}
|
${OPENGL_LIBRARIES}
|
||||||
${CMAKE_DL_LIBS}
|
${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(
|
target_include_directories(
|
||||||
yaze_test PUBLIC
|
yaze_test PUBLIC
|
||||||
app/
|
app/
|
||||||
@@ -103,14 +106,23 @@ target_link_libraries(
|
|||||||
${PNG_LIBRARIES}
|
${PNG_LIBRARIES}
|
||||||
${OPENGL_LIBRARIES}
|
${OPENGL_LIBRARIES}
|
||||||
${CMAKE_DL_LIBS}
|
${CMAKE_DL_LIBS}
|
||||||
yaze_c
|
|
||||||
ImGuiTestEngine
|
|
||||||
ImGui
|
ImGui
|
||||||
gmock_main
|
gmock_main
|
||||||
gmock
|
gmock
|
||||||
gtest_main
|
gtest_main
|
||||||
gtest
|
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
|
# ROM Testing Configuration
|
||||||
if(YAZE_ENABLE_ROM_TESTS)
|
if(YAZE_ENABLE_ROM_TESTS)
|
||||||
target_compile_definitions(yaze_test PRIVATE
|
target_compile_definitions(yaze_test PRIVATE
|
||||||
@@ -119,7 +131,7 @@ if(YAZE_ENABLE_ROM_TESTS)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_compile_definitions(yaze_test PRIVATE "IMGUI_ENABLE_TEST_ENGINE")
|
# ImGui Test Engine definitions are now handled conditionally above
|
||||||
|
|
||||||
# Platform-specific definitions
|
# Platform-specific definitions
|
||||||
if(UNIX AND NOT APPLE)
|
if(UNIX AND NOT APPLE)
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "testing.h"
|
#include "testing.h"
|
||||||
#include "yaze.h"
|
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace test {
|
namespace test {
|
||||||
|
|||||||
@@ -8,10 +8,13 @@
|
|||||||
#include "imgui/backends/imgui_impl_sdl2.h"
|
#include "imgui/backends/imgui_impl_sdl2.h"
|
||||||
#include "imgui/backends/imgui_impl_sdlrenderer2.h"
|
#include "imgui/backends/imgui_impl_sdlrenderer2.h"
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
|
|
||||||
|
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||||
#include "imgui_test_engine/imgui_te_context.h"
|
#include "imgui_test_engine/imgui_te_context.h"
|
||||||
#include "imgui_test_engine/imgui_te_engine.h"
|
#include "imgui_test_engine/imgui_te_engine.h"
|
||||||
#include "imgui_test_engine/imgui_te_imconfig.h"
|
#include "imgui_test_engine/imgui_te_imconfig.h"
|
||||||
#include "imgui_test_engine/imgui_te_ui.h"
|
#include "imgui_test_engine/imgui_te_ui.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace test {
|
namespace test {
|
||||||
@@ -25,13 +28,19 @@ absl::Status TestEditor::Update() {
|
|||||||
|
|
||||||
static bool show_demo_window = true;
|
static bool show_demo_window = true;
|
||||||
|
|
||||||
|
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||||
ImGuiTestEngine_ShowTestEngineWindows(engine_, &show_demo_window);
|
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();
|
ImGui::End();
|
||||||
|
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||||
void TestEditor::RegisterTests(ImGuiTestEngine* engine) {
|
void TestEditor::RegisterTests(ImGuiTestEngine* engine) {
|
||||||
engine_ = engine;
|
engine_ = engine;
|
||||||
ImGuiTest* test = IM_REGISTER_TEST(engine, "demo_test", "test1");
|
ImGuiTest* test = IM_REGISTER_TEST(engine, "demo_test", "test1");
|
||||||
@@ -41,6 +50,7 @@ void TestEditor::RegisterTests(ImGuiTestEngine* engine) {
|
|||||||
ctx->ItemCheck("Node/Checkbox");
|
ctx->ItemCheck("Node/Checkbox");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// TODO: Fix the window/controller management
|
// TODO: Fix the window/controller management
|
||||||
int RunIntegrationTest() {
|
int RunIntegrationTest() {
|
||||||
@@ -50,11 +60,15 @@ int RunIntegrationTest() {
|
|||||||
IMGUI_CHECKVERSION();
|
IMGUI_CHECKVERSION();
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
|
|
||||||
// Initialize Test Engine
|
// Initialize Test Engine (if available)
|
||||||
|
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||||
ImGuiTestEngine* engine = ImGuiTestEngine_CreateContext();
|
ImGuiTestEngine* engine = ImGuiTestEngine_CreateContext();
|
||||||
ImGuiTestEngineIO& test_io = ImGuiTestEngine_GetIO(engine);
|
ImGuiTestEngineIO& test_io = ImGuiTestEngine_GetIO(engine);
|
||||||
test_io.ConfigVerboseLevel = ImGuiTestVerboseLevel_Info;
|
test_io.ConfigVerboseLevel = ImGuiTestVerboseLevel_Info;
|
||||||
test_io.ConfigVerboseLevelOnError = ImGuiTestVerboseLevel_Debug;
|
test_io.ConfigVerboseLevelOnError = ImGuiTestVerboseLevel_Debug;
|
||||||
|
#else
|
||||||
|
void* engine = nullptr; // Placeholder when test engine is disabled
|
||||||
|
#endif
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
|
||||||
@@ -65,8 +79,10 @@ int RunIntegrationTest() {
|
|||||||
ImGui_ImplSDLRenderer2_Init(yaze::core::Renderer::Get().renderer());
|
ImGui_ImplSDLRenderer2_Init(yaze::core::Renderer::Get().renderer());
|
||||||
|
|
||||||
yaze::test::TestEditor test_editor;
|
yaze::test::TestEditor test_editor;
|
||||||
|
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||||
test_editor.RegisterTests(engine);
|
test_editor.RegisterTests(engine);
|
||||||
ImGuiTestEngine_Start(engine, ImGui::GetCurrentContext());
|
ImGuiTestEngine_Start(engine, ImGui::GetCurrentContext());
|
||||||
|
#endif
|
||||||
controller.set_active(true);
|
controller.set_active(true);
|
||||||
|
|
||||||
// Set the default style
|
// Set the default style
|
||||||
@@ -85,7 +101,9 @@ int RunIntegrationTest() {
|
|||||||
controller.DoRender();
|
controller.DoRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||||
ImGuiTestEngine_Stop(engine);
|
ImGuiTestEngine_Stop(engine);
|
||||||
|
#endif
|
||||||
controller.OnExit();
|
controller.OnExit();
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,11 @@
|
|||||||
#define YAZE_TEST_INTEGRATION_TEST_EDITOR_H
|
#define YAZE_TEST_INTEGRATION_TEST_EDITOR_H
|
||||||
|
|
||||||
#include "app/editor/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_context.h"
|
||||||
#include "imgui_test_engine/imgui_te_engine.h"
|
#include "imgui_test_engine/imgui_te_engine.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace test {
|
namespace test {
|
||||||
@@ -44,10 +47,16 @@ class TestEditor : public yaze::editor::Editor {
|
|||||||
return absl::UnimplementedError("Not implemented");
|
return absl::UnimplementedError("Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||||
void RegisterTests(ImGuiTestEngine* engine);
|
void RegisterTests(ImGuiTestEngine* engine);
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||||
ImGuiTestEngine* engine_;
|
ImGuiTestEngine* engine_;
|
||||||
|
#else
|
||||||
|
void* engine_; // Placeholder when test engine is disabled
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
int RunIntegrationTest();
|
int RunIntegrationTest();
|
||||||
|
|||||||
Reference in New Issue
Block a user