From e9b2a15f1818c39e025e8b2b696bbcba4401f8f4 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 25 Sep 2023 14:09:28 +0800 Subject: [PATCH] Fix XR header include and don't build XRInterface.cpp if XR is disabled. (#16324) --- native/CMakeLists.txt | 9 +++++++-- native/cocos/core/Root.cpp | 2 +- native/cocos/platform/android/AndroidPlatform.cpp | 4 ++++ native/cocos/renderer/gfx-gles3/GLES3Device.cpp | 2 +- native/cocos/scene/Camera.h | 2 +- native/cocos/xr/XRRemotePreviewManager.cpp | 2 +- 6 files changed, 15 insertions(+), 6 deletions(-) diff --git a/native/CMakeLists.txt b/native/CMakeLists.txt index 07f6eae2f68..d26dfee13c2 100644 --- a/native/CMakeLists.txt +++ b/native/CMakeLists.txt @@ -726,9 +726,14 @@ elseif(ANDROID OR OHOS) cocos/platform/java/modules/SystemWindow.h cocos/platform/java/modules/SystemWindowManager.cpp cocos/platform/java/modules/SystemWindowManager.h - cocos/platform/java/modules/XRInterface.cpp - cocos/platform/java/modules/XRInterface.h ) + + if(USE_XR) + cocos_source_files( + cocos/platform/java/modules/XRInterface.cpp + cocos/platform/java/modules/XRInterface.h + ) + endif() endif() if(ANDROID) diff --git a/native/cocos/core/Root.cpp b/native/cocos/core/Root.cpp index a08d9d8fbca..be2030e6983 100644 --- a/native/cocos/core/Root.cpp +++ b/native/cocos/core/Root.cpp @@ -30,7 +30,7 @@ #include "platform/interfaces/modules/IScreen.h" #include "platform/interfaces/modules/ISystemWindow.h" #include "platform/interfaces/modules/ISystemWindowManager.h" -#include "platform/java/modules/XRInterface.h" +#include "platform/interfaces/modules/IXRInterface.h" #if CC_USE_DEBUG_RENDERER #include "profiler/DebugRenderer.h" #endif diff --git a/native/cocos/platform/android/AndroidPlatform.cpp b/native/cocos/platform/android/AndroidPlatform.cpp index b14f3e2732f..8c2733eb949 100644 --- a/native/cocos/platform/android/AndroidPlatform.cpp +++ b/native/cocos/platform/android/AndroidPlatform.cpp @@ -42,7 +42,11 @@ #include "platform/java/modules/SystemWindow.h" #include "platform/java/modules/SystemWindowManager.h" #include "platform/java/modules/Vibrator.h" + +#include "platform/interfaces/modules/IXRInterface.h" +#if CC_USE_XR #include "platform/java/modules/XRInterface.h" +#endif #include "base/StringUtil.h" #include "engine/EngineEvents.h" diff --git a/native/cocos/renderer/gfx-gles3/GLES3Device.cpp b/native/cocos/renderer/gfx-gles3/GLES3Device.cpp index 6f3043b9aec..e081883bece 100644 --- a/native/cocos/renderer/gfx-gles3/GLES3Device.cpp +++ b/native/cocos/renderer/gfx-gles3/GLES3Device.cpp @@ -44,7 +44,7 @@ #include "GLES3Swapchain.h" #include "GLES3Texture.h" #include "application/ApplicationManager.h" -#include "platform/java/modules/XRInterface.h" +#include "platform/interfaces/modules/IXRInterface.h" #include "profiler/Profiler.h" #include "states/GLES3GeneralBarrier.h" #include "states/GLES3Sampler.h" diff --git a/native/cocos/scene/Camera.h b/native/cocos/scene/Camera.h index bb645d92955..2e2ebfbe627 100644 --- a/native/cocos/scene/Camera.h +++ b/native/cocos/scene/Camera.h @@ -37,7 +37,7 @@ #include "math/Mat4.h" #include "math/Vec3.h" #include "math/Vec4.h" -#include "platform/java/modules/XRInterface.h" +#include "platform/interfaces/modules/IXRInterface.h" #include "renderer/gfx-base/GFXDef-common.h" #include "renderer/pipeline/Define.h" diff --git a/native/cocos/xr/XRRemotePreviewManager.cpp b/native/cocos/xr/XRRemotePreviewManager.cpp index a7d94a2f596..a2f598872cf 100644 --- a/native/cocos/xr/XRRemotePreviewManager.cpp +++ b/native/cocos/xr/XRRemotePreviewManager.cpp @@ -30,7 +30,7 @@ #include "base/std/container/unordered_map.h" #include "base/std/container/vector.h" #include "math/Quaternion.h" -#include "platform/java/modules/XRInterface.h" +#include "platform/interfaces/modules/IXRInterface.h" #if CC_USE_XR #include "Xr.h"