Skip to content

Commit a358e9f

Browse files
C. M. Barthryantrem
andauthored
Add uwp packaging logic (#142)
* setup react windows project * start on cmake definition for babylon react native for uwp * cache some helper logic * change setup to x64 for local testing * add source files * add some needed files * working winrt plugin initialization * more windows work * failing during linker * add options to vcxproj to try and unblock debug builds * move to use jsi * fix modules * add react-native-windows dependency * working compilation * current state * current proto changes * working native input compilation * fix playground solution * close to working * working windows logic * hacked app setup to support working windows logic * working vr * move BabylonNative dll definition and add arm64 support * fix babylonnative to build in module folder * fix submodule declarations * remove unneeded build scripts * add clean solution * working build * working build * typescript content needs cleaned up * things need cleaned up but we will try a clean repo * fix package.json definition * remove debug logic * get metro to play nice with new exclusion list * add x86, arm build support * revert files * packages working * add reset function and allow babylonnative to build from modules folder * fix package path resolution for react native windows * prepare for draft review * comment out slider, needs work to fix * move to newest babylonnative and fix gitmodule repo * remove unneeded package-lock * remove untrue comments * remove unneeded comments * fix namespace comment names * avoid checking in bin log * revert unneeded metro.config.js changes * get npm install working vs using yarn * get project to work with npm install * add readme tips * fix permissions and slider initialization issues * add step value to fix windows slider usage * rename babylon native component to avoid lib collisions * rename to BabylonReactNative * ready for review * update build steps * cleanup some unneeded changes * avoid moving to new commit * add event revokers * add uwp build logic * revert settings file * remove files and update documentation * address review comments * address more review comments * Update Modules/@babylonjs/react-native/EngineHook.ts Co-authored-by: Ryan Tremblay <[email protected]> * address review comments * move hmd render behaviors to enginehook * remove unneeded dev dependencies * move engine logic into engineview * Update Modules/@babylonjs/react-native/EngineHook.ts Co-authored-by: Ryan Tremblay <[email protected]> * working windows packaging * avoid combining gulp files * address review comments * remove unneeded reference * update vcxproj and package choices * remove additional solution to prevent react-native-windows version conflicts * remove unneeded solution and update module * packages appear ready for usage * clean up things for review * execute file copies in parallel * revert unneeded changes * revert settings file Co-authored-by: Ryan Tremblay <[email protected]>
1 parent bfaff66 commit a358e9f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+4783
-4679
lines changed

Apps/PackageTest/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,6 @@ buck-out/
6161

6262
# CocoaPods
6363
/ios/Pods/
64+
65+
deploy.binlog
66+
msbuild.binlog

Apps/PackageTest/metro.config.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,25 @@
44
*
55
* @format
66
*/
7+
const path = require('path');
8+
const exclusionList = require('metro-config/src/defaults/exclusionList');
79

810
module.exports = {
11+
resolver: {
12+
blockList: exclusionList([
13+
// This stops "react-native run-windows" from causing the metro server to crash if its already running
14+
new RegExp(
15+
`${path.resolve(__dirname, 'windows').replace(/[/\\]/g, '/')}.*`,
16+
),
17+
// This prevents "react-native run-windows" from hitting: EBUSY: resource busy or locked, open msbuild.ProjectImports.zip
18+
/.*\.ProjectImports\.zip/,
19+
]),
20+
},
921
transformer: {
1022
getTransformOptions: async () => ({
1123
transform: {
1224
experimentalImportSupport: false,
13-
inlineRequires: false,
25+
inlineRequires: true,
1426
},
1527
}),
1628
},

Apps/PackageTest/package-lock.json

Lines changed: 3533 additions & 757 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Apps/PackageTest/package.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,37 @@
55
"scripts": {
66
"android": "react-native run-android",
77
"ios": "react-native run-ios",
8+
"windows": "react-native run-windows --arch x64",
9+
"windows-verbose": "react-native run-windows --arch x64 --logging",
810
"start": "react-native start",
911
"test": "jest",
1012
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
1113
},
1214
"dependencies": {
1315
"@babylonjs/core": "^5.0.0-alpha.6",
1416
"@babylonjs/react-native": "file:../../Package/Assembled/babylonjs-react-native-0.0.1.tgz",
15-
"react": "16.13.1",
16-
"react-native": "0.63.1",
17-
"react-native-permissions": "^2.1.5"
17+
"react": "^17.0.1",
18+
"react-native": "^0.64.0-rc.0",
19+
"react-native-permissions": "^3.0.0",
20+
"react-native-windows": "^0.64.0-0"
1821
},
1922
"devDependencies": {
2023
"@babel/core": "^7.8.4",
2124
"@babel/runtime": "^7.8.4",
2225
"@react-native-community/cli": "^4.13.0",
2326
"@react-native-community/eslint-config": "^1.1.0",
2427
"@types/jest": "^25.2.3",
25-
"@types/react-native": "0.63.1",
28+
"@types/react-native": "^0.63.18",
2629
"@types/react-test-renderer": "^16.9.2",
2730
"@typescript-eslint/eslint-plugin": "^2.27.0",
2831
"@typescript-eslint/parser": "^2.27.0",
2932
"babel-jest": "^25.1.0",
3033
"eslint": "^6.5.1",
3134
"jest": "^25.1.0",
35+
"metro-config": "^0.64.0",
3236
"metro-react-native-babel-preset": "^0.59.0",
3337
"prettier": "^2.0.4",
34-
"react-test-renderer": "16.13.1",
38+
"react-test-renderer": "^17.0.1",
3539
"typescript": "^3.8.3"
3640
},
3741
"jest": {
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
*AppPackages*
2+
*BundleArtifacts*
3+
4+
#OS junk files
5+
[Tt]humbs.db
6+
*.DS_Store
7+
8+
#Visual Studio files
9+
*.[Oo]bj
10+
*.user
11+
*.aps
12+
*.pch
13+
*.vspscc
14+
*.vssscc
15+
*_i.c
16+
*_p.c
17+
*.ncb
18+
*.suo
19+
*.tlb
20+
*.tlh
21+
*.bak
22+
*.[Cc]ache
23+
*.ilk
24+
*.log
25+
*.lib
26+
*.sbr
27+
*.sdf
28+
*.opensdf
29+
*.opendb
30+
*.unsuccessfulbuild
31+
ipch/
32+
[Oo]bj/
33+
[Bb]in
34+
[Dd]ebug*/
35+
[Rr]elease*/
36+
Ankh.NoLoad
37+
38+
# Visual C++ cache files
39+
ipch/
40+
*.aps
41+
*.ncb
42+
*.opendb
43+
*.opensdf
44+
*.sdf
45+
*.cachefile
46+
*.VC.db
47+
*.VC.VC.opendb
48+
49+
#MonoDevelop
50+
*.pidb
51+
*.userprefs
52+
53+
#Tooling
54+
_ReSharper*/
55+
*.resharper
56+
[Tt]est[Rr]esult*
57+
*.sass-cache
58+
59+
#Project files
60+
[Bb]uild/
61+
62+
#Subversion files
63+
.svn
64+
65+
# Office Temp Files
66+
~$*
67+
68+
# vim Temp Files
69+
*~
70+
71+
#NuGet
72+
packages/
73+
*.nupkg
74+
75+
#ncrunch
76+
*ncrunch*
77+
*crunch*.local.xml
78+
79+
# visual studio database projects
80+
*.dbmdl
81+
82+
#Test files
83+
*.testsettings
84+
85+
#Other files
86+
*.DotSettings
87+
.vs/
88+
*project.lock.json
89+
90+
#Files generated by the VS build
91+
**/Generated Files/**
92+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
4+
<!-- Flags can be added here to effect the compilation of Microsoft.ReactNative -->
5+
<PropertyGroup Label="Microsoft.ReactNative Build Flags">
6+
<UseWinUI3>false</UseWinUI3>
7+
<UseHermes>false</UseHermes>
8+
</PropertyGroup>
9+
10+
</Project>

Apps/PackageTest/windows/PackageTest.sln

Lines changed: 223 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/Bundle
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#include "pch.h"
2+
3+
#include "App.h"
4+
5+
#include "AutolinkedNativeModules.g.h"
6+
#include "ReactPackageProvider.h"
7+
8+
using namespace winrt::PackageTest;
9+
using namespace winrt::PackageTest::implementation;
10+
using namespace winrt;
11+
using namespace Windows::UI::Xaml;
12+
using namespace Windows::UI::Xaml::Controls;
13+
using namespace Windows::UI::Xaml::Navigation;
14+
using namespace Windows::ApplicationModel;
15+
16+
/// <summary>
17+
/// Initializes the singleton application object. This is the first line of
18+
/// authored code executed, and as such is the logical equivalent of main() or
19+
/// WinMain().
20+
/// </summary>
21+
App::App() noexcept
22+
{
23+
#if BUNDLE
24+
JavaScriptBundleFile(L"index.windows");
25+
InstanceSettings().UseWebDebugger(false);
26+
InstanceSettings().UseFastRefresh(false);
27+
#else
28+
JavaScriptBundleFile(L"index");
29+
InstanceSettings().UseWebDebugger(true);
30+
InstanceSettings().UseFastRefresh(true);
31+
#endif
32+
33+
#if _DEBUG
34+
InstanceSettings().UseDeveloperSupport(true);
35+
#else
36+
InstanceSettings().UseDeveloperSupport(false);
37+
#endif
38+
39+
RegisterAutolinkedNativeModulePackages(PackageProviders()); // Includes any autolinked modules
40+
41+
PackageProviders().Append(make<ReactPackageProvider>()); // Includes all modules in this project
42+
43+
InitializeComponent();
44+
}
45+
46+
/// <summary>
47+
/// Invoked when the application is launched normally by the end user. Other entry points
48+
/// will be used such as when the application is launched to open a specific file.
49+
/// </summary>
50+
/// <param name="e">Details about the launch request and process.</param>
51+
void App::OnLaunched(activation::LaunchActivatedEventArgs const& e)
52+
{
53+
super::OnLaunched(e);
54+
55+
Frame rootFrame = Window::Current().Content().as<Frame>();
56+
rootFrame.Navigate(xaml_typename<PackageTest::MainPage>(), box_value(e.Arguments()));
57+
}
58+
59+
/// <summary>
60+
/// Invoked when application execution is being suspended. Application state is saved
61+
/// without knowing whether the application will be terminated or resumed with the contents
62+
/// of memory still intact.
63+
/// </summary>
64+
/// <param name="sender">The source of the suspend request.</param>
65+
/// <param name="e">Details about the suspend request.</param>
66+
void App::OnSuspending([[maybe_unused]] IInspectable const& sender, [[maybe_unused]] SuspendingEventArgs const& e)
67+
{
68+
// Save application state and stop any background activity
69+
}
70+
71+
/// <summary>
72+
/// Invoked when Navigation to a certain page fails
73+
/// </summary>
74+
/// <param name="sender">The Frame which failed navigation</param>
75+
/// <param name="e">Details about the navigation failure</param>
76+
void App::OnNavigationFailed(IInspectable const&, NavigationFailedEventArgs const& e)
77+
{
78+
throw hresult_error(E_FAIL, hstring(L"Failed to load Page ") + e.SourcePageType().Name);
79+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#pragma once
2+
3+
#include "App.xaml.g.h"
4+
5+
namespace activation = winrt::Windows::ApplicationModel::Activation;
6+
7+
namespace winrt::PackageTest::implementation
8+
{
9+
struct App : AppT<App>
10+
{
11+
App() noexcept;
12+
void OnLaunched(activation::LaunchActivatedEventArgs const&);
13+
void OnSuspending(IInspectable const&, Windows::ApplicationModel::SuspendingEventArgs const&);
14+
void OnNavigationFailed(IInspectable const&, Windows::UI::Xaml::Navigation::NavigationFailedEventArgs const&);
15+
private:
16+
using super = AppT<App>;
17+
};
18+
} // namespace winrt::PackageTest::implementation

0 commit comments

Comments
 (0)