From f6da4d0eb6e763dcec320d22c7ece126a424bbfd Mon Sep 17 00:00:00 2001 From: ssdfasd <2156608475@qq.com> Date: Sun, 5 Apr 2026 15:37:35 +0800 Subject: [PATCH] Split new_editor compat sources into static library --- docs/plan/XCUI_Phase_Status_2026-04-05.md | 6 +++ new_editor/CMakeLists.txt | 53 ++++++++++++++++++++--- 2 files changed, 52 insertions(+), 7 deletions(-) diff --git a/docs/plan/XCUI_Phase_Status_2026-04-05.md b/docs/plan/XCUI_Phase_Status_2026-04-05.md index 83061da2..1d7c143b 100644 --- a/docs/plan/XCUI_Phase_Status_2026-04-05.md +++ b/docs/plan/XCUI_Phase_Status_2026-04-05.md @@ -30,6 +30,9 @@ Old `editor` replacement is explicitly out of scope for this phase. - The default native shell path now also has a cleaner translation-unit seam: - legacy ImGui shell chrome / HUD rendering now lives in a dedicated legacy-only `Application` translation unit instead of keeping direct `ImGui::*` calls inside the main native host TU - `Application.cpp` no longer directly includes ``, even though the compatibility host path is still compiled into `new_editor` +- The `new_editor` build now also has an explicit compatibility-source slice: + - legacy ImGui shell sources and vendored ImGui backend sources are now grouped into a dedicated compatibility static library instead of being compiled directly as part of the main `XCNewEditor` source list + - the main `XCNewEditor` target still sees ImGui headers through older editor bridge headers, but its default implementation source list is now narrower than the compatibility source list - Old `editor` replacement remains deferred; all active execution still stays inside XCUI shared code and `new_editor`. ## Three-Layer Status @@ -282,6 +285,9 @@ Current gap: - Legacy shell chrome / HUD rendering is now split out of the main `Application.cpp` translation unit: - the direct `ImGui::*` shell rendering path now lives in a dedicated legacy-only `Application` implementation file - the main `Application.cpp` native host path no longer directly includes ``, reducing default-path compile-time coupling before the larger compat-target split +- `new_editor` build composition is now split into main/native and compatibility slices: + - the main `XCNewEditor` target no longer compiles legacy ImGui shell/panel/backend source files directly + - legacy ImGui shell/panel/backend sources plus vendored ImGui sources now build behind a dedicated compatibility static library that the main executable links ## Phase Risks Still Open diff --git a/new_editor/CMakeLists.txt b/new_editor/CMakeLists.txt index 1d0e5355..a047bbf2 100644 --- a/new_editor/CMakeLists.txt +++ b/new_editor/CMakeLists.txt @@ -44,17 +44,10 @@ endif() set(NEW_EDITOR_SOURCES src/main.cpp src/Application.cpp - src/ApplicationLegacyImGui.cpp src/panels/Panel.cpp - src/panels/XCUIDemoPanel.cpp - src/panels/XCUILayoutLabPanel.cpp src/Rendering/MainWindowBackdropPass.cpp src/Rendering/MainWindowNativeBackdropRenderer.cpp - src/XCUIBackend/ImGuiXCUIInputAdapter.cpp - src/XCUIBackend/LegacyImGuiHostInterop.cpp - src/XCUIBackend/ImGuiHostCompositor.cpp src/XCUIBackend/NativeWindowUICompositor.cpp - src/XCUIBackend/XCUIEditorFontSetup.cpp src/XCUIBackend/XCUIAssetDocumentSource.cpp src/XCUIBackend/XCUIEditorCommandRouter.cpp src/XCUIBackend/XCUIInputBridge.cpp @@ -64,6 +57,16 @@ set(NEW_EDITOR_SOURCES src/XCUIBackend/XCUIStandaloneTextAtlasProvider.cpp src/XCUIBackend/XCUIDemoRuntime.cpp src/XCUIBackend/XCUILayoutLabRuntime.cpp +) + +set(NEW_EDITOR_IMGUI_COMPAT_SOURCES + src/ApplicationLegacyImGui.cpp + src/panels/XCUIDemoPanel.cpp + src/panels/XCUILayoutLabPanel.cpp + src/XCUIBackend/ImGuiXCUIInputAdapter.cpp + src/XCUIBackend/LegacyImGuiHostInterop.cpp + src/XCUIBackend/ImGuiHostCompositor.cpp + src/XCUIBackend/XCUIEditorFontSetup.cpp ${IMGUI_SOURCE_DIR}/imgui.cpp ${IMGUI_SOURCE_DIR}/imgui_demo.cpp ${IMGUI_SOURCE_DIR}/imgui_draw.cpp @@ -73,8 +76,17 @@ set(NEW_EDITOR_SOURCES ${IMGUI_SOURCE_DIR}/backends/imgui_impl_dx12.cpp ) +add_library(XCNewEditorImGuiCompat STATIC ${NEW_EDITOR_IMGUI_COMPAT_SOURCES}) add_executable(${PROJECT_NAME} WIN32 ${NEW_EDITOR_SOURCES}) +target_include_directories(XCNewEditorImGuiCompat PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/src + ${XCENGINE_ROOT_DIR}/engine/include + ${XCENGINE_ROOT_DIR}/editor/src + ${IMGUI_SOURCE_DIR} + ${IMGUI_SOURCE_DIR}/backends +) + target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ${XCENGINE_ROOT_DIR}/engine/include @@ -85,6 +97,13 @@ target_include_directories(${PROJECT_NAME} PRIVATE file(TO_CMAKE_PATH "${XCENGINE_ROOT_DIR}" XCENGINE_ROOT_DIR_CMAKE) +target_compile_definitions(XCNewEditorImGuiCompat PRIVATE + UNICODE + _UNICODE + XCENGINE_NEW_EDITOR_REPO_ROOT="${XCENGINE_ROOT_DIR_CMAKE}" +) +target_compile_options(XCNewEditorImGuiCompat PRIVATE /utf-8) + target_compile_definitions(${PROJECT_NAME} PRIVATE UNICODE _UNICODE @@ -93,7 +112,18 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE target_compile_options(${PROJECT_NAME} PRIVATE /utf-8) if(MSVC) + target_compile_options(XCNewEditorImGuiCompat PRIVATE /FS) target_compile_options(${PROJECT_NAME} PRIVATE /FS) + set_property(TARGET XCNewEditorImGuiCompat PROPERTY + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") + set_target_properties(XCNewEditorImGuiCompat PROPERTIES + MSVC_DEBUG_INFORMATION_FORMAT "$<$:Embedded>" + COMPILE_PDB_NAME "XCNewEditorImGuiCompat-compile" + COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/new_editor/compile-pdb-compat" + COMPILE_PDB_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/new_editor/compile-pdb-compat/Debug" + COMPILE_PDB_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/new_editor/compile-pdb-compat/Release" + COMPILE_PDB_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_BINARY_DIR}/new_editor/compile-pdb-compat/MinSizeRel" + COMPILE_PDB_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/new_editor/compile-pdb-compat/RelWithDebInfo") target_link_options(${PROJECT_NAME} PRIVATE $<$:/INCREMENTAL:NO>) set_property(TARGET ${PROJECT_NAME} PROPERTY @@ -110,8 +140,17 @@ if(MSVC) ) endif() +target_link_libraries(XCNewEditorImGuiCompat PRIVATE + XCEngine + d3d12.lib + dxgi.lib + user32 + gdi32 +) + target_link_libraries(${PROJECT_NAME} PRIVATE XCEngine + XCNewEditorImGuiCompat d3d12.lib dxgi.lib user32