diff --git a/.github/workflows/bn_master_commit.yml b/.github/workflows/bn_master_commit.yml index 91e4f70c1..18c152436 100644 --- a/.github/workflows/bn_master_commit.yml +++ b/.github/workflows/bn_master_commit.yml @@ -13,17 +13,17 @@ jobs: runs-on: macos-latest steps: - name: Checkout Repo - uses: actions/checkout@v2.3.3 + uses: actions/checkout@v4.2.0 with: submodules: 'recursive' - name: Free space uses: ./.github/workflows/macos_freespace - name: Setup Node 16 - uses: actions/setup-node@v3 + uses: actions/setup-node@v4.0.4 with: node-version: 16 - name: Setup CMake - uses: jwlawson/actions-setup-cmake@v1.8 + uses: jwlawson/actions-setup-cmake@v2.0.2 with: cmake-version: '3.26.3' - name: Setup Ninja @@ -38,7 +38,7 @@ jobs: run: npm install working-directory: ./Package - name: Setup Java - uses: actions/setup-java@v3 + uses: actions/setup-java@v4.4.0 with: distribution: 'temurin' java-version: '17' @@ -54,13 +54,13 @@ jobs: runs-on: macos-latest steps: - name: Checkout Repo - uses: actions/checkout@v2.3.3 + uses: actions/checkout@v4.2.0 with: submodules: 'recursive' - name: Free space uses: ./.github/workflows/macos_freespace - name: Setup Node 16 - uses: actions/setup-node@v3 + uses: actions/setup-node@v4.0.4 with: node-version: 16 - name: NPM Install (Playground) @@ -85,13 +85,13 @@ jobs: config: [Debug, Release] steps: - name: Checkout Repo - uses: actions/checkout@v2.3.3 + uses: actions/checkout@v4.2.0 with: submodules: 'true' - name: Setup MSBuild - uses: microsoft/setup-msbuild@v1.0.2 + uses: microsoft/setup-msbuild@v2 - name: Setup Node 16 - uses: actions/setup-node@v3 + uses: actions/setup-node@v4.0.4 with: node-version: 16 - name: Setup NuGet diff --git a/.github/workflows/ios_android.yml b/.github/workflows/ios_android.yml index 12c8be556..d0ec08f56 100644 --- a/.github/workflows/ios_android.yml +++ b/.github/workflows/ios_android.yml @@ -18,17 +18,17 @@ jobs: runs-on: macos-latest steps: - name: Checkout Repo - uses: actions/checkout@v2.3.3 + uses: actions/checkout@v4.2.0 with: submodules: 'recursive' - name: Free space uses: ./.github/workflows/macos_freespace - name: Setup Node 16 - uses: actions/setup-node@v3 + uses: actions/setup-node@v4.0.4 with: node-version: 16 - name: Setup CMake - uses: jwlawson/actions-setup-cmake@v1.8 + uses: jwlawson/actions-setup-cmake@v2.0.2 with: cmake-version: '3.26.3' - name: Setup Ninja @@ -36,7 +36,7 @@ jobs: - name: 'Select XCode ${{ inputs.xcode-version }}' run: sudo xcode-select --switch /Applications/Xcode_${{ inputs.xcode-version }}.app/Contents/Developer - name: Setup Java - uses: actions/setup-java@v3 + uses: actions/setup-java@v4.4.0 with: distribution: 'temurin' java-version: '17' diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 756b946a3..90d19b006 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -3,256 +3,173 @@ on: pull_request: branches: - master -env: - BRN_Version: '0.64' jobs: - build-android: - runs-on: macos-latest - steps: - - name: Checkout Repo - uses: actions/checkout@v2.3.3 - with: - submodules: 'recursive' - - name: Free space - uses: ./.github/workflows/macos_freespace - - name: Setup Node 16 - uses: actions/setup-node@v3 - with: - node-version: 16 - - name: Setup CMake - uses: jwlawson/actions-setup-cmake@v1.8 - with: - cmake-version: '3.26.3' - - name: Setup Ninja - run: brew install ninja - - name: NPM Install (Playground) - run: npm install - working-directory: ./Apps/Playground - - name: NPM Install (React Native ${{ env.BRN_Version }}) - run: npm run select ${{ env.BRN_Version }} - working-directory: ./Apps/Playground - - name: NPM Install (Binary Package) - run: npm install - working-directory: ./Package - - name: Setup Java - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: '17' - check-latest: true - - name: Gulp (Android) - run: npx gulp buildAndroid - working-directory: ./Package - env: - JAVA_HOME: ${{ env.JAVA_HOME_11_X64 }} - - build-android-rnta: +# build-ios-android-rnta: +# runs-on: macos-latest +# strategy: +# matrix: +# platform: [ios, android] +# react-native-version: ['0.73'] +# steps: +# - name: Checkout Repo +# uses: actions/checkout@v4.2.0 +# - name: Setup CMake +# uses: jwlawson/actions-setup-cmake@v2.0.2 +# with: +# cmake-version: '3.26.3' +# - name: Setup Ninja +# run: brew install ninja +# - name: Setup Watchman +# run: brew install watchman +# - name: Free space +# uses: ./.github/workflows/macos_freespace +# - name: Set React-Native version ${{ matrix.react-native-version }} +# run: npm run set-react-version -- ${{ matrix.react-native-version }} +# working-directory: ./Apps/BRNPlayground +# - name: NPM Install (BRNPlayground) +# run: npm install +# working-directory: ./Apps/BRNPlayground +# +# - name: Build Bundle +# run: npm run build:${{ matrix.platform }} +# working-directory: ./Apps/BRNPlayground +# +# - name: NPM Install (Binary Package) +# run: npm install +# working-directory: ./Package +# - name: Setup Java +# uses: actions/setup-java@v4.4.0 +# with: +# distribution: 'temurin' +# java-version: '17' +# check-latest: true +# - name: Gulp ${{ matrix.platform }} +# run: npx gulp build${{ matrix.platform }}RNTA +# working-directory: ./Package +# env: +# JAVA_HOME: ${{ env.JAVA_HOME_11_X64 }} + + android-ios-rnta: runs-on: macos-latest + strategy: + matrix: + react-native-version: ['0.73', '0.74'] + platform: ['android', 'ios'] steps: - name: Checkout Repo - uses: actions/checkout@v2.3.3 - with: - submodules: 'recursive' - - name: Free space - uses: ./.github/workflows/macos_freespace + uses: actions/checkout@v4.2.0 - name: Setup CMake - uses: jwlawson/actions-setup-cmake@v1.8 + uses: jwlawson/actions-setup-cmake@v2.0.2 with: cmake-version: '3.26.3' - name: Setup Ninja run: brew install ninja - name: Setup Watchman run: brew install watchman - - name: NPM Install (Playground) +# - name: Free space +# uses: ./.github/workflows/macos_freespace + - name: Set React-Native version ${{ matrix.react-native-version }} + run: npm run set-react-version -- ${{ matrix.react-native-version }} + working-directory: ./Apps/BRNPlayground + - name: NPM Install (BRNPlayground) run: npm install working-directory: ./Apps/BRNPlayground - - - name: Build Windows Bundle - run: npm run build:android + - name: Build Bundle ${{ matrix.platform }} + run: npm run build:${{ matrix.platform }} working-directory: ./Apps/BRNPlayground - - name: NPM Install (Binary Package) run: npm install working-directory: ./Package - name: Setup Java - uses: actions/setup-java@v3 + uses: actions/setup-java@v4.4.0 with: distribution: 'temurin' java-version: '17' check-latest: true - - name: Gulp (Android) - run: npx gulp buildAndroidRNTA + - name: Gulp build ${{ matrix.platform }} + run: npx gulp buildRNTA${{ matrix.platform }} working-directory: ./Package env: JAVA_HOME: ${{ env.JAVA_HOME_11_X64 }} - - build-iOS: - runs-on: macos-latest - steps: - - name: Checkout Repo - uses: actions/checkout@v2.3.3 - with: - submodules: 'recursive' - - name: Free space - uses: ./.github/workflows/macos_freespace - - name: Setup Node 16 - uses: actions/setup-node@v3 - with: - node-version: 16 - - name: NPM Install (Playground) - run: npm install - working-directory: ./Apps/Playground - - name: NPM Install (React Native ${{ env.BRN_Version }}) - run: npm run select --reactNative ${{ env.BRN_Version }} - working-directory: ./Apps/Playground - - name: NPM Install (Binary Package) - run: npm install - working-directory: ./Package - - name: Gulp (iOS) - run: npx gulp buildIOS - working-directory: ./Package - build-iOS-rnta: - runs-on: macos-latest - steps: - - name: Checkout Repo - uses: actions/checkout@v2.3.3 - with: - submodules: 'recursive' - - name: Free space - uses: ./.github/workflows/macos_freespace - - name: Setup Watchman - run: brew install watchman - - - name: NPM Install (Playground) - run: npm install - working-directory: ./Apps/BRNPlayground - - - name: Build iOS Bundle - run: npm run build:ios - working-directory: ./Apps/BRNPlayground - - - name: NPM Install (Binary Package) - run: npm install - working-directory: ./Package - - name: Gulp (iOS) - run: npx gulp buildIOSRNTA - working-directory: ./Package +# - name: Build iOS App +# if: ${{ matrix.platform == 'ios' }} +# run: | +# xcodebuild -sdk iphonesimulator -arch x86_64 -configuration Release -workspace BRNPlayground.xcworkspace -scheme ReactTestApp build CODE_SIGNING_ALLOWED=NO -archivePath ./playgroundSimulator.xcarchive archive +# working-directory: ./Apps/BRNPlayground/ios + - name: Display structure + run: ls -R + - name: Upload Assembled ${{ matrix.platform }} Folder + uses: actions/upload-artifact@v4 + with: + name: 'Assembled-${{ matrix.platform }}${{ matrix.react-native-version }}' + path: Package/Assembled-iOSAndroid + - name: Upload Assembled ${{ matrix.platform }} BaseKit Folder + uses: actions/upload-artifact@v4 + with: + name: 'Assembled-BaseKit-${{ matrix.platform }}${{ matrix.react-native-version }}' + path: Package/Assembled-BaseKit-iOSAndroid - name: Cache XCFrameworks uses: actions/cache@v2 + if: ${{ matrix.platform == 'ios' }} with: path: Modules/@babylonjs/react-native-iosandroid/ios/libs key: ${{ runner.os }}-xcframeworks-${{ github.sha }} restore-keys: | ${{ runner.os }}-xcframeworks - - test-publish-android-ios: - runs-on: macos-latest - steps: - - name: Checkout Repo - uses: actions/checkout@v2.3.3 + - name: Upload APK + uses: actions/upload-artifact@v4 + if: ${{ matrix.platform == 'android' }} with: - submodules: 'recursive' - - name: Free space - uses: ./.github/workflows/macos_freespace - - name: Setup Node 16 - uses: actions/setup-node@v3 - with: - node-version: 16 - - name: Setup CMake - uses: jwlawson/actions-setup-cmake@v1.8 + name: 'AndroidAPK${{ matrix.react-native-version }}' + path: ./Apps/BRNPlayground/apk + - name: Upload iOS App + uses: actions/upload-artifact@v4 + if: ${{ matrix.platform == 'ios' }} with: - cmake-version: '3.26.3' - - name: Setup Ninja - run: brew install ninja - - name: Setup Java - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: '17' - check-latest: true - - name: NPM Install (Playground) - run: npm install - working-directory: ./Apps/Playground - - name: NPM Install (React Native ${{ env.BRN_Version }}) - run: npm run select --reactNative ${{ env.BRN_Version }} - working-directory: ./Apps/Playground - - name: NPM Install (Binary Package) - run: npm install - working-directory: ./Package - - name: Gulp - run: npx gulp - working-directory: ./Package - env: - JAVA_HOME: ${{ env.JAVA_HOME_11_X64 }} + name: 'iOSApp${{ matrix.react-native-version }}' + path: Apps/BRNPlayground/ios/ + + build-typescript: + uses: ./.github/workflows/typescript.yml + with: + release-version: 0.0.${GITHUB_SHA::8} - build-windows: - runs-on: windows-2019 + windows-rnta: + runs-on: windows-2022 strategy: matrix: - platform: [x86, x64, ARM64] + platform: [x64, ARM64] config: [Debug, Release] + react-native-version: ['0.73', '0.74'] + basekit: ['', '-BaseKit'] steps: - name: Support longpaths run: git config --system core.longpaths true - name: Checkout Repo - uses: actions/checkout@v2.3.3 - with: - submodules: 'true' - - name: Setup MSBuild - uses: microsoft/setup-msbuild@v1.0.2 - - name: Setup Node 16 - uses: actions/setup-node@v3 - with: - node-version: 16 - - 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 (React Native ${{ env.BRN_Version }}) - run: npm run select ${{ env.BRN_Version }} - working-directory: ./Apps/Playground - - name: NPM Install (Binary Package) - run: npm install - working-directory: ./Package - - name: Gulp Setup Project ${{ matrix.platform }} (Windows) - run: npx gulp makeUWPProject${{ matrix.platform }} - working-directory: ./Package - - name: Gulp Build ${{ matrix.platform }} ${{ matrix.config }} (Windows) - run: npx gulp buildUWP${{ matrix.platform }}${{ matrix.config }} - working-directory: ./Package - - name: Gulp NuGet Restore Playground - run: npx gulp nugetRestoreUWPPlayground - working-directory: ./Package - - name: Gulp Build ${{ matrix.platform }} ${{ matrix.config }} Playground (Windows) - run: npx gulp buildUWPPlayground${{ matrix.platform }}${{ matrix.config }} - working-directory: ./Package - - build-windows-rnta: - runs-on: windows-2019 - steps: - - name: Support longpaths - run: git config --system core.longpaths true - - name: Checkout Repo - uses: actions/checkout@v2.3.3 + uses: actions/checkout@v4.2.0 with: submodules: 'true' - name: Setup MSBuild - uses: microsoft/setup-msbuild@v1.0.2 + uses: microsoft/setup-msbuild@v2 - name: Setup Node 20 - uses: actions/setup-node@v3 + uses: actions/setup-node@v4.0.4 with: node-version: 20 - + - name: Install 10.0.18362.0 Windows SDK + run: | + $sdkVersion = '10.0.18362.0' + $installerUrl = "https://go.microsoft.com/fwlink/p/?linkid=2120843&clcid=0x409&Culture=en-US&country=US&Consent=0&callingAppTelemetryId=0&passive=false&dest=https://go.microsoft.com/fwlink/?linkid=2120843" + Invoke-WebRequest -Uri $installerUrl -OutFile 'winsdksetup.exe' + Start-Process -FilePath 'winsdksetup.exe' -ArgumentList "/features OptionId.WindowsDesktopSoftwareDevelopmentKit OptionId.WindowsSoftwareDevelopmentKit, /quiet" -Wait - name: Install watchman run: choco install watchman working-directory: ./Apps/BRNPlayground - + - name: Set React-Native version ${{ matrix.react-native-version }} + run: npm run set-react-version -- ${{ matrix.react-native-version }} + working-directory: ./Apps/BRNPlayground - name: NPM Install RNTA run: npm install working-directory: ./Apps/BRNPlayground @@ -265,80 +182,162 @@ jobs: run: npm install working-directory: ./Package + + - name: RNPermissions Patch test + run: Copy-Item -Path "RNPermissions.vcxproj" -Destination "Apps\BRNPlayground\node_modules\react-native-permissions\windows\RNPermissions\RNPermissions.vcxproj" -Force + working-directory: ./ + + + + - name: NPM Generate Windows Project run: npx install-windows-test-app working-directory: ./Apps/BRNPlayground - + - name: BabylonNative build directory - run: mkdir @babylonjs/react-native/Build/uwp_x64 + run: mkdir @babylonjs/react-native/Build/uwp_${{ matrix.platform }} working-directory: ./Modules - name: CMake BabylonNative - run: cmake -G "Visual Studio 16 2019" -D CMAKE_SYSTEM_NAME=WindowsStore -D CMAKE_SYSTEM_VERSION=10.0.19041.0 -DCMAKE_UNITY_BUILD=true -D CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM=10.0.19041.0 -A x64 ./../../../react-native-windows/windows - working-directory: ./Modules/@babylonjs/react-native/Build/uwp_x64 + run: cmake -D CMAKE_SYSTEM_NAME=WindowsStore -D CMAKE_SYSTEM_VERSION=10.0 -A ${{ matrix.platform == 'x86' && 'win32' || matrix.platform}} ${{ matrix.basekit == '-BaseKit' && '-DBASEKIT_BUILD=1' || matrix.basekit}} ./../../../react-native-windows/windows + working-directory: ./Modules/@babylonjs/react-native/Build/uwp_${{ matrix.platform }} - name: Nuget restore run: nuget restore BRNPlayground.sln working-directory: ./Apps/BRNPlayground/windows - - name: Windows build BN - run: MSBuild /p:Platform="x64" /p:Configuration="Release" /m ReactNativeBabylon.sln - working-directory: ./Modules/@babylonjs/react-native/Build/uwp_x64 + - name: Windows build BN ${{ matrix.platform }} ${{ matrix.config }} + run: MSBuild /p:Platform="${{ matrix.platform == 'x86' && 'win32' || matrix.platform}}" /p:Configuration="${{ matrix.config }}" /m ReactNativeBabylon.sln + working-directory: ./Modules/@babylonjs/react-native/Build/uwp_${{ matrix.platform }} - - name: Windows build BRN - run: MSBuild /p:Platform="x64" /p:Configuration="Release" /m BRNPlayground.sln + - name: Windows build BRN ${{ matrix.platform }} ${{ matrix.config }} + run: MSBuild /p:Platform="${{ matrix.platform == 'x86' && 'win32' || matrix.platform}}" /p:Configuration="${{ matrix.config }}" ${{ matrix.basekit == '-BaseKit' && '/p:BASEKIT_BUILD=1' || matrix.basekit}} /m BRNPlayground.sln working-directory: ./Apps/BRNPlayground/windows -# Test packages - build-android-ios-065: - uses: ./.github/workflows/ios_android.yml - with: - react-native-version: '0.65' - release-version: 0.0.${GITHUB_SHA::8} - - build-android-ios-069: - uses: ./.github/workflows/ios_android.yml - with: - react-native-version: '0.69' - release-version: 0.0.${GITHUB_SHA::8} - - build-android-ios-070: - uses: ./.github/workflows/ios_android.yml - with: - react-native-version: '0.70' - release-version: 0.0.${GITHUB_SHA::8} - - build-android-ios-071: - uses: ./.github/workflows/ios_android.yml - with: - react-native-version: '0.71' - release-version: 0.0.${GITHUB_SHA::8} + - name: Gulp build ${{ matrix.platform }} + run: npx gulp package${{ matrix.platform }}${{ matrix.config }}${{ matrix.basekit == '-BaseKit' && 'BaseKit' || matrix.basekit}}RNTA + working-directory: ./Package + - name: Display structure + run: ls -R + - name: Upload Assembled ${{ matrix.platform }} Folder + uses: actions/upload-artifact@v4 + with: + name: 'Assembled${{ matrix.basekit }}-Windows${{ matrix.react-native-version }}-${{ matrix.platform }}${{ matrix.config }}' + path: Package/Assembled-Windows + - name: Upload Windows App + uses: actions/upload-artifact@v4 + with: + name: 'WindowsApp${{ matrix.basekit }}${{ matrix.react-native-version }}-${{ matrix.platform }}${{ matrix.config }}' + path: Apps/BRNPlayground/windows/AppPackages/ReactTestApp - build-windows-065: - uses: ./.github/workflows/windows.yml - with: - react-native-version: '0.65' - release-version: 0.0.${GITHUB_SHA::8} + publish-react-native: + needs: [build-typescript, android-ios-rnta, windows-rnta] + runs-on: macos-latest + strategy: + matrix: + react-native-version: ['0.73', '0.74'] + steps: + - name: Checkout Repo + uses: actions/checkout@v4.2.0 + - name: NPM Install (Binary Package) + run: npm install + working-directory: ./Package + - name: Download Assembled Folder + uses: actions/download-artifact@v4 + with: + name: 'Assembled' + path: Package/Assembled + - name: Display structure of downloaded Assembled and Assembled-Windows folders + run: ls -R + - name: Version & Publish Package @babylonjs/react-native + run: | + npm version --no-git-tag-version 10.0.0 + npm publish --access public --dry-run + working-directory: ./Package/Assembled + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - build-windows-069: - uses: ./.github/workflows/windows.yml - with: - react-native-version: '0.69' - release-version: 0.0.${GITHUB_SHA::8} + publish-android-ios: + needs: [build-typescript, android-ios-rnta, windows-rnta] + runs-on: macos-latest + strategy: + matrix: + react-native-version: ['0.73', '0.74'] + basekit: ['', '-BaseKit'] + steps: + - name: Checkout Repo + uses: actions/checkout@v4.2.0 + - name: NPM Install (Binary Package) + run: npm install + working-directory: ./Package + - name: Download Assembled${{ matrix.basekit }}-android ${{ matrix.react-native-version }} Folder + uses: actions/download-artifact@v4 + with: + name: 'Assembled${{ matrix.basekit }}-android${{ matrix.react-native-version }}' + path: Package/Assembled + merge-multiple: true + - name: Download Assembled${{ matrix.basekit }}-ios ${{ matrix.react-native-version }} Folder + uses: actions/download-artifact@v4 + with: + name: 'Assembled${{ matrix.basekit }}-ios${{ matrix.react-native-version }}' + path: Package/Assembled + merge-multiple: true + - name: Display structure of downloaded Assembled folder + run: ls -R + - name: Version & Publish Package @babylonjs/react-native${{ matrix.basekit }}-iosandroid + run: | + npm version --no-git-tag-version 10.0.0 + npm publish --access public --dry-run + working-directory: ./Package/Assembled + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - build-windows-070: - uses: ./.github/workflows/windows.yml - with: - react-native-version: '0.70' - release-version: 0.0.${GITHUB_SHA::8} + publish-windows: + needs: [build-typescript, android-ios-rnta, windows-rnta] + runs-on: macos-latest + strategy: + matrix: + react-native-version: ['0.73', '0.74'] + basekit: ['', '-BaseKit'] + steps: + - name: Checkout Repo + uses: actions/checkout@v4.2.0 + - name: NPM Install (Binary Package) + run: npm install + working-directory: ./Package - build-windows-071: - uses: ./.github/workflows/windows.yml - with: - react-native-version: '0.71' - release-version: 0.0.${GITHUB_SHA::8} + - name: Download Assembled${{ matrix.basekit }}-Windows ${{ matrix.react-native-version }} x64Debug Folder + uses: actions/download-artifact@v4 + with: + name: 'Assembled${{ matrix.basekit }}-Windows${{ matrix.react-native-version }}-x64Debug' + path: Package/Assembled + merge-multiple: true + - name: Download Assembled${{ matrix.basekit }}-Windows ${{ matrix.react-native-version }} x64Release Folder + uses: actions/download-artifact@v4 + with: + name: 'Assembled${{ matrix.basekit }}-Windows${{ matrix.react-native-version }}-x64Release' + path: Package/Assembled + merge-multiple: true + + - name: Download Assembled${{ matrix.basekit }}-Windows ${{ matrix.react-native-version }} ARM64Debug Folder + uses: actions/download-artifact@v4 + with: + name: 'Assembled${{ matrix.basekit }}-Windows${{ matrix.react-native-version }}-ARM64Debug' + path: Package/Assembled + merge-multiple: true + - name: Download Assembled${{ matrix.basekit }}-Windows ${{ matrix.react-native-version }} ARM64Release Folder + uses: actions/download-artifact@v4 + with: + name: 'Assembled${{ matrix.basekit }}-Windows${{ matrix.react-native-version }}-ARM64Release' + path: Package/Assembled + merge-multiple: true - build-typescript: - uses: ./.github/workflows/typescript.yml - with: - release-version: 0.0.${GITHUB_SHA::8} + - name: Display structure of downloaded Assembled folder + run: ls -R + - name: Version & Publish Package @babylonjs/react-native${{ matrix.basekit }}-windows + run: | + npm version --no-git-tag-version 10.0.0 + npm publish --access public --dry-run + working-directory: ./Package/Assembled + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d4d0f478d..66a43e37c 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -73,7 +73,7 @@ jobs: runs-on: macos-latest steps: - name: Checkout Repo - uses: actions/checkout@v2.3.3 + uses: actions/checkout@v4.2.0 - name: NPM Install (Binary Package) run: npm install working-directory: ./Package diff --git a/.github/workflows/publish_preview.yml b/.github/workflows/publish_preview.yml index f8f609030..d450aaf19 100644 --- a/.github/workflows/publish_preview.yml +++ b/.github/workflows/publish_preview.yml @@ -89,7 +89,7 @@ jobs: runs-on: macos-latest steps: - name: Checkout Repo - uses: actions/checkout@v2.3.3 + uses: actions/checkout@v4.2.0 - name: NPM Install (Binary Package) run: npm install working-directory: ./Package diff --git a/.github/workflows/test_version.yml b/.github/workflows/test_version.yml index 978e48ece..6442f3370 100644 --- a/.github/workflows/test_version.yml +++ b/.github/workflows/test_version.yml @@ -33,11 +33,11 @@ jobs: runs-on: windows-2019 steps: - name: Checkout Repo - uses: actions/checkout@v2.3.3 + uses: actions/checkout@v4.2.0 - name: Setup MSBuild - uses: microsoft/setup-msbuild@v1.0.2 + uses: microsoft/setup-msbuild@v2 - name: Setup Node ${{ github.event.inputs.Node_Version }} - uses: actions/setup-node@v3 + uses: actions/setup-node@v4.0.4 with: node-version: ${{ github.event.inputs.Node_Version }} - name: Build Playground Windows x64 @@ -66,13 +66,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Repo - uses: actions/checkout@v2.3.3 + uses: actions/checkout@v4.2.0 - name: Setup Node ${{ github.event.inputs.Node_Version }} - uses: actions/setup-node@v3 + uses: actions/setup-node@v4.0.4 with: node-version: ${{ github.event.inputs.Node_Version }} - name: Setup Java - uses: actions/setup-java@v3 + uses: actions/setup-java@v4.4.0 with: distribution: 'temurin' java-version: '17' @@ -103,7 +103,7 @@ jobs: runs-on: macos-12 steps: - name: Checkout Repo - uses: actions/checkout@v2.3.3 + uses: actions/checkout@v4.2.0 - name: Clone iOS Toolchain run: | git clone https://github.com/leetal/ios-cmake.git @@ -138,13 +138,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Repo - uses: actions/checkout@v2.3.3 + uses: actions/checkout@v4.2.0 - name: Setup Node ${{ github.event.inputs.Node_Version }} - uses: actions/setup-node@v3 + uses: actions/setup-node@v4.0.4 with: node-version: ${{ github.event.inputs.Node_Version }} - name: Setup Java - uses: actions/setup-java@v3 + uses: actions/setup-java@v4.4.0 with: distribution: 'temurin' java-version: '17' @@ -173,7 +173,7 @@ jobs: runs-on: macos-12 steps: - name: Checkout Repo - uses: actions/checkout@v2.3.3 + uses: actions/checkout@v4.2.0 - name: Clone iOS Toolchain run: | git clone https://github.com/leetal/ios-cmake.git diff --git a/.github/workflows/typescript.yml b/.github/workflows/typescript.yml index 72b46384b..250e7689a 100644 --- a/.github/workflows/typescript.yml +++ b/.github/workflows/typescript.yml @@ -11,13 +11,9 @@ jobs: runs-on: macos-latest steps: - name: Checkout Repo - uses: actions/checkout@v2.3.3 + uses: actions/checkout@v4.2.0 with: submodules: 'recursive' - - name: Setup Node 16 - uses: actions/setup-node@v3 - with: - node-version: 16 - name: NPM Install (Playground) run: npm install working-directory: ./Apps/Playground diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index f07803716..d6f183602 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -15,13 +15,13 @@ jobs: runs-on: windows-2019 steps: - name: Checkout Repo - uses: actions/checkout@v2.3.3 + uses: actions/checkout@v4.2.0 with: submodules: 'true' - name: Setup MSBuild - uses: microsoft/setup-msbuild@v1.0.2 + uses: microsoft/setup-msbuild@v2 - name: Setup Node 16 - uses: actions/setup-node@v3 + uses: actions/setup-node@v4.0.4 with: node-version: 16 - name: Setup NuGet diff --git a/Apps/BRNPlayground/package-lock.json b/Apps/BRNPlayground/package-lock.json index 8aa2b7862..ff50157d9 100644 --- a/Apps/BRNPlayground/package-lock.json +++ b/Apps/BRNPlayground/package-lock.json @@ -37,7 +37,7 @@ "jest": "^29.6.3", "mkdirp": "^1.0.0", "prettier": "2.8.8", - "react-native-test-app": "^3.10.3", + "react-native-test-app": "^3.10.16", "react-test-renderer": "18.2.0", "typescript": "5.0.4" }, @@ -5391,10 +5391,14 @@ } }, "node_modules/@rnx-kit/react-native-host": { - "version": "0.4.12", - "resolved": "https://registry.npmjs.org/@rnx-kit/react-native-host/-/react-native-host-0.4.12.tgz", - "integrity": "sha512-LVOoF6/+s8JnkCn5hjZTzdyjkL54LOh1vHAimeKeGc427SPEAmHLpOohDNiMhq0kR/jY3qn8TkX8X7C8gXNWKQ==", + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@rnx-kit/react-native-host/-/react-native-host-0.5.0.tgz", + "integrity": "sha512-ZuHDl899uZyqk4qcBkGMRmVp2u6EXLikMAVd0ry7u2gWll0dZSfM2TbDHGq5Z0d8qpdAdSTRB0bYpvwmEznxVQ==", "dev": true, + "license": "MIT", + "engines": { + "node": ">=16.17" + }, "peerDependencies": { "react-native": ">=0.66" } @@ -13722,12 +13726,16 @@ } }, "node_modules/react-native-test-app": { - "version": "3.10.3", - "resolved": "https://registry.npmjs.org/react-native-test-app/-/react-native-test-app-3.10.3.tgz", - "integrity": "sha512-mamLagA1cBffcM8co8g/O1SJi2PsjDU63BG0GVTOVNPzie9hb1K0CWlMw+jMMXXHeKGvinrZEIaJXjIISn7PlQ==", + "version": "3.10.16", + "resolved": "https://registry.npmjs.org/react-native-test-app/-/react-native-test-app-3.10.16.tgz", + "integrity": "sha512-0zmU2cQJtlt+Jo1wb2ZZ/V4SKmYtcBTSvHpTl1m60AB6xQyW/JAEuoz7Ir7x/WRGbe1qSHdwJXEPgYVEWOrizQ==", "dev": true, + "license": "MIT", + "workspaces": [ + "example" + ], "dependencies": { - "@rnx-kit/react-native-host": "^0.4.12", + "@rnx-kit/react-native-host": "^0.5.0", "ajv": "^8.0.0", "cliui": "^8.0.0", "fast-xml-parser": "^4.0.0", @@ -13745,12 +13753,12 @@ "node": ">=16.17" }, "peerDependencies": { - "@callstack/react-native-visionos": "0.73 - 0.75", + "@callstack/react-native-visionos": "0.73 - 0.76", "@expo/config-plugins": ">=5.0", "react": "17.0.1 - 19.0", - "react-native": "0.66 - 0.75 || >=0.76.0-0 <0.76.0", + "react-native": "0.66 - 0.76 || >=0.77.0-0 <0.77.0", "react-native-macos": "^0.0.0-0 || 0.66 || 0.68 || 0.71 - 0.75", - "react-native-windows": "^0.0.0-0 || 0.66 - 0.75" + "react-native-windows": "^0.0.0-0 || 0.66 - 0.76" }, "peerDependenciesMeta": { "@callstack/react-native-visionos": { diff --git a/Apps/BRNPlayground/package.json b/Apps/BRNPlayground/package.json index af9e5f435..dd3840cb8 100644 --- a/Apps/BRNPlayground/package.json +++ b/Apps/BRNPlayground/package.json @@ -14,6 +14,7 @@ "start": "react-native start", "test": "jest", "windows": "react-native run-windows --sln windows/BRNPlayground.sln", + "set-react-version": "node scripts/set-react-version.mjs", "postinstall": "node ./postinstall.js" }, "dependencies": { @@ -45,7 +46,7 @@ "jest": "^29.6.3", "mkdirp": "^1.0.0", "prettier": "2.8.8", - "react-native-test-app": "^3.10.3", + "react-native-test-app": "^3.10.16", "react-test-renderer": "18.2.0", "typescript": "5.0.4" }, diff --git a/Apps/BRNPlayground/postinstall.js b/Apps/BRNPlayground/postinstall.js index 62261b46d..40a4387db 100644 --- a/Apps/BRNPlayground/postinstall.js +++ b/Apps/BRNPlayground/postinstall.js @@ -28,17 +28,18 @@ function postInstall() { exec("npm install --legacy-peer-deps", { cwd: "../../Modules/@babylonjs/react-native", }); - +/* if (os.platform() === "darwin") { iosCMake(); - exec("npm install && npx gulp buildIOSRNTA", { + exec("npm install && npx gulp buildRNTAios", { cwd: "../../Package", }); console.log(chalk.black.bgCyan("Installing iOS pods...")); exec("pod install", { cwd: "ios" }); } + */ } postInstall(); diff --git a/Apps/BRNPlayground/scripts/helpers.js b/Apps/BRNPlayground/scripts/helpers.js new file mode 100644 index 000000000..d0566f20c --- /dev/null +++ b/Apps/BRNPlayground/scripts/helpers.js @@ -0,0 +1,186 @@ +// @ts-check +"use strict"; + +const nodefs = require("node:fs"); +const path = require("node:path"); +const { fileURLToPath } = require("node:url"); + +const npmRegistryBaseURL = "https://registry.npmjs.org/"; + +/** + * Fetches package metadata from the npm registry. + * @param {string} pkg + * @param {string=} distTag + */ +function fetchPackageMetadata(pkg, distTag) { + const init = { + headers: { + Accept: + "application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*", + }, + }; + const url = distTag + ? npmRegistryBaseURL + pkg + "/" + distTag + : npmRegistryBaseURL + pkg; + return fetch(url, init).then((res) => res.json()); +} + +/** + * Finds the specified file using Node module resolution. + * @param {string} file + * @param {string=} startDir + * @returns {string | undefined} + */ +function findFile(file, startDir = process.cwd(), fs = nodefs) { + let currentDir = startDir; + let candidate = path.join(currentDir, file); + while (!fs.existsSync(candidate)) { + const nextDir = path.dirname(currentDir); + if (nextDir === currentDir) { + return undefined; + } + + currentDir = nextDir; + candidate = path.join(currentDir, file); + } + + return candidate; +} + +/** + * Finds nearest relative path to a file or directory from current path. + * @param {string} fileOrDirName Path to the file or directory to find. + * @param {string=} currentDir The current working directory. Mostly used for unit tests. + * @returns {string | null} Nearest path to given file or directory; null if not found + */ +function findNearest( + fileOrDirName, + currentDir = path.resolve(""), + fs = nodefs +) { + const result = findFile(fileOrDirName, currentDir, fs); + return result ? path.relative("", result) : null; +} + +/** + * Returns whether the current module is main. + * @param {string} url + * @param {string} script + * @returns {boolean} + */ +function isMain(url, script = process.argv[1]) { + return Boolean( + url && script && fileURLToPath(url) === require.resolve(script) + ); +} + +/** + * @template T + * @param {(...args: any[]) => T} fn + * @returns {(...args: any[]) => T} + */ +function memo(fn) { + /** @type {T} */ + let result; + return (...args) => { + if (result === undefined) { + result = fn(...args); + } + return result; + }; +} + +/** + * Reads text file at specified path. + * @param {import("node:fs").PathLike} path + * @returns {string} + */ +function readTextFile(path, fs = nodefs) { + return fs.readFileSync(path, { encoding: "utf-8" }); +} + +/** + * Reads and parses JSON file at specified path. + * @template [T = Record] + * @param {import("node:fs").PathLike} path + * @returns {T} + */ +function readJSONFile(path, fs = nodefs) { + return JSON.parse(readTextFile(path, fs)); +} + +/** + * @template T + * @param {string[]} dependencyChain + * @param {string=} startDir + * @returns {T} + */ +function requireTransitive(dependencyChain, startDir = process.cwd()) { + const p = dependencyChain.reduce((curr, next) => { + const p = require.resolve(next + "/package.json", { paths: [curr] }); + return path.dirname(p); + }, startDir); + return require(p); +} + +/** + * Returns the numerical value equivalent of the specified version string. + * @param {string} version + * @returns {number} + */ +function toVersionNumber(version) { + const [major, minor = 0, patch = 0] = version.split("-")[0].split("."); + return v(Number(major), Number(minor), Number(patch)); +} + +/** + * Returns the numerical value of the individual version identifiers combined. + * @param {number} major + * @param {number} minor + * @param {number} patch + * @returns {number} + */ +function v(major, minor, patch) { + return major * 1000000 + minor * 1000 + patch; +} + +/** + * Writes data to specified file path. + * @param {string} file + * @param {string} data + * @returns {Promise} + */ +function writeTextFile(file, data, fs = nodefs.promises) { + return fs.writeFile(file, data, { encoding: "utf-8", mode: 0o644 }); +} + +/** + * Returns version string of specified module. + * @param {string} module + * @returns {string} + */ +function getPackageVersion(module, startDir = process.cwd(), fs = nodefs) { + const options = { paths: [startDir] }; + const manifestPath = require.resolve(`${module}/package.json`, options); + const mod = readJSONFile(manifestPath, fs); + const version = mod["version"]; + if (typeof version !== "string") { + throw new Error(`Invalid version number: ${module}@${version}`); + } + + return version; +} + +exports.fetchPackageMetadata = fetchPackageMetadata; +exports.findFile = findFile; +exports.findNearest = findNearest; +exports.getPackageVersion = getPackageVersion; +exports.isMain = isMain; +exports.memo = memo; +exports.npmRegistryBaseURL = npmRegistryBaseURL; +exports.readJSONFile = readJSONFile; +exports.readTextFile = readTextFile; +exports.requireTransitive = requireTransitive; +exports.toVersionNumber = toVersionNumber; +exports.v = v; +exports.writeTextFile = writeTextFile; diff --git a/Apps/BRNPlayground/scripts/set-react-version.mjs b/Apps/BRNPlayground/scripts/set-react-version.mjs new file mode 100644 index 000000000..328b30512 --- /dev/null +++ b/Apps/BRNPlayground/scripts/set-react-version.mjs @@ -0,0 +1,317 @@ +// @ts-check + +/** + * Reminder that this script is meant to be runnable without installing + * dependencies. It can therefore not rely on any external libraries. + */ +import { promises as fs } from "node:fs"; +import * as os from "node:os"; +import * as path from "node:path"; +import { + fetchPackageMetadata, + isMain, + npmRegistryBaseURL, + readJSONFile, + readTextFile, + toVersionNumber, + v, +} from "./helpers.js"; + +/** + * @typedef {import("./types.js").Manifest} Manifest + */ + +/** + * Returns whether specified string is a valid version number. + * @param {string} v + * @return {boolean} + */ +function isValidVersion(v) { + return /^\d+\.\d+$/.test(v); +} + +/** + * Type-safe `Object.keys()` + * @template {Record} T + * @param {T} obj + * @returns {(keyof T)[]} + */ +function keys(obj) { + return /** @type {(keyof T)[]} */ (Object.keys(obj)); +} + +/** + * @param {string} filename + * @param {string | RegExp} searchValue + * @param {string} replaceValue + * @returns {Promise} + */ +function searchReplaceInFile(filename, searchValue, replaceValue) { + const current = readTextFile(filename); + const updated = current.replace(searchValue, replaceValue); + return updated === current + ? Promise.resolve() + : fs.writeFile(filename, updated); +} + +/** + * Disables [Jetifier](https://developer.android.com/tools/jetifier). + * + * Jetifier is only necessary when you depend on code that has not yet migrated + * to AndroidX. If we only deal with modern code, disabling it makes builds + * slightly faster. + */ +function disableJetifier() { + return searchReplaceInFile( + "android/gradle.properties", + "android.enableJetifier=true", + "android.enableJetifier=false" + ); +} + +function disableWebStorage() { + return searchReplaceInFile( + "package.json", + /\s+"@react-native-webapis\/web-storage":.*/, + "" + ); +} + +/** + * Infer the React Native version an out-of-tree platform package is based on. + * @param {Manifest} manifest + * @returns {string} + */ +function inferReactNativeVersion({ name, version, dependencies = {} }) { + const codegenVersion = dependencies["@react-native/codegen"]; + if (!codegenVersion) { + throw new Error( + `Unable to determine the react-native version that ${name}@${version} is based on` + ); + } + + const rnVersion = codegenVersion.split(".").slice(0, 2).join(".") + ".0-0"; + return rnVersion[0] === "^" || rnVersion[0] === "~" + ? rnVersion + : "^" + rnVersion; +} + +/** + * Fetches package information. + * @param {string} pkg + * @param {string} version + * @return {Promise} + */ +function fetchPackageInfo(pkg, version) { + return fetchPackageMetadata(pkg) + .then(({ ["dist-tags"]: distTags, versions }) => { + const tags = [version, version + "-stable", "v" + version + "-stable"]; + for (const t of tags) { + if (distTags[t]) { + return distTags[t]; + } + } + + const allVersions = Object.keys(versions); + for (let i = allVersions.length - 1; i >= 0; --i) { + const v = allVersions[i]; + if (v.startsWith(version)) { + return v; + } + } + }) + .then((foundVersion) => { + if (!foundVersion) { + console.warn(`No match found for '${pkg}@${version}'`); + return undefined; + } + return fetch(npmRegistryBaseURL + pkg + "/" + foundVersion); + }) + .then((res) => res?.json() ?? /** @type {Manifest} */ ({})) + .then(({ version, dependencies = {}, peerDependencies = {} }) => { + return { version, dependencies, peerDependencies }; + }); +} + +/** + * Returns an object with common dependencies. + * @param {string} v + * @param {Manifest} manifest + * @return {Promise>} + */ +async function resolveCommonDependencies( + v, + { dependencies = {}, peerDependencies = {} } +) { + const [rnBabelPresetVersion, rnMetroConfigVersion, metroBabelPresetVersion] = + await (async () => { + if (["^", "canary", "nightly"].some((tag) => v.includes(tag))) { + return [v, v, undefined]; + } + + const [ + { version: rnBabelPresetVersion }, + { version: rnMetroConfigVersion }, + { version: metroBabelPresetVersion }, + ] = await Promise.all([ + fetchPackageInfo("@react-native/babel-preset", v), + fetchPackageInfo("@react-native/metro-config", v), + (async () => { + // Metro bumps and publishes all packages together, meaning we can use + // `metro-react-native-babel-transformer` to determine the version of + // `metro-react-native-babel-preset` that should be used. + const version = dependencies["metro-react-native-babel-transformer"]; + if (version) { + return { version }; + } + + // `metro-react-native-babel-transformer` is no longer a direct dependency + // of `react-native`. As of 0.72, we should go through + // `@react-native-community/cli-plugin-metro` instead. + const cliVersion = dependencies["@react-native-community/cli"] + .replace("^", "") + .split(".") + .slice(0, 2) + .join("."); + const metroPluginInfo = await fetchPackageInfo( + "@react-native-community/cli-plugin-metro", + cliVersion + ); + return { version: metroPluginInfo.dependencies?.["metro"] }; + })(), + ]); + return [ + rnBabelPresetVersion, + rnMetroConfigVersion, + metroBabelPresetVersion, + ]; + })(); + + return { + "@react-native-community/cli": dependencies["@react-native-community/cli"], + "@react-native-community/cli-platform-android": + dependencies["@react-native-community/cli-platform-android"], + "@react-native-community/cli-platform-ios": + dependencies["@react-native-community/cli-platform-ios"], + "@react-native/babel-preset": rnBabelPresetVersion, + "@react-native/metro-config": rnMetroConfigVersion, + "metro-react-native-babel-preset": metroBabelPresetVersion, + react: peerDependencies["react"], + }; +} + +/** + * Returns a profile for specified version. + * @param {string} v + * @param {boolean} coreOnly + * @return {Promise>} + */ +async function getProfile(v, coreOnly) { + // @ts-ignore + const manifest = /** @type {Manifest} */ (readJSONFile("package.json")); + /*const visionos = manifest.defaultPlatformPackages?.["visionos"]; + if (!visionos) { + throw new Error("Missing platform package for visionOS"); + }*/ + const versions = { + core: fetchPackageInfo("react-native", v), + macos: coreOnly + ? Promise.resolve({ version: undefined }) + : fetchPackageInfo("react-native-macos", v), + /*visionos: coreOnly + ? Promise.resolve({ version: undefined }) + : fetchPackageInfo(visionos, v),*/ + windows: coreOnly + ? Promise.resolve({ version: undefined }) + : fetchPackageInfo("react-native-windows", v), + }; + const reactNative = await versions.core; + const commonDeps = await resolveCommonDependencies(v, reactNative); + + /** @type {(manifest: Manifest) => string | undefined} */ + const getVersion = ({ version }) => version; + return { + ...commonDeps, + "react-native": reactNative.version, + "react-native-macos": await versions.macos.then(getVersion), + "react-native-windows": await versions.windows.then(getVersion), + //[visionos]: await versions.visionos.then(getVersion), + }; +} + +/** + * Sets specified React Native version. + * @param {string} version + * @param {boolean} coreOnly + * @return {Promise} + */ +export async function setReactVersion(version, coreOnly) { + /** @type {fs.FileHandle | undefined} */ + let fd; + try { + const profile = await getProfile(version, coreOnly); + console.dir(profile, { depth: null }); + + const manifests = ["package.json"]; + for (const manifestPath of manifests) { + const manifest = /** @type {Manifest} */ (readJSONFile(manifestPath)); + const { dependencies, devDependencies, resolutions = {} } = manifest; + if (!devDependencies) { + throw new Error("Expected 'devDependencies' to be declared"); + } + + for (const packageName of keys(profile)) { + const deps = dependencies?.[packageName] + ? dependencies + : devDependencies; + deps[packageName] = profile[packageName]; + + // Reset resolutions so we don't get old packages + resolutions[packageName] = undefined; + } + + // Reset resolutions of the nested type e.g., + // `@react-native/community-cli-plugin/@react-native-community/cli-server-api` + for (const pkg of Object.keys(resolutions)) { + if (pkg.startsWith("@react-native")) { + resolutions[pkg] = undefined; + } + } + + const tmpFile = manifestPath + ".tmp"; + fd = await fs.open(tmpFile, "w", 0o644); + await fd.write(JSON.stringify(manifest, undefined, 2)); + await fd.write(os.EOL); + await fd.close(); + fd = undefined; + await fs.rename(tmpFile, manifestPath); + } + } catch (e) { + console.error(e); + process.exitCode = 1; + } finally { + fd?.close(); + } +} + +const { [1]: script, [2]: version } = process.argv; +if (isMain(import.meta.url)) { + if (!isValidVersion(version)) { + console.log( + `Usage: ${path.basename(script)} []` + ); + process.exitCode = 1; + } else { + setReactVersion(version, process.argv.includes("--core-only")).then(() => { + const numVersion = toVersionNumber(version); + if (numVersion >= v(0, 74, 0)) { + disableJetifier(); + } + + // `@react-native-webapis/web-storage` is not compatible with codegen 0.71 + if (numVersion < v(0, 72, 0)) { + disableWebStorage(); + } + }); + } +} diff --git a/Modules/@babylonjs/react-native-windows/windows/BabylonReactNative/BabylonReactNative.vcxproj b/Modules/@babylonjs/react-native-windows/windows/BabylonReactNative/BabylonReactNative.vcxproj index dec1f250c..5fcfd22ff 100644 --- a/Modules/@babylonjs/react-native-windows/windows/BabylonReactNative/BabylonReactNative.vcxproj +++ b/Modules/@babylonjs/react-native-windows/windows/BabylonReactNative/BabylonReactNative.vcxproj @@ -193,16 +193,13 @@ JsRuntime.lib; MachineIndependentd.lib; napi.lib; - NativeCamera.lib; NativeCapture.lib; NativeEngine.lib; NativeInput.lib; NativeOptimizations.lib; NativeTracing.lib; - NativeXr.lib; nvtt.lib; OGLCompilerd.lib; - openxr_loaderd.lib; OSDependentd.lib; pvrtc.lib; spirv-cross-cored.lib; @@ -212,7 +209,6 @@ UrlLib.lib; Window.lib; XMLHttpRequest.lib; - xr.lib; WindowsApp.lib; %(AdditionalDependencies); @@ -254,16 +250,13 @@ JsRuntime.lib; MachineIndependent.lib; napi.lib; - NativeCamera.lib; NativeCapture.lib; NativeEngine.lib; NativeInput.lib; NativeOptimizations.lib; NativeTracing.lib; - NativeXr.lib; nvtt.lib; OGLCompiler.lib; - openxr_loader.lib; OSDependent.lib; pvrtc.lib; spirv-cross-core.lib; @@ -273,7 +266,6 @@ UrlLib.lib; Window.lib; XMLHttpRequest.lib; - xr.lib; WindowsApp.lib; %(AdditionalDependencies); diff --git a/Modules/@babylonjs/react-native/shared/BabylonNative.cpp b/Modules/@babylonjs/react-native/shared/BabylonNative.cpp index ac06316a9..ffdead0c9 100644 --- a/Modules/@babylonjs/react-native/shared/BabylonNative.cpp +++ b/Modules/@babylonjs/react-native/shared/BabylonNative.cpp @@ -2,10 +2,24 @@ #include #include + #ifndef BASEKIT_BUILD #include #include + +#ifdef WIN32 +#pragma comment(lib, "NativeCamera.lib") +#pragma comment(lib, "NativeXr.lib") +#pragma comment(lib, "xr.lib") +#ifdef _DEBUG + #pragma comment(lib, "openxr_loaderd.lib") +#else + #pragma comment(lib, "openxr_loader.lib") +#endif #endif + +#endif + #include #include #include diff --git a/Package/gulpfile.js b/Package/gulpfile.js index 5397fbbfd..d52af87e1 100644 --- a/Package/gulpfile.js +++ b/Package/gulpfile.js @@ -14,6 +14,7 @@ let assembledWindowsDir = 'Assembled-Windows'; let basekitBuild = false; let cmakeBasekitBuildDefinition = ''; let basekitPackagePath = ''; +let playgroundDirectory = '../Apps/Playground/Playground/'; function exec(command, workingDirectory = '.', logCommand = true) { if (logCommand) { @@ -91,6 +92,15 @@ const buildIphoneSimulator = async () => { exec('xcodebuild -sdk iphonesimulator -arch x86_64 -configuration Release -project ReactNativeBabylon.xcodeproj -scheme BabylonNative build CODE_SIGNING_ALLOWED=NO', 'iOS/Build'); }; +const buildIphoneOSRNTA = async () => { + exec('xcodebuild -sdk iphoneos -configuration Release -project ReactNativeBabylon.xcodeproj -scheme BabylonNative build CODE_SIGNING_ALLOWED=NO', 'iOS/Build'); + //exec('xcodebuild -sdk iphoneos -configuration Release -workspace BRNPlayground.xcworkspace -scheme ReactTestApp build CODE_SIGNING_ALLOWED=NO -archivePath ./playgroundiOS.xcarchive archive', '../Apps/BRNPlayground/ios/Build'); +}; + +const buildIphoneSimulatorRNTA = async () => { + exec('xcodebuild -sdk iphonesimulator -arch x86_64 -configuration Release -project ReactNativeBabylon.xcodeproj -scheme BabylonNative build CODE_SIGNING_ALLOWED=NO', 'iOS/Build'); + //exec('xcodebuild -sdk iphonesimulator -arch x86_64 -configuration Release -workspace BRNPlayground.xcworkspace -scheme ReactTestApp build CODE_SIGNING_ALLOWED=NO -archivePath ./playgroundSimulator.xcarchive archive', '../Apps/BRNPlayground/ios/Build'); +}; const buildAndroid = async () => { const basekitBuildProp = basekitBuild ? "-PBASEKIT_BUILD=1" : ""; @@ -99,7 +109,21 @@ const buildAndroid = async () => { const buildAndroidRNTA = async () => { const basekitBuildProp = basekitBuild ? "-PBASEKIT_BUILD=1" : ""; - exec(`./gradlew babylonjs_react-native:assembleRelease --stacktrace --info ${basekitBuildProp}`, '../Apps/BRNPlayground/android'); + exec(`./gradlew app:assembleRelease --stacktrace --info ${basekitBuildProp}`, '../Apps/BRNPlayground/android'); + const baseKitOrFull = basekitBuild ? '-basekit' : ''; + const srcFile = '../Apps/BRNPlayground/android/app/build/outputs/apk/release/app-release.apk'; + const newName = `app-release${baseKitOrFull}.apk`; + + const apkFolder = '../Apps/BRNPlayground/apk'; + if (!fs.existsSync(apkFolder)) { + fs.mkdirSync(apkFolder, { recursive: true }); + } + await new Promise(resolve => { + gulp.src(srcFile) + .pipe(rename(newName)) + .pipe(gulp.dest(apkFolder)) + .on('end', resolve); + }); }; const makeUWPProjectPlatform = async (name, arch) => { @@ -212,8 +236,8 @@ const copyIOSAndroidCommonFiles = () => { const copyIOSFiles = async () => { await new Promise(resolve => { - gulp.src('../Apps/Playground/Playground/node_modules/@babylonjs/react-native-iosandroid/ios/*.h') - .pipe(gulp.src('../Apps/Playground/Playground/node_modules/@babylonjs/react-native-iosandroid/ios/*.mm')) + gulp.src(`${playgroundDirectory}/node_modules/@babylonjs/react-native-iosandroid/ios/*.h`) + .pipe(gulp.src(`${playgroundDirectory}/node_modules/@babylonjs/react-native-iosandroid/ios/*.mm`)) // This xcodeproj is garbage that we don't need in the package, but `pod install` ignores the package if it doesn't contain at least one xcodeproj. 🤷🏼‍♂️ .pipe(gulp.src('iOS/Build/ReactNativeBabylon.xcodeproj**/**/*')) .pipe(gulp.dest(`${assemblediOSAndroidDir}/ios`)) @@ -225,6 +249,14 @@ const copyIOSFiles = async () => { .pipe(gulp.dest(`${assemblediOSAndroidDir}/ios/include`)) .on('end', resolve); }); + + // this file is part of Android but copied from iOS cmake fetching because easier than finding gradle temp build directory + await new Promise(resolve => { + gulp.src('../Package/iOS/Build/_deps/babylonnative-src/Dependencies/xr/Source/ARCore/Include/*') + .pipe(gulp.dest(`${assemblediOSAndroidDir}/android/include`)) + .on('end', resolve); + }); + }; const createIOSUniversalLibs = async () => { @@ -298,20 +330,14 @@ const createXCFrameworks = async () => { const copyAndroidFiles = async () => { await new Promise(resolve => { gulp.src(`${basekitPackagePath}Android/build.gradle`) - .pipe(gulp.src('../Apps/Playground/Playground/node_modules/@babylonjs/react-native-iosandroid/android/src**/main/AndroidManifest.xml')) - .pipe(gulp.src('../Apps/Playground/Playground/node_modules/@babylonjs/react-native-iosandroid/android/src**/main/java/**/*')) + .pipe(gulp.src(`${playgroundDirectory}/node_modules/@babylonjs/react-native-iosandroid/android/src**/main/AndroidManifest.xml`)) + .pipe(gulp.src(`${playgroundDirectory}/node_modules/@babylonjs/react-native-iosandroid/android/src**/main/java/**/*`)) .pipe(gulp.dest(`${assemblediOSAndroidDir}/android`)) .on('end', resolve); }); await new Promise(resolve => { - gulp.src('../Package/iOS/Build/_deps/babylonnative-src/Dependencies/xr/Source/ARCore/Include/*') - .pipe(gulp.dest(`${assemblediOSAndroidDir}/android/include`)) - .on('end', resolve); - }); - - await new Promise(resolve => { - const jnidir = '../Apps/Playground/Playground/node_modules/@babylonjs/react-native-iosandroid/android/build/intermediates/library_and_local_jars_jni/release/jni/**'; + const jnidir = `${playgroundDirectory}/node_modules/@babylonjs/react-native-iosandroid/android/build/intermediates/library_and_local_jars_jni/release/jni/**`; gulp.src(`${jnidir}/libBabylonNative.so`) .pipe(gulp.dest(`${assemblediOSAndroidDir}/android/src/main/jniLibs/`)) .on('end', resolve); @@ -323,7 +349,7 @@ const copyAndroidFiles = async () => { const versionIndex = process.argv.indexOf('--reactNative'); if (versionIndex != -1 && process.argv[versionIndex + 1] != '0.71') { await new Promise(resolve => { - gulp.src('../Apps/Playground/Playground/node_modules/@babylonjs/react-native-iosandroid/android/build/intermediates/cmake/release/obj/{arm64-v8a,armeabi-v7a,x86}/libturbomodulejsijni.so') + gulp.src(`${playgroundDirectory}/node_modules/@babylonjs/react-native-iosandroid/android/build/intermediates/cmake/release/obj/{arm64-v8a,armeabi-v7a,x86}/libturbomodulejsijni.so`) .pipe(gulp.dest(`${assemblediOSAndroidDir}/android/src/main/jniLibs/`)) .on('end', resolve); }); @@ -421,6 +447,38 @@ const copyOpenXRHelperHeaders = () => { .pipe(gulp.dest(`${assembledWindowsDir}/windows/include`)); } +const copyx64DebugRNTAFiles = gulp.series( + createUWPDirectories, + gulp.parallel( + copyCommonFilesUWP, + copyx64DebugUWPFiles, + copyVCXProjUWPFiles, + copyOpenXRInfoFiles, + copyOpenXRPreviewHeaders, + copyOpenXRUtilityHeaders, + copyOpenXRHelperHeaders)); + +const copyx64DebugBaseKitRNTAFiles = gulp.series( + createUWPDirectories, + gulp.parallel( + copyCommonFilesUWP, + copyx64DebugUWPFiles, + copyVCXProjUWPFiles)); + +const copyx64ReleaseRNTAFiles = gulp.series(createUWPDirectories, copyx64ReleaseUWPFiles); +const copyx64ReleaseBaseKitRNTAFiles = gulp.series(createUWPDirectories, copyx64ReleaseUWPFiles); + + +const copyARM64DebugRNTAFiles = gulp.series(createUWPDirectories, copyARM64DebugUWPFiles); +const copyARM64DebugBaseKitRNTAFiles = gulp.series(createUWPDirectories, copyARM64DebugUWPFiles); +const copyARM64ReleaseRNTAFiles = gulp.series(createUWPDirectories, copyARM64ReleaseUWPFiles); +const copyARM64ReleaseBaseKitRNTAFiles = gulp.series(createUWPDirectories, copyARM64ReleaseUWPFiles); + +const copyx86DebugRNTAFiles = gulp.series(createUWPDirectories, copyx86DebugUWPFiles); +const copyx86DebugBaseKitRNTAFiles = gulp.series(createUWPDirectories, copyx86DebugUWPFiles); +const copyx86ReleaseRNTAFiles = gulp.series(createUWPDirectories, copyx86ReleaseUWPFiles); +const copyx86ReleaseBaseKitRNTAFiles = gulp.series(createUWPDirectories, copyx86ReleaseUWPFiles); + const copyUWPFiles = gulp.series( createUWPDirectories, basekitBuild ? @@ -495,12 +553,10 @@ const validateAssembled = async () => { checkDirectory(actual, expected, 'Assembled'); } -const validateAssemblediOSAndroid = async () => { - let expectediosandroid = [ +const validateAssembledAndroid = async () => { + let expectedandroid = [ `${assemblediOSAndroidDir}/android`, `${assemblediOSAndroidDir}/android/build.gradle`, - `${assemblediOSAndroidDir}/android/include`, - `${assemblediOSAndroidDir}/android/include/IXrContextARCore.h`, `${assemblediOSAndroidDir}/android/src`, `${assemblediOSAndroidDir}/android/src/main`, `${assemblediOSAndroidDir}/android/src/main/AndroidManifest.xml`, @@ -522,6 +578,28 @@ const validateAssemblediOSAndroid = async () => { `${assemblediOSAndroidDir}/android/src/main/jniLibs/x86/libBabylonNative.so`, `${assemblediOSAndroidDir}/android/src/main/jniLibs/x86_64`, `${assemblediOSAndroidDir}/android/src/main/jniLibs/x86_64/libBabylonNative.so`, + ]; + + const versionIndex = process.argv.indexOf('--reactNative'); + if (versionIndex != -1) { + if (process.argv[versionIndex + 1] !== '0.71') { + const expectedandroidNot071 = [ + `${assemblediOSAndroidDir}/android/src/main/jniLibs/arm64-v8a/libturbomodulejsijni.so`, + `${assemblediOSAndroidDir}/android/src/main/jniLibs/armeabi-v7a/libturbomodulejsijni.so`, + `${assemblediOSAndroidDir}/android/src/main/jniLibs/x86/libturbomodulejsijni.so`, + ]; + expectedandroid = expectedandroid.concat(expectedandroidNot071); + } + } + const actualandroid = glob.sync(`${assemblediOSAndroidDir}/**/*`); + checkDirectory(actualandroid, expectedandroid, `${assemblediOSAndroidDir}`); +} + +const validateAssemblediOS = async () => { + let expectedios = [ + `${assemblediOSAndroidDir}/android`, + `${assemblediOSAndroidDir}/android/include`, + `${assemblediOSAndroidDir}/android/include/IXrContextARCore.h`, `${assemblediOSAndroidDir}/ios`, `${assemblediOSAndroidDir}/ios/BabylonModule.mm`, `${assemblediOSAndroidDir}/ios/BabylonNativeInterop.h`, @@ -578,19 +656,13 @@ const validateAssemblediOSAndroid = async () => { `${assemblediOSAndroidDir}/NOTICE.html`, ]; - const versionIndex = process.argv.indexOf('--reactNative'); - if (versionIndex != -1) { - if (process.argv[versionIndex + 1] !== '0.71') { - const expectediosandroidNot071 = [ - `${assemblediOSAndroidDir}/android/src/main/jniLibs/arm64-v8a/libturbomodulejsijni.so`, - `${assemblediOSAndroidDir}/android/src/main/jniLibs/armeabi-v7a/libturbomodulejsijni.so`, - `${assemblediOSAndroidDir}/android/src/main/jniLibs/x86/libturbomodulejsijni.so`, - ]; - expectediosandroid = expectediosandroid.concat(expectediosandroidNot071); - } - } - const actualiosandroid = glob.sync(`${assemblediOSAndroidDir}/**/*`); - checkDirectory(actualiosandroid, expectediosandroid, `${assemblediOSAndroidDir}`); + const actualios = glob.sync(`${assemblediOSAndroidDir}/**/*`); + checkDirectory(actualios, expectedios, `${assemblediOSAndroidDir}`); +} + +const validateAssemblediOSAndroid = async() => { + await validateAssembledAndroid(); + await validateAssemblediOS(); } const createPackage = async () => { @@ -613,6 +685,10 @@ const switchToBaseKit = async () => { basekitPackagePath = 'BaseKit/'; } +const enableRNTA = async () => { + playgroundDirectory = '../Apps/BRNPlayground/'; +} + const patchPackageVersion = async () => { const releaseVersionIndex = process.argv.indexOf('--releaseVersion'); const versionIndex = process.argv.indexOf('--reactNative'); @@ -681,11 +757,23 @@ const patchPackageVersion = async () => { const copyFiles = gulp.parallel(copyIOSAndroidCommonFiles, copyIOSFiles, copyAndroidFiles); +const copyFilesiOS = gulp.parallel(copyIOSAndroidCommonFiles, copyIOSFiles); + const buildIOS = gulp.series(makeXCodeProj, buildIphoneOS, buildIphoneSimulator); -const buildIOSRNTA = gulp.series(makeXCodeProjRNTA, createXCFrameworks); +const buildIOSRNTA = gulp.series(makeXCodeProjRNTA, createXCFrameworks, buildIphoneOSRNTA, buildIphoneSimulatorRNTA); + const buildTS = gulp.series(patchPackageVersion, copyCommonFiles, copySharedFiles, buildTypeScript, validateAssembled); const buildIOSAndroid = gulp.series(patchPackageVersion, buildIOS, buildAndroid, createIOSUniversalLibs, copyFiles, validateAssemblediOSAndroid); + const build = gulp.series(buildIOSAndroid, switchToBaseKit, buildIOSAndroid); + +// a variant is full kit or base kit +const buildAndroidRNTAKitVariant = gulp.series(patchPackageVersion, buildAndroidRNTA, copyAndroidFiles, validateAssembledAndroid); +const buildIOSRNTAKitVariant = gulp.series(patchPackageVersion, buildIOSRNTA, createIOSUniversalLibs, copyFilesiOS, validateAssemblediOS); + +const buildRNTAandroid = gulp.series(enableRNTA, buildAndroidRNTAKitVariant, switchToBaseKit, buildAndroidRNTAKitVariant); +const buildRNTAios = gulp.series(enableRNTA, buildIOSRNTAKitVariant, switchToBaseKit, buildIOSRNTAKitVariant); + const rebuild = gulp.series(clean, build); const pack = gulp.series(rebuild, createPackage); @@ -693,9 +781,11 @@ exports.validateAssembled = validateAssembled; exports.validateAssemblediOSAndroid = validateAssemblediOSAndroid; exports.buildIOS = buildIOS; -exports.buildIOSRNTA = buildIOSRNTA; exports.buildAndroid = buildAndroid; -exports.buildAndroidRNTA = buildAndroidRNTA; + +exports.buildRNTAandroid = buildRNTAandroid; +exports.buildRNTAios = buildRNTAios; + exports.createIOSUniversalLibs = createIOSUniversalLibs; exports.createXCFrameworks = createXCFrameworks; exports.copyFiles = copyFiles; @@ -713,6 +803,36 @@ const buildUWPPublish = gulp.series(patchPackageVersion, buildUWP, copyPackageFi const packUWP = gulp.series(clean, buildUWP, copyPackageFilesUWP, createPackage, createPackageUWP); const packUWPNoBuild = gulp.series(clean, copyPackageFilesUWP, createPackage, createPackageUWP); +const packagex86DebugRNTA = gulp.series(patchPackageVersion, copyx86DebugRNTAFiles); +const packagex86DebugBaseKitRNTA = gulp.series(patchPackageVersion, copyx86DebugBaseKitRNTAFiles); +const packagex86ReleaseRNTA = gulp.series(patchPackageVersion, copyx86ReleaseRNTAFiles); +const packagex86ReleaseBaseKitRNTA = gulp.series(patchPackageVersion, copyx86ReleaseBaseKitRNTAFiles); + +const packagex64DebugRNTA = gulp.series(patchPackageVersion, copyx64DebugRNTAFiles); +const packagex64DebugBaseKitRNTA = gulp.series(patchPackageVersion, copyx64DebugBaseKitRNTAFiles); +const packagex64ReleaseRNTA = gulp.series(patchPackageVersion, copyx64ReleaseRNTAFiles); +const packagex64ReleaseBaseKitRNTA = gulp.series(patchPackageVersion, copyx64ReleaseBaseKitRNTAFiles); + +const packageARM64DebugRNTA = gulp.series(patchPackageVersion, copyARM64DebugRNTAFiles); +const packageARM64DebugBaseKitRNTA = gulp.series(patchPackageVersion, copyARM64DebugBaseKitRNTAFiles); +const packageARM64ReleaseRNTA = gulp.series(patchPackageVersion, copyARM64ReleaseRNTAFiles); +const packageARM64ReleaseBaseKitRNTA = gulp.series(patchPackageVersion, copyARM64ReleaseBaseKitRNTAFiles); + +exports.packagex86DebugRNTA = packagex86DebugRNTA; +exports.packagex86DebugBaseKitRNTA = packagex86DebugBaseKitRNTA; +exports.packagex86ReleaseRNTA = packagex86ReleaseRNTA; +exports.packagex86ReleaseBaseKitRNTA = packagex86ReleaseBaseKitRNTA; + +exports.packagex64DebugRNTA = packagex64DebugRNTA; +exports.packagex64DebugBaseKitRNTA = packagex64DebugBaseKitRNTA; +exports.packagex64ReleaseRNTA = packagex64ReleaseRNTA; +exports.packagex64ReleaseBaseKitRNTA = packagex64ReleaseBaseKitRNTA; + +exports.packageARM64DebugRNTA = packageARM64DebugRNTA; +exports.packageARM64DebugBaseKitRNTA = packageARM64DebugBaseKitRNTA; +exports.packageARM64ReleaseRNTA = packageARM64ReleaseRNTA; +exports.packageARM64ReleaseBaseKitRNTA = packageARM64ReleaseBaseKitRNTA; + exports.buildTS = buildTS; exports.makeUWPProjectx86 = makeUWPProjectx86; exports.makeUWPProjectx64 = makeUWPProjectx64; diff --git a/RNPermissions.vcxproj b/RNPermissions.vcxproj new file mode 100644 index 000000000..6d2cec29c --- /dev/null +++ b/RNPermissions.vcxproj @@ -0,0 +1,157 @@ + + + + + true + true + true + {99677b9d-a27b-4239-930e-c36c8d339c54} + RNPermissions + RNPermissions + en-US + 16.0 + true + Windows Store + 10.0 + 10.0 + 10.0.17763.0 + + + + $([MSBuild]::GetDirectoryNameOfFileAbove($(SolutionDir), 'node_modules\react-native-windows\package.json'))\node_modules\react-native-windows\ + + + + + Debug + ARM + + + Debug + ARM64 + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + ARM64 + + + Release + Win32 + + + Release + x64 + + + + DynamicLibrary + Unicode + false + + + true + true + + + false + true + false + + + + + + + + + + + + + + + + + + Use + pch.h + $(IntDir)pch.pch + Level4 + %(AdditionalOptions) /bigobj + + /DWINRT_NO_MAKE_DETECTION %(AdditionalOptions) + 28204 + _WINRT_DLL;%(PreprocessorDefinitions) + $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) + + + Console + true + RNPermissions.def + + + + + _DEBUG;%(PreprocessorDefinitions) + ProgramDatabase + + + + + NDEBUG;%(PreprocessorDefinitions) + + + + + + ReactPackageProvider.idl + + + + + + Create + + + ReactPackageProvider.idl + + + + + + + + + + + + + + + + + + + + + This project references targets in your node_modules\react-native-windows folder. The missing file is {0}. + + + + + + + +