Skip to content

Commit 53a7580

Browse files
C. M. Barthrgerd
andauthored
Package header files needed for IXrContext.h usage (OpenXR + UWP) (#163)
* add additional items * try and decrease precompiled header size for BabylonReactNative * update pch.h definition * include header files for extension * include newer commits * fix napi-jsi build break * move openxr header into babylonreactnative repo * move back to main repo * move to newer commit * Update Package/gulpfile.js Co-authored-by: rgerd <[email protected]> * reduce number of gulp tasks Co-authored-by: rgerd <[email protected]>
1 parent acb6f0b commit 53a7580

File tree

8 files changed

+80
-4129
lines changed

8 files changed

+80
-4129
lines changed

Modules/@babylonjs/react-native-windows/README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,4 @@ This package contains windows dependencies for @babylonjs/react-native. See @bab
99
This package has several **peer dependencies**. If these dependencies are unmet, `npm install` will emit warnings. Be sure to add these dependencies to your project.
1010

1111
This package will not work without installing the `@babylonjs/react-native` peer dependency.
12-
The `react-native-permissions` dependency is required for XR capabilities of Babylon.js.
13-
14-
### Universal Windows Platform (UWP) Configuration
15-
16-
The minimum UWP target platform version is 10.0.18362.0. UWP BabylonReactNative requires the following NPM dependencies. These versions contradict the peer dependencies declared in package.json in order to support Android and iOS consumers using older versions of react and react-native.
12+
The `react-native-permissions` dependency is required for XR capabilities of Babylon.js.

Modules/@babylonjs/react-native-windows/windows/BabylonReactNative/BabylonReactNative.vcxproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<!-- Note: CppWinRT NuGet dependency should be resolved for the solution not the individual project -->
4-
<Import Project="$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.201102.2\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.201102.2\build\native\Microsoft.Windows.CppWinRT.props')" />
4+
<Import Project="$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.210122.3\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.210122.3\build\native\Microsoft.Windows.CppWinRT.props')" />
55
<PropertyGroup Label="Globals">
66
<CppWinRTOptimized>true</CppWinRTOptimized>
77
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
@@ -80,6 +80,7 @@
8080
<PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset>
8181
<CharacterSet>Unicode</CharacterSet>
8282
<GenerateManifest>false</GenerateManifest>
83+
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
8384
</PropertyGroup>
8485
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
8586
<UseDebugLibraries>true</UseDebugLibraries>
@@ -318,13 +319,13 @@
318319
<Error Condition="!Exists('$(BabylonNativeBuildDir)') And !Exists('$(BabylonNativeLibsDir)')" Text="$(ErrorText)" />
319320
</Target>
320321
<ImportGroup Label="ExtensionTargets">
321-
<Import Project="$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.201102.2\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.201102.2\build\native\Microsoft.Windows.CppWinRT.targets')" />
322+
<Import Project="$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.210122.3\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.210122.3\build\native\Microsoft.Windows.CppWinRT.targets')" />
322323
</ImportGroup>
323324
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
324325
<PropertyGroup>
325326
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
326327
</PropertyGroup>
327-
<Error Condition="!Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.201102.2\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', $(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.201102.2\build\native\Microsoft.Windows.CppWinRT.props'))" />
328-
<Error Condition="!Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.201102.2\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.201102.2\build\native\Microsoft.Windows.CppWinRT.targets'))" />
328+
<Error Condition="!Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.210122.3\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', $(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.210122.3\build\native\Microsoft.Windows.CppWinRT.props'))" />
329+
<Error Condition="!Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.210122.3\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.210122.3\build\native\Microsoft.Windows.CppWinRT.targets'))" />
329330
</Target>
330331
</Project>

Modules/@babylonjs/react-native-windows/windows/BabylonReactNative/BabylonReactNative.vcxproj.filters

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
<Midl Include="EngineView.idl" />
3030
</ItemGroup>
3131
<ItemGroup>
32-
<None Include="packages.config" />
3332
<None Include="BabylonReactNative.def" />
33+
<None Include="packages.config" />
3434
</ItemGroup>
3535
<ItemGroup>
3636
<None Include="PropertySheet.props" />
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Microsoft.Windows.CppWinRT" version="2.0.201102.2" targetFramework="native" />
3+
<package id="Microsoft.Windows.CppWinRT" version="2.0.210122.3" targetFramework="native" />
44
</packages>

Modules/@babylonjs/react-native-windows/windows/BabylonReactNative/pch.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#pragma once
22

3+
#ifndef NOMINMAX
34
#define NOMINMAX
5+
#endif
6+
7+
#ifndef WINRT_LEAN_AND_MEAN
8+
#define WINRT_LEAN_AND_MEAN
9+
#endif
410

511
#include <unknwn.h>
612
#include <winrt/Windows.Devices.Input.h>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#pragma once
2+
3+
#if __has_include("jsi/jsi.h")
4+
#include "jsi/jsi.h"
5+
#include "IXrContextOpenXR.h"
6+
7+
namespace BabylonReactNative
8+
{
9+
bool TryGetXrContext(facebook::jsi::Runtime& jsiRuntime, const facebook::jsi::Value& xrSession, IXrContextOpenXR*& xrContext)
10+
{
11+
xrContext = nullptr;
12+
if (!xrSession.isObject() ||
13+
!xrSession.asObject(jsiRuntime).hasProperty(jsiRuntime, "nativeXrContext") ||
14+
!xrSession.asObject(jsiRuntime).hasProperty(jsiRuntime, "nativeXrContextType") ||
15+
xrSession.asObject(jsiRuntime).getProperty(jsiRuntime, "nativeXrContextType").asString(jsiRuntime).utf8(jsiRuntime) != "OpenXR")
16+
{
17+
return false;
18+
}
19+
20+
auto nativeExtensionPtr = static_cast<uintptr_t>(xrSession.asObject(jsiRuntime).getProperty(jsiRuntime, "nativeXrContext").asNumber());
21+
xrContext = reinterpret_cast<IXrContextOpenXR*>(nativeExtensionPtr);
22+
return true;
23+
}
24+
}
25+
#endif

Package/gulpfile.js

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ const createUWPDirectories = async () => {
239239
shelljs.mkdir('-p', 'Assembled-Windows/windows/libs/x64/Debug');
240240
shelljs.mkdir('-p', 'Assembled-Windows/windows/libs/x64/Release');
241241
shelljs.mkdir('-p', 'Assembled-Windows/windows/BabylonReactNative');
242+
shelljs.mkdir('-p', 'Assembled-Windows/windows/include');
243+
shelljs.mkdir('-p', 'Assembled-Windows/windows/OpenXR-MixedReality/include/openxr');
244+
shelljs.mkdir('-p', 'Assembled-Windows/windows/OpenXR-MixedReality/include/XrUtility');
242245
}
243246

244247
const copyCommonFilesUWP = () => {
@@ -301,6 +304,28 @@ const copyVCXProjUWPFiles = () => {
301304
.pipe(gulp.dest('Assembled-Windows/windows/BabylonReactNative'));
302305
}
303306

307+
const copyOpenXRInfoFiles = () => {
308+
return gulp.src('../Modules/@babylonjs/react-native/submodules/BabylonNative/Dependencies/xr/Dependencies/OpenXR-MixedReality/LICENSE')
309+
.pipe(gulp.src('../Modules/@babylonjs/react-native/submodules/BabylonNative/Dependencies/xr/Dependencies/OpenXR-MixedReality/README.md'))
310+
.pipe(gulp.dest('Assembled-Windows/windows/OpenXR-MixedReality'));
311+
}
312+
313+
const copyOpenXRPreviewHeaders = () => {
314+
return gulp.src('../Modules/@babylonjs/react-native/submodules/BabylonNative/Dependencies/xr/Dependencies/OpenXR-MixedReality/openxr_preview/include/openxr/*')
315+
.pipe(gulp.dest('Assembled-Windows/windows/OpenXR-MixedReality/include/openxr'));
316+
}
317+
318+
const copyOpenXRUtilityHeaders = () => {
319+
return gulp.src('../Modules/@babylonjs/react-native/submodules/BabylonNative/Dependencies/xr/Dependencies/OpenXR-MixedReality/shared/XrUtility/*')
320+
.pipe(gulp.dest('Assembled-Windows/windows/OpenXR-MixedReality/include/XrUtility'));
321+
}
322+
323+
const copyOpenXRHelperHeaders = () => {
324+
return gulp.src('../Modules/@babylonjs/react-native/submodules/BabylonNative/Dependencies/xr/Source/OpenXR/Include/*')
325+
.pipe(gulp.src('../Modules/@babylonjs/react-native-windows/windows/include/*'))
326+
.pipe(gulp.dest('Assembled-Windows/windows/include'));
327+
}
328+
304329
const copyUWPFiles = gulp.series(
305330
createUWPDirectories,
306331
gulp.parallel(
@@ -313,7 +338,11 @@ const copyUWPFiles = gulp.series(
313338
copyARMReleaseUWPFiles,
314339
copyARM64DebugUWPFiles,
315340
copyARM64ReleaseUWPFiles,
316-
copyVCXProjUWPFiles));
341+
copyVCXProjUWPFiles,
342+
copyOpenXRInfoFiles,
343+
copyOpenXRPreviewHeaders,
344+
copyOpenXRUtilityHeaders,
345+
copyOpenXRHelperHeaders));
317346

318347
const validate = async () => {
319348
// When the package contents are updated *and validated*, update the expected below by running 'find Assembled | pbcopy' and pasting it over the expected string.
@@ -470,4 +499,4 @@ exports.copyUWPFiles = copyUWPFiles;
470499
exports.packUWP = packUWP;
471500
exports.packUWPNoBuild = packUWPNoBuild;
472501

473-
exports.default = build;
502+
exports.default = build;

0 commit comments

Comments
 (0)