diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 01544b686..db0190d1b 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -40,3 +40,26 @@ jobs: - name: Gulp (iOS) run: npx gulp buildIOS working-directory: ./Package + + build-windows: + runs-on: windows-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v2.3.3 + with: + submodules: 'true' + - name: Setup MSBuild + uses: microsoft/setup-msbuild@v1.0.2 + - name: Setup NuGet + uses: nuget/setup-nuget@v1 + with: + nuget-version: '5.x' + - name: NPM Install (Playground) + run: npm install + working-directory: ./Apps/Playground + - name: NPM Install (Binary Package) + run: npm install + working-directory: ./Package + - name: Gulp (Windows) + run: npx gulp buildUWPPR + working-directory: ./Package \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 493363cac..39082cdc9 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -4,7 +4,7 @@ on: types: [published] jobs: - build: + build-android-ios: runs-on: macos-latest steps: - name: Checkout Repo @@ -22,6 +22,54 @@ jobs: - name: Gulp run: npx gulp working-directory: ./Package + - name: Upload Assembled Folder + uses: actions/upload-artifact@v2 + with: + name: 'Assembled' + path: Package/Assembled + build-windows: + runs-on: windows-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v2.3.3 + with: + submodules: 'true' + - name: Setup MSBuild + uses: microsoft/setup-msbuild@v1.0.2 + - name: Setup NuGet + uses: nuget/setup-nuget@v1 + with: + nuget-version: '5.x' + - name: NPM Install (Playground) + run: npm install + working-directory: ./Apps/Playground + - name: NPM Install (Binary Package) + run: npm install + working-directory: ./Package + - name: Gulp (Windows) + run: npx gulp buildUWPPublish + working-directory: ./Package + - name: Upload Assembled Folder + uses: actions/upload-artifact@v2 + with: + name: 'Assembled' + path: Package/Assembled + package: + needs: [build-android-ios, build-windows] + runs-on: macos-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v2.3.3 + - name: NPM Install (Binary Package) + run: npm install + working-directory: ./Package + - name: Download Assembled Folder + uses: actions/download-artifact@v2 + with: + name: 'Assembled' + path: Package/Assembled + - name: Display structure of downloaded Assembled folder + run: ls -R - name: Setup Node.js uses: actions/setup-node@v2.1.2 with: @@ -34,4 +82,4 @@ jobs: npm publish --access public working-directory: ./Package/Assembled env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file diff --git a/Modules/@babylonjs/react-native/windows/scripts/Setup.bat b/Modules/@babylonjs/react-native/windows/scripts/PRBuild.bat similarity index 100% rename from Modules/@babylonjs/react-native/windows/scripts/Setup.bat rename to Modules/@babylonjs/react-native/windows/scripts/PRBuild.bat diff --git a/Modules/@babylonjs/react-native/windows/scripts/PRBuild.ps1 b/Modules/@babylonjs/react-native/windows/scripts/PRBuild.ps1 new file mode 100644 index 000000000..ca064bb3a --- /dev/null +++ b/Modules/@babylonjs/react-native/windows/scripts/PRBuild.ps1 @@ -0,0 +1,5 @@ +Import-Module $PSScriptRoot\Utils.psm1 + +Compile-Solution -Platform "x64" -Configuration "Debug" -Solution "$PSScriptRoot\..\..\submodules\BabylonNative\Build_uwp_x64\ReactNativeBabylon.sln" +nuget restore "$PSScriptRoot\..\..\..\..\..\Apps\Playground\windows\Playground.sln" +Compile-Solution -Platform "x64" -Configuration "Debug" -Solution "$PSScriptRoot\..\..\..\..\..\Apps\Playground\windows\Playground.sln" \ No newline at end of file diff --git a/Modules/@babylonjs/react-native/windows/scripts/Setup.ps1 b/Modules/@babylonjs/react-native/windows/scripts/Setup.ps1 deleted file mode 100644 index 53a074633..000000000 --- a/Modules/@babylonjs/react-native/windows/scripts/Setup.ps1 +++ /dev/null @@ -1,6 +0,0 @@ -Import-Module $PSScriptRoot\Utils.psm1 - -Restore-CMakeProject -Platform "x86" -Restore-CMakeProject -Platform "x64" -Restore-CMakeProject -Platform "arm" -Restore-CMakeProject -Platform "arm64" \ No newline at end of file diff --git a/Modules/@babylonjs/react-native/windows/scripts/Utils.psm1 b/Modules/@babylonjs/react-native/windows/scripts/Utils.psm1 index 7006dcf4f..5ab9a91c7 100644 --- a/Modules/@babylonjs/react-native/windows/scripts/Utils.psm1 +++ b/Modules/@babylonjs/react-native/windows/scripts/Utils.psm1 @@ -1,6 +1,12 @@ # MSBuild lookup adapted from https://blog.lextudio.com/locate-msbuild-via-powershell-on-different-operating-systems-140757bb8e18 function Get-MSBuildPath { $msbuild = "" + $MSBuildExistsInPath = $null -ne (Get-Command "msbuild" -ErrorAction SilentlyContinue) + if ($MSBuildExistsInPath) { + $msbuild = "msbuild.exe" + return $msbuild + } + if (-not(Get-PackageProvider NuGet -ErrorAction silentlyContinue)) { Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Confirm:$False -Force } @@ -63,7 +69,7 @@ function Compile-Solution { ) $MSBuild = Get-MSBuildPath - & "$MSBuild" /p:Configuration="$Configuration" /p:Platform="$Platform" $Solution + & "$MSBuild" /p:Configuration="$Configuration" /p:Platform="$Platform" /m $Solution if ($? -Eq $False) { Write-Error "$Platform $Configuration Build failed." exit 1 diff --git a/Package/gulpfile.js b/Package/gulpfile.js index e4e7fffe1..28c42631a 100644 --- a/Package/gulpfile.js +++ b/Package/gulpfile.js @@ -42,7 +42,17 @@ const buildAndroid = async () => { }; const makeUWPProject = async () => { - exec('.\\..\\Modules\\@babylonjs\\react-native\\windows\\scripts\\Setup.bat'); + // windows build agents don't support the path lengths required for initializing arcore dependencies, + // so we manually initialize the submodules we need here. + exec('git -c submodule."Dependencies/xr/Dependencies/arcore-android-sdk".update=none submodule update --init --recursive "./../Modules/@babylonjs/react-native/submodules/BabylonNative'); + shelljs.mkdir('-p', './../Modules/@babylonjs/react-native/submodules/BabylonNative/Build_uwp_x64'); + exec('cmake -D CMAKE_SYSTEM_NAME=WindowsStore -D CMAKE_SYSTEM_VERSION=10.0 -D NAPI_JAVASCRIPT_ENGINE=JSI ./../../../windows', './../Modules/@babylonjs/react-native/submodules/BabylonNative/Build_uwp_x64'); + shelljs.mkdir('-p', './../Modules/@babylonjs/react-native/submodules/BabylonNative/Build_uwp_x86'); + exec('cmake -D CMAKE_SYSTEM_NAME=WindowsStore -D CMAKE_SYSTEM_VERSION=10.0 -D NAPI_JAVASCRIPT_ENGINE=JSI -A Win32 ./../../../windows', './../Modules/@babylonjs/react-native/submodules/BabylonNative/Build_uwp_x86'); + shelljs.mkdir('-p', './../Modules/@babylonjs/react-native/submodules/BabylonNative/Build_uwp_arm'); + exec('cmake -D CMAKE_SYSTEM_NAME=WindowsStore -D CMAKE_SYSTEM_VERSION=10.0 -D NAPI_JAVASCRIPT_ENGINE=JSI -A arm ./../../../windows', './../Modules/@babylonjs/react-native/submodules/BabylonNative/Build_uwp_arm'); + shelljs.mkdir('-p', './../Modules/@babylonjs/react-native/submodules/BabylonNative/Build_uwp_arm64'); + exec('cmake -D CMAKE_SYSTEM_NAME=WindowsStore -D CMAKE_SYSTEM_VERSION=10.0 -D NAPI_JAVASCRIPT_ENGINE=JSI -A arm64 ./../../../windows', './../Modules/@babylonjs/react-native/submodules/BabylonNative/Build_uwp_arm64'); } const buildUWPProject = async () => { @@ -51,6 +61,20 @@ const buildUWPProject = async () => { const buildUWP = gulp.series(makeUWPProject, buildUWPProject); +const makeUWPProjectPR = async () => { + // windows build agents don't support the path lengths required for initializing arcore dependencies, + // so we manually initialize the submodules we need here. + exec('git -c submodule."Dependencies/xr/Dependencies/arcore-android-sdk".update=none submodule update --init --recursive "./../Modules/@babylonjs/react-native/submodules/BabylonNative'); + shelljs.mkdir('-p', './../Modules/@babylonjs/react-native/submodules/BabylonNative/Build_uwp_x64'); + exec('cmake -D CMAKE_SYSTEM_NAME=WindowsStore -D CMAKE_SYSTEM_VERSION=10.0 -D NAPI_JAVASCRIPT_ENGINE=JSI ./../../../windows', './../Modules/@babylonjs/react-native/submodules/BabylonNative/Build_uwp_x64'); +} + +const buildUWPProjectPR = async () => { + exec('.\\..\\Modules\\@babylonjs\\react-native\\windows\\scripts\\PRBuild.bat'); +} + +const buildUWPPR = gulp.series(makeUWPProjectPR, buildUWPProjectPR); + const copyCommonFiles = () => { return gulp.src('../Apps/Playground/node_modules/@babylonjs/react-native/package.json') .pipe(gulp.src('../Apps/Playground/node_modules/@babylonjs/react-native/README.md')) @@ -283,10 +307,18 @@ exports.build = build; exports.rebuild = rebuild; exports.pack = pack; -const packUWP = gulp.series(clean, buildUWP, copyCommonFiles, copySharedFiles, copyUWPFiles, createPackage); -const packUWPNoBuild = gulp.series(clean, copyCommonFiles, copySharedFiles, copyUWPFiles, createPackage); +const copyPackageFilesUWP = gulp.series(copyCommonFiles, copySharedFiles, copyUWPFiles); +const buildUWPPublish = gulp.series(buildUWP, copyPackageFilesUWP); +const packUWP = gulp.series(clean, buildUWP, copyPackageFilesUWP, createPackage); +const packUWPNoBuild = gulp.series(clean, copyPackageFilesUWP, createPackage); +exports.makeUWPProject = makeUWPProject; +exports.buildUWPProject = buildUWPProject; +exports.makeUWPProjectPR = makeUWPProjectPR; +exports.buildUWPProjectPR = buildUWPProjectPR; exports.buildUWP = buildUWP; +exports.buildUWPPR = buildUWPPR; +exports.buildUWPPublish = buildUWPPublish; exports.copyUWPFiles = copyUWPFiles; exports.packUWP = packUWP; exports.packUWPNoBuild = packUWPNoBuild; diff --git a/Package/package-lock.json b/Package/package-lock.json index c6705bbc6..82876ab36 100644 --- a/Package/package-lock.json +++ b/Package/package-lock.json @@ -2,13 +2,6 @@ "requires": true, "lockfileVersion": 1, "dependencies": { - "@babylonjs/react-native": { - "version": "file:Assembled/babylonjs-react-native-0.0.1.tgz", - "integrity": "sha512-2WmOtAQeqCcYMG74w04dRIEahvfWwdBm/WsIOn/waL+0VqgiVZaoyfF1arcPMxId5t0ZdbwT6zKCGS0qyQr5eg==", - "requires": { - "base-64": "^0.1.0" - } - }, "ansi-colors": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-1.1.0.tgz", @@ -33,6 +26,15 @@ "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", "dev": true }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, "ansi-wrap": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/ansi-wrap/-/ansi-wrap-0.1.0.tgz", @@ -394,11 +396,6 @@ } } }, - "base-64": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/base-64/-/base-64-0.1.0.tgz", - "integrity": "sha1-eAqZyE59YAJgNhURxId2E78k9rs=" - }, "binary-extensions": { "version": "1.13.1", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz", @@ -460,6 +457,16 @@ "integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo=", "dev": true }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, "chokidar": { "version": "2.1.8", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz", @@ -666,6 +673,21 @@ "object-visit": "^1.0.0" } }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, "color-support": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", @@ -837,6 +859,12 @@ "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=", "dev": true }, + "didyoumean": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.1.tgz", + "integrity": "sha1-6S7f2tplN9SE1zwBcv0eugxJdv8=", + "dev": true + }, "duplexify": { "version": "3.7.1", "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.7.1.tgz", @@ -1479,6 +1507,12 @@ "glogg": "^1.0.0" } }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, "has-symbols": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", @@ -1859,6 +1893,43 @@ "strip-bom": "^2.0.0" } }, + "lodash._reinterpolate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz", + "integrity": "sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=", + "dev": true + }, + "lodash.clonedeep": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", + "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=", + "dev": true + }, + "lodash.intersection": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/lodash.intersection/-/lodash.intersection-4.4.0.tgz", + "integrity": "sha1-ChG6Yx0OlcI8fy9Mu5ppLtF45wU=", + "dev": true + }, + "lodash.template": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-4.5.0.tgz", + "integrity": "sha512-84vYFxIkmidUiFxidA/KjjH9pAycqW+h980j7Fuz5qxRtO9pgB7MDFTdys1N7A5mcucRiDyEq4fusljItR1T/A==", + "dev": true, + "requires": { + "lodash._reinterpolate": "^3.0.0", + "lodash.templatesettings": "^4.0.0" + } + }, + "lodash.templatesettings": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-4.2.0.tgz", + "integrity": "sha512-stgLz+i3Aa9mZgnjr/O+v9ruKZsPsndy7qPZOchbqk2cnTU1ZaldKK+v7m54WoKIyxiuMZTKT2H81F8BeAc3ZQ==", + "dev": true, + "requires": { + "lodash._reinterpolate": "^3.0.0" + } + }, "make-iterator": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/make-iterator/-/make-iterator-1.0.1.tgz", @@ -2358,6 +2429,18 @@ "pinkie": "^2.0.0" } }, + "plugin-error": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-1.0.1.tgz", + "integrity": "sha512-L1zP0dk7vGweZME2i+EeakvUNqSrdiI3F91TwEoYiGrAfUXmVv6fJIq4g82PAXxNsWOp0J7ZqQy/3Szz0ajTxA==", + "dev": true, + "requires": { + "ansi-colors": "^1.0.1", + "arr-diff": "^4.0.0", + "arr-union": "^3.1.0", + "extend-shallow": "^3.0.2" + } + }, "posix-character-classes": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", @@ -3015,6 +3098,15 @@ "is-utf8": "^0.2.0" } }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + }, "sver-compat": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/sver-compat/-/sver-compat-1.5.0.tgz", @@ -3229,6 +3321,12 @@ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "dev": true + }, "v8flags": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.2.0.tgz", diff --git a/README.md b/README.md index 9f2b55658..4210b24cf 100644 --- a/README.md +++ b/README.md @@ -146,10 +146,10 @@ After having run the above commands, you can also open `Apps/Playground/ios/Play UWP can only be built on a PC. `CMake` must be manually run to generate project definitions for BabylonNative dependencies. 1. Run `npm install` in Apps\Playground. -1. Run `Modules\@babylonjs\react-native\windows\scripts\Setup.bat` in an administrator command prompt. This script will run `CMake` and generate visual studio projects for all of the required BabylonNative dependencies. -1. Run `Modules\@babylonjs\react-native\windows\scripts\Build.bat` in an administrator command prompt. This script will compile BabylonNative dependencies and BabylonReactNative.dll for all platforms and configurations. +1. Run `npm install` in Package. +1. Run `npx gulp buildUWP` in Package. This command will run cmake and build BabylonNative dependencies. It may take a while to complete. 1. In Apps\Playground, run `npm run windows`. -> Note: if you experience build issues for Apps\Playground related to autolinking, try running `npx react-native autolink-windows -logging` in the Apps\Playground folder. You can also run `npm run windows-verbose` to view logging. +> Note: if you experience build issues for Apps\Playground related to autolinking, try running `npx react-native autolink-windows` in the Apps\Playground folder. You can also run `npm run windows-verbose` to view logging. ### **Testing in the Playground App** ###