diff --git a/gfx/vr/VRManager.cpp b/gfx/vr/VRManager.cpp index e5058b377b19..a3cf405a08b9 100644 --- a/gfx/vr/VRManager.cpp +++ b/gfx/vr/VRManager.cpp @@ -17,9 +17,9 @@ #include "gfxVR.h" #if defined(XP_WIN) #include "gfxVROculus.h" -#include "gfxVROpenVR.h" #endif -#if defined(XP_WIN) || defined(XP_MACOSX) || defined(XP_LINUX) +#if defined(XP_WIN) || defined(XP_MACOSX) || (defined(XP_LINUX) && !defined(MOZ_WIDGET_ANDROID)) +#include "gfxVROpenVR.h" #include "gfxVROSVR.h" #endif #include "gfxVRPuppet.h" @@ -75,14 +75,15 @@ VRManager::VRManager() if (mgr) { mManagers.AppendElement(mgr); } - // OpenVR is cross platform compatible, but supported only on Windows for now +#endif + +#if defined(XP_WIN) || defined(XP_MACOSX) || (defined(XP_LINUX) && !defined(MOZ_WIDGET_ANDROID)) + // OpenVR is cross platform compatible mgr = VRSystemManagerOpenVR::Create(); if (mgr) { mManagers.AppendElement(mgr); } -#endif -#if defined(XP_WIN) || defined(XP_MACOSX) || defined(XP_LINUX) // OSVR is cross platform compatible mgr = VRSystemManagerOSVR::Create(); if (mgr) { diff --git a/gfx/vr/gfxVROpenVR.h b/gfx/vr/gfxVROpenVR.h index 07c51a21c38d..b5e94647d7f9 100644 --- a/gfx/vr/gfxVROpenVR.h +++ b/gfx/vr/gfxVROpenVR.h @@ -8,6 +8,7 @@ #include "nsTArray.h" #include "nsIScreen.h" +#include "nsIThread.h" #include "nsCOMPtr.h" #include "mozilla/RefPtr.h" diff --git a/gfx/vr/moz.build b/gfx/vr/moz.build index ae38f2afb73d..1d488f545581 100644 --- a/gfx/vr/moz.build +++ b/gfx/vr/moz.build @@ -35,15 +35,20 @@ UNIFIED_SOURCES += [ 'VRManager.cpp', ] -if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': +# Build OpenVR on Windows, Linux, and macOS desktop targets +if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('cocoa', 'uikit', 'windows', 'gtk2', 'gtk3'): DIRS += [ 'openvr', ] SOURCES += [ - 'gfxVROculus.cpp', 'gfxVROpenVR.cpp', ] +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': + SOURCES += [ + 'gfxVROculus.cpp', + ] + IPDL_SOURCES = [ 'ipc/PVRLayer.ipdl', 'ipc/PVRManager.ipdl', diff --git a/gfx/vr/openvr/README.mozilla b/gfx/vr/openvr/README.mozilla index 3bd2edb59fd1..332e7fe055af 100644 --- a/gfx/vr/openvr/README.mozilla +++ b/gfx/vr/openvr/README.mozilla @@ -37,8 +37,11 @@ Steps to update the library: - Update "gfx/vr/openvr/moz.build" when files are added or removed. - Update the "strtools_public.h" and "strtools_public.cpp" files, commenting out - the "Uint64ToString" function. This function name conflicts with another used - in Gecko. Fortunately, the OpenVR SDK does not use this function either. + the "Uint64ToString", "wcsncpy_s", and "strncpy_s" functions. + The "Uint64ToString" function name conflicts with another used in Gecko and + the "errno_t" return type returned by the other functions is not defined in + Mozilla's macOS continuous integration build environments. Fortunately, the + OpenVR SDK does not use these functions. - Replace the #define VR_INTERFACE in openvr.h to avoid extern'ing the functions. Unlike the usual OpenVR API builds, we are not building a separate dll. diff --git a/gfx/vr/openvr/moz.build b/gfx/vr/openvr/moz.build index 10fec03c868b..655a536b5e3b 100644 --- a/gfx/vr/openvr/moz.build +++ b/gfx/vr/openvr/moz.build @@ -14,13 +14,19 @@ if CONFIG['OS_ARCH'] == 'WINNT': else: DEFINES['WIN32'] = True -# When we support platforms other than Windows, we -# will also need to define these: -# -# LINUX64 -# LINUX -# OSX -# POSIX +if CONFIG['OS_ARCH'] == 'Darwin': + DEFINES['POSIX'] = True + DEFINES['OSX'] = True + if CONFIG['GNU_CXX']: + CXXFLAGS += ['-xobjective-c++'] + +if CONFIG['OS_ARCH'] == 'Linux': + DEFINES['POSIX'] = True + DEFINES['LINUX'] = True + if CONFIG['HAVE_64BIT_BUILD']: + DEFINES['LINUX64'] = True + else: + DEFINES['LINUX32'] = True LOCAL_INCLUDES += [ '/toolkit/components/jsoncpp/include', @@ -45,3 +51,9 @@ SOURCES += [ 'src/vrpathregistry_public.cpp', ] +if CONFIG['CLANG_CXX'] or CONFIG['GNU_CXX']: + # Harmless warnings in 3rd party code + CXXFLAGS += [ + '-Wno-error=parentheses', + '-Wno-error=unused-variable', + ] diff --git a/gfx/vr/openvr/src/strtools_public.h b/gfx/vr/openvr/src/strtools_public.h index 2a60f1280e72..8a66cb0f99e8 100644 --- a/gfx/vr/openvr/src/strtools_public.h +++ b/gfx/vr/openvr/src/strtools_public.h @@ -52,6 +52,8 @@ inline int strnicmp( const char *pStr1, const char *pStr2, size_t unBufferLen ) #if defined( OSX ) // behaviors ensure NULL-termination at least as well as _TRUNCATE does, but // wcsncpy_s/strncpy_s can non-NULL-terminate, wcslcpy/strlcpy can not. +/* +// Commented out by Mozilla, please see README.mozilla inline errno_t wcsncpy_s(wchar_t *strDest, size_t numberOfElements, const wchar_t *strSource, size_t count) { return wcslcpy(strDest, strSource, numberOfElements); @@ -61,7 +63,7 @@ inline errno_t strncpy_s(char *strDest, size_t numberOfElements, const char *str { return strlcpy(strDest, strSource, numberOfElements); } - +*/ #endif #if defined( LINUX )