diff --git a/.github/actions/build-apple-slices-hermes/action.yml b/.github/actions/build-apple-slices-hermes/action.yml deleted file mode 100644 index bc66de6a21b2..000000000000 --- a/.github/actions/build-apple-slices-hermes/action.yml +++ /dev/null @@ -1,103 +0,0 @@ -name: build-apple-slices-hermes -description: This action builds hermesc for Apple platforms -inputs: - hermes-version: - required: true - description: The version of Hermes - react-native-version: - required: true - description: The version of Hermes - slice: - required: true - description: The slice of hermes you want to build. It could be iphone, iphonesimulator, macos, catalyst, appletvos, appletvsimulator, xros, or xrossimulator - flavor: - required: true - description: The flavor we want to build. It can be Debug or Release -runs: - using: composite - steps: - - name: Setup xcode - uses: ./.github/actions/setup-xcode - - name: Restore Hermes workspace - uses: ./.github/actions/restore-hermes-workspace - - name: Restore HermesC Artifact - uses: actions/download-artifact@v4 - with: - name: hermesc-apple - path: ./packages/react-native/sdks/hermes/build_host_hermesc - - name: Restore Slice From Cache - id: restore-slice-cache - uses: actions/cache/restore@v4 - with: - path: ./packages/react-native/sdks/hermes/build_${{ inputs.slice }}_${{ inputs.flavor }} - key: v6-hermes-apple-${{ inputs.hermes-version }}-${{ inputs.react-native-version }}-${{ hashfiles('packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh') }}-${{ inputs.slice }}-${{ inputs.flavor }} - - name: Build the Hermes ${{ inputs.slice }} frameworks - shell: bash - run: | - cd ./packages/react-native/sdks/hermes || exit 1 - SLICE=${{ inputs.slice }} - FLAVOR=${{ inputs.flavor }} - FINAL_PATH=build_"$SLICE"_"$FLAVOR" - echo "Final path for this slice is: $FINAL_PATH" - - if [[ -d "$FINAL_PATH" ]]; then - echo "[HERMES] Skipping! Found the requested slice at $FINAL_PATH". - exit 0 - fi - - if [[ "$ARTIFACTS_EXIST" ]]; then - echo "[HERMES] Skipping! Artifacts exists already." - exit 0 - fi - - export RELEASE_VERSION=${{ inputs.react-native-version }} - - # HermesC is used to build hermes, so it has to be executable - chmod +x ./build_host_hermesc/bin/hermesc - - if [[ "$SLICE" == "macosx" ]]; then - echo "[HERMES] Building Hermes for MacOS" - - chmod +x ./utils/build-mac-framework.sh - BUILD_TYPE="${{ inputs.flavor }}" ./utils/build-mac-framework.sh - else - echo "[HERMES] Building Hermes for iOS: $SLICE" - - chmod +x ./utils/build-ios-framework.sh - BUILD_TYPE="${{ inputs.flavor }}" ./utils/build-ios-framework.sh "$SLICE" - fi - - echo "Moving from build_$SLICE to $FINAL_PATH" - mv build_"$SLICE" "$FINAL_PATH" - - # check whether everything is there - if [[ -d "$FINAL_PATH/lib/hermesvm.framework" ]]; then - echo "Successfully built hermesvm.framework for $SLICE in $FLAVOR" - else - echo "Failed to built hermesvm.framework for $SLICE in $FLAVOR" - exit 1 - fi - - if [[ -d "$FINAL_PATH/lib/hermesvm.framework.dSYM" ]]; then - echo "Successfully built hermesvm.framework.dSYM for $SLICE in $FLAVOR" - else - echo "Failed to built hermesvm.framework.dSYM for $SLICE in $FLAVOR" - echo "Please try again" - exit 1 - fi - - name: Compress slices to preserve Symlinks - shell: bash - run: | - cd ./packages/react-native/sdks/hermes - tar -czv -f build_${{ matrix.slice }}_${{ matrix.flavor }}.tar.gz build_${{ matrix.slice }}_${{ matrix.flavor }} - - name: Upload Artifact for Slice (${{ inputs.slice }}, ${{ inputs.flavor }}} - uses: actions/upload-artifact@v4.3.4 - with: - name: slice-${{ inputs.slice }}-${{ inputs.flavor }} - path: ./packages/react-native/sdks/hermes/build_${{ inputs.slice }}_${{ inputs.flavor }}.tar.gz - - name: Save slice cache - if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, '-stable') }} # To avoid that the cache explode. - uses: actions/cache/save@v4 - with: - path: ./packages/react-native/sdks/hermes/build_${{ inputs.slice }}_${{ inputs.flavor }} - key: v6-hermes-apple-${{ inputs.hermes-version }}-${{ inputs.react-native-version }}-${{ hashfiles('packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh') }}-${{ inputs.SLICE }}-${{ inputs.FLAVOR }} diff --git a/.github/actions/build-hermes-macos/action.yml b/.github/actions/build-hermes-macos/action.yml deleted file mode 100644 index 0f3a42a367f7..000000000000 --- a/.github/actions/build-hermes-macos/action.yml +++ /dev/null @@ -1,227 +0,0 @@ -name: build-hermes-macos -description: This action builds hermesc for Apple platforms -inputs: - hermes-version: - required: true - description: The version of Hermes - react-native-version: - required: true - description: The version of React Native - flavor: - required: true - description: The flavor we want to build. It can be Debug or Release -runs: - using: composite - steps: - - name: Setup xcode - uses: ./.github/actions/setup-xcode - - name: Restore Hermes workspace - uses: ./.github/actions/restore-hermes-workspace - - name: Restore Cached Artifacts - uses: actions/cache/restore@v4 - with: - key: v4-hermes-artifacts-${{ inputs.flavor }}-${{ inputs.hermes-version }}-${{ inputs.react-native-version }}-${{ hashFiles('./packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh') }} - path: | - /tmp/hermes/osx-bin/${{ inputs.flavor }} - /tmp/hermes/dSYM/${{ inputs.flavor }} - /tmp/hermes/hermes-runtime-darwin/hermes-ios-${{ inputs.flavor }}.tar.gz - - name: Check if the required artifacts already exist - id: check_if_apple_artifacts_are_there - shell: bash - run: | - FLAVOR="${{ inputs.flavor }}" - echo "Flavor is $FLAVOR" - OSX_BIN="/tmp/hermes/osx-bin/$FLAVOR" - DSYM="/tmp/hermes/dSYM/$FLAVOR" - HERMES="/tmp/hermes/hermes-runtime-darwin/hermes-ios-$FLAVOR.tar.gz" - - if [[ -d "$OSX_BIN" ]] && \ - [[ -d "$DSYM" ]] && \ - [[ -f "$HERMES" ]]; then - - echo "Artifacts are there!" - echo "ARTIFACTS_EXIST=true" >> $GITHUB_ENV - echo "ARTIFACTS_EXIST=true" >> $GITHUB_OUTPUT - fi - - name: Setup node.js - uses: ./.github/actions/setup-node - - name: Yarn- Install Dependencies - if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }} - uses: ./.github/actions/yarn-install - - name: Slice cache macosx - if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }} - uses: actions/download-artifact@v4 - with: - path: ./packages/react-native/sdks/hermes/ - name: slice-macosx-${{ inputs.flavor }} - - name: Slice cache iphoneos - if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }} - uses: actions/download-artifact@v4 - with: - path: ./packages/react-native/sdks/hermes/ - name: slice-iphoneos-${{ inputs.flavor }} - - name: Slice cache iphonesimulator - if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }} - uses: actions/download-artifact@v4 - with: - path: ./packages/react-native/sdks/hermes/ - name: slice-iphonesimulator-${{ inputs.flavor }} - - name: Slice cache appletvos - if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }} - uses: actions/download-artifact@v4 - with: - path: ./packages/react-native/sdks/hermes/ - name: slice-appletvos-${{ inputs.flavor }} - - name: Slice cache appletvsimulator - if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }} - uses: actions/download-artifact@v4 - with: - path: ./packages/react-native/sdks/hermes/ - name: slice-appletvsimulator-${{ inputs.flavor }} - - name: Slice cache catalyst - if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }} - uses: actions/download-artifact@v4 - with: - path: ./packages/react-native/sdks/hermes/ - name: slice-catalyst-${{ inputs.flavor }} - - name: Slice cache xros - if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }} - uses: actions/download-artifact@v4 - with: - path: ./packages/react-native/sdks/hermes/ - name: slice-xros-${{ inputs.flavor }} - - name: Slice cache xrsimulator - if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }} - uses: actions/download-artifact@v4 - with: - path: ./packages/react-native/sdks/hermes/ - name: slice-xrsimulator-${{ inputs.flavor }} - - name: Unzip slices - shell: bash - if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }} - run: | - cd ./packages/react-native/sdks/hermes - ls -l . - tar -xzv -f build_catalyst_${{ matrix.flavor }}.tar.gz - tar -xzv -f build_iphoneos_${{ matrix.flavor }}.tar.gz - tar -xzv -f build_iphonesimulator_${{ matrix.flavor }}.tar.gz - tar -xzv -f build_appletvos_${{ matrix.flavor }}.tar.gz - tar -xzv -f build_appletvsimulator_${{ matrix.flavor }}.tar.gz - tar -xzv -f build_macosx_${{ matrix.flavor }}.tar.gz - tar -xzv -f build_xros_${{ matrix.flavor }}.tar.gz - tar -xzv -f build_xrsimulator_${{ matrix.flavor }}.tar.gz - - name: Move back build folders - if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }} - shell: bash - run: | - ls -l ./packages/react-native/sdks/hermes - cd ./packages/react-native/sdks/hermes || exit 1 - mv build_macosx_${{ inputs.flavor }} build_macosx - mv build_iphoneos_${{ inputs.flavor }} build_iphoneos - mv build_iphonesimulator_${{ inputs.flavor }} build_iphonesimulator - mv build_appletvos_${{ inputs.flavor }} build_appletvos - mv build_appletvsimulator_${{ inputs.flavor }} build_appletvsimulator - mv build_catalyst_${{ inputs.flavor }} build_catalyst - mv build_xros_${{ inputs.flavor }} build_xros - mv build_xrsimulator_${{ inputs.flavor }} build_xrsimulator - - name: Prepare destroot folder - if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }} - shell: bash - run: | - cd ./packages/react-native/sdks/hermes || exit 1 - chmod +x ./utils/build-apple-framework.sh - . ./utils/build-apple-framework.sh - prepare_dest_root_for_ci - - name: Create fat framework for iOS - if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }} - shell: bash - run: | - cd ./packages/react-native/sdks/hermes || exit 1 - echo "[HERMES] Creating the universal framework" - chmod +x ./utils/build-ios-framework.sh - ./utils/build-ios-framework.sh build_framework - - chmod +x ./destroot/bin/hermesc - - name: Package the Hermes Apple frameworks - if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }} - shell: bash - run: | - BUILD_TYPE="${{ inputs.flavor }}" - echo "Packaging Hermes Apple frameworks for $BUILD_TYPE build type" - - TARBALL_OUTPUT_DIR=$(mktemp -d /tmp/hermes-tarball-output-XXXXXXXX) - - TARBALL_FILENAME=$(node ./packages/react-native/scripts/hermes/get-tarball-name.js --buildType "$BUILD_TYPE") - - echo "Packaging Hermes Apple frameworks for $BUILD_TYPE build type" - - TARBALL_OUTPUT_PATH=$(node ./packages/react-native/scripts/hermes/create-tarball.js \ - --inputDir ./packages/react-native/sdks/hermes \ - --buildType "$BUILD_TYPE" \ - --outputDir $TARBALL_OUTPUT_DIR) - - echo "Hermes tarball saved to $TARBALL_OUTPUT_PATH" - - mkdir -p $HERMES_TARBALL_ARTIFACTS_DIR - cp $TARBALL_OUTPUT_PATH $HERMES_TARBALL_ARTIFACTS_DIR/. - - mkdir -p /tmp/hermes/osx-bin/${{ inputs.flavor }} - cp ./packages/react-native/sdks/hermes/build_macosx/bin/* /tmp/hermes/osx-bin/${{ inputs.flavor }} - ls -lR /tmp/hermes/osx-bin/ - - name: Create dSYM archive - if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }} - shell: bash - run: | - FLAVOR=${{ inputs.flavor }} - WORKING_DIR="/tmp/hermes_tmp/dSYM/$FLAVOR" - - mkdir -p "$WORKING_DIR/macosx" - mkdir -p "$WORKING_DIR/catalyst" - mkdir -p "$WORKING_DIR/iphoneos" - mkdir -p "$WORKING_DIR/iphonesimulator" - mkdir -p "$WORKING_DIR/appletvos" - mkdir -p "$WORKING_DIR/appletvsimulator" - mkdir -p "$WORKING_DIR/xros" - mkdir -p "$WORKING_DIR/xrsimulator" - - cd ./packages/react-native/sdks/hermes || exit 1 - - DSYM_FILE_PATH=lib/hermesvm.framework.dSYM - cp -r build_macosx/$DSYM_FILE_PATH "$WORKING_DIR/macosx/" - cp -r build_catalyst/$DSYM_FILE_PATH "$WORKING_DIR/catalyst/" - cp -r build_iphoneos/$DSYM_FILE_PATH "$WORKING_DIR/iphoneos/" - cp -r build_iphonesimulator/$DSYM_FILE_PATH "$WORKING_DIR/iphonesimulator/" - cp -r build_appletvos/$DSYM_FILE_PATH "$WORKING_DIR/appletvos/" - cp -r build_appletvsimulator/$DSYM_FILE_PATH "$WORKING_DIR/appletvsimulator/" - cp -r build_xros/$DSYM_FILE_PATH "$WORKING_DIR/xros/" - cp -r build_xrsimulator/$DSYM_FILE_PATH "$WORKING_DIR/xrsimulator/" - - DEST_DIR="/tmp/hermes/dSYM/$FLAVOR" - tar -C "$WORKING_DIR" -czvf "hermesvm.framework.dSYM" . - - mkdir -p "$DEST_DIR" - mv "hermesvm.framework.dSYM" "$DEST_DIR" - - name: Upload hermes dSYM artifacts - uses: actions/upload-artifact@v4.3.4 - with: - name: hermes-dSYM-${{ inputs.flavor }} - path: /tmp/hermes/dSYM/${{ inputs.flavor }} - - name: Upload hermes Runtime artifacts - uses: actions/upload-artifact@v4.3.4 - with: - name: hermes-darwin-bin-${{ inputs.flavor }} - path: /tmp/hermes/hermes-runtime-darwin/hermes-ios-${{ inputs.flavor }}.tar.gz - - name: Upload hermes osx artifacts - uses: actions/upload-artifact@v4.3.4 - with: - name: hermes-osx-bin-${{ inputs.flavor }} - path: /tmp/hermes/osx-bin/${{ inputs.flavor }} - - name: Upload Hermes Artifacts - uses: actions/cache/save@v4 - if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, '-stable') }} # To avoid that the cache explode. - with: - key: v4-hermes-artifacts-${{ inputs.flavor }}-${{ inputs.hermes-version }}-${{ inputs.react-native-version }}-${{ hashFiles('./packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh') }} - path: | - /tmp/hermes/osx-bin/${{ inputs.flavor }} - /tmp/hermes/dSYM/${{ inputs.flavor }} - /tmp/hermes/hermes-runtime-darwin/hermes-ios-${{ inputs.flavor }}.tar.gz diff --git a/.github/actions/build-hermesc-apple/action.yml b/.github/actions/build-hermesc-apple/action.yml deleted file mode 100644 index c4fefdce9e17..000000000000 --- a/.github/actions/build-hermesc-apple/action.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: build-hermesc-apple -description: This action builds hermesc for Apple platforms -inputs: - hermes-version: - required: true - description: The version of Hermes - react-native-version: - required: true - description: The version of React Native -runs: - using: composite - steps: - - name: Setup xcode - uses: ./.github/actions/setup-xcode - - name: Restore Hermes workspace - uses: ./.github/actions/restore-hermes-workspace - - name: Hermes apple cache - uses: actions/cache/restore@v4 - with: - path: ./packages/react-native/sdks/hermes/build_host_hermesc - key: v2-hermesc-apple-${{ inputs.hermes-version }}-${{ inputs.react-native-version }} - - name: Build HermesC Apple - shell: bash - run: | - cd ./packages/react-native/sdks/hermes || exit 1 - . ./utils/build-apple-framework.sh - build_host_hermesc_if_needed - - name: Upload HermesC Artifact - uses: actions/upload-artifact@v4.3.4 - with: - name: hermesc-apple - path: ./packages/react-native/sdks/hermes/build_host_hermesc - - name: Cache hermesc apple - uses: actions/cache/save@v4 - if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, '-stable') }} # To avoid that the cache explode. - with: - path: ./packages/react-native/sdks/hermes/build_host_hermesc - key: v2-hermesc-apple-${{ inputs.hermes-version }}-${{ inputs.react-native-version }} - enableCrossOsArchive: true diff --git a/.github/actions/build-hermesc-linux/action.yml b/.github/actions/build-hermesc-linux/action.yml deleted file mode 100644 index 0c90739d0a72..000000000000 --- a/.github/actions/build-hermesc-linux/action.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: build-hermesc-linux -description: This action builds hermesc for linux platforms -inputs: - hermes-version: - required: True - description: The version of Hermes - react-native-version: - required: True - description: The version of React Native -runs: - using: composite - steps: - - name: Install dependencies - shell: bash - run: | - sudo apt update - sudo apt install -y git openssh-client build-essential \ - libreadline-dev libicu-dev jq zip python3 - - # Install cmake 3.28.3-1build7 - sudo apt-get install cmake=3.28.3-1build7 - sudo ln -sf /usr/bin/cmake /usr/local/bin/cmake - - name: Restore Hermes workspace - uses: ./.github/actions/restore-hermes-workspace - - name: Linux cache - uses: actions/cache@v4 - with: - key: v1-hermes-${{ github.job }}-linux-${{ inputs.hermes-version }}-${{ inputs.react-native-version }} - path: | - /tmp/hermes/linux64-bin/ - /tmp/hermes/hermes/destroot/ - - name: Set up workspace - shell: bash - run: | - mkdir -p /tmp/hermes/linux64-bin - - name: Build HermesC for Linux - shell: bash - run: | - if [ -f /tmp/hermes/linux64-bin/hermesc ]; then - echo 'Skipping; Clean "/tmp/hermes/linux64-bin" to rebuild.' - else - cd /tmp/hermes - cmake -S hermes -B build -DHERMES_STATIC_LINK=ON -DCMAKE_BUILD_TYPE=Release -DHERMES_ENABLE_TEST_SUITE=OFF \ - -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=True -DCMAKE_CXX_FLAGS=-s -DCMAKE_C_FLAGS=-s \ - -DCMAKE_EXE_LINKER_FLAGS="-Wl,--whole-archive -lpthread -Wl,--no-whole-archive" - cmake --build build --target hermesc -j 4 - cp /tmp/hermes/build/bin/hermesc /tmp/hermes/linux64-bin/. - fi - - name: Upload linux artifacts - uses: actions/upload-artifact@v4.3.4 - with: - name: hermes-linux-bin - path: /tmp/hermes/linux64-bin diff --git a/.github/actions/build-hermesc-windows/action.yml b/.github/actions/build-hermesc-windows/action.yml deleted file mode 100644 index 1dcaebb2fb93..000000000000 --- a/.github/actions/build-hermesc-windows/action.yml +++ /dev/null @@ -1,86 +0,0 @@ -name: build-hermesc-windows -description: This action builds hermesc for Windows platforms -inputs: - hermes-version: - required: True - description: The version of Hermes - react-native-version: - required: True - description: The version of React Native -runs: - using: composite - steps: - - name: Download Previous Artifacts - uses: actions/download-artifact@v4 - with: - name: hermes-workspace - path: 'C:\tmp\hermes' - - name: Set up workspace - shell: powershell - run: | - mkdir -p C:\tmp\hermes\osx-bin - mkdir -p .\packages\react-native\sdks\hermes - cp -r -Force C:\tmp\hermes\hermes\* .\packages\react-native\sdks\hermes\. - cp -r -Force .\packages\react-native\sdks\hermes-engine\utils\* .\packages\react-native\sdks\hermes\. - - name: Windows cache - uses: actions/cache@v4 - with: - key: v3-hermes-${{ github.job }}-windows-${{ inputs.hermes-version }}-${{ inputs.react-native-version }} - path: | - C:\tmp\hermes\win64-bin\ - C:\tmp\hermes\hermes\icu\ - C:\tmp\hermes\hermes\deps\ - C:\tmp\hermes\hermes\build_release\ - - name: setup-msbuild - uses: microsoft/setup-msbuild@v1.3.2 - - name: Set up workspace - shell: powershell - run: | - New-Item -ItemType Directory -ErrorAction SilentlyContinue $Env:HERMES_WS_DIR\icu - New-Item -ItemType Directory -ErrorAction SilentlyContinue $Env:HERMES_WS_DIR\deps - New-Item -ItemType Directory -ErrorAction SilentlyContinue $Env:HERMES_WS_DIR\win64-bin - - name: Downgrade CMake - shell: powershell - run: choco install cmake --version 3.31.6 --force - - name: Build HermesC for Windows - shell: powershell - run: | - if (-not(Test-Path -Path $Env:HERMES_WS_DIR\win64-bin\hermesc.exe)) { - cd $Env:HERMES_WS_DIR\icu - # If Invoke-WebRequest shows a progress bar, it will fail with - # Win32 internal error "Access is denied" 0x5 occurred [...] - $progressPreference = 'silentlyContinue' - Invoke-WebRequest -Uri "$Env:ICU_URL" -OutFile "icu.zip" - Expand-Archive -Path "icu.zip" -DestinationPath "." - - cd $Env:HERMES_WS_DIR - Copy-Item -Path "icu\bin64\icu*.dll" -Destination "deps" - # Include MSVC++ 2015 redistributables - Copy-Item -Path "c:\windows\system32\msvcp140.dll" -Destination "deps" - Copy-Item -Path "c:\windows\system32\vcruntime140.dll" -Destination "deps" - Copy-Item -Path "c:\windows\system32\vcruntime140_1.dll" -Destination "deps" - - $Env:PATH += ";$Env:CMAKE_DIR;$Env:MSBUILD_DIR" - $Env:ICU_ROOT = "$Env:HERMES_WS_DIR\icu" - - cmake -S hermes -B build_release -G 'Visual Studio 17 2022' -Ax64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=True -DHERMES_ENABLE_WIN10_ICU_FALLBACK=OFF - if (-not $?) { throw "Failed to configure Hermes" } - echo "Running windows build..." - cd build_release - cmake --build . --target hermesc --config Release - if (-not $?) { throw "Failed to build Hermes" } - - echo "Copying hermesc.exe to win64-bin" - cd $Env:HERMES_WS_DIR - Copy-Item -Path "build_release\bin\Release\hermesc.exe" -Destination "win64-bin" - # Include Windows runtime dependencies - Copy-Item -Path "deps\*" -Destination "win64-bin" - } - else { - Write-Host "Skipping; Clean c:\tmp\hermes\win64-bin to rebuild." - } - - name: Upload windows artifacts - uses: actions/upload-artifact@v4.3.4 - with: - name: hermes-win64-bin - path: C:\tmp\hermes\win64-bin\ diff --git a/.github/actions/build-npm-package/action.yml b/.github/actions/build-npm-package/action.yml index 8b894e906395..808916f8b29c 100644 --- a/.github/actions/build-npm-package/action.yml +++ b/.github/actions/build-npm-package/action.yml @@ -4,9 +4,6 @@ inputs: release-type: required: true description: The type of release we are building. It could be nightly, release or dry-run - hermes-ws-dir: - required: 'true' - description: The workspace for hermes gha-npm-token: required: false description: The GHA npm token, required only to publish to npm @@ -20,87 +17,6 @@ runs: - name: Setup git safe folders shell: bash run: git config --global --add safe.directory '*' - - name: Create /tmp/hermes/osx-bin directory - shell: bash - run: mkdir -p /tmp/hermes/osx-bin - - name: Download osx-bin release artifacts - uses: actions/download-artifact@v4 - with: - name: hermes-osx-bin-Release - path: /tmp/hermes/osx-bin/Release - - name: Download osx-bin debug artifacts - uses: actions/download-artifact@v4 - with: - name: hermes-osx-bin-Debug - path: /tmp/hermes/osx-bin/Debug - - name: Download darwin-bin release artifacts - uses: actions/download-artifact@v4 - with: - name: hermes-darwin-bin-Release - path: /tmp/hermes/hermes-runtime-darwin - - name: Download darwin-bin debug artifacts - uses: actions/download-artifact@v4 - with: - name: hermes-darwin-bin-Debug - path: /tmp/hermes/hermes-runtime-darwin - - name: Download hermes dSYM debug artifacts - uses: actions/download-artifact@v4 - with: - name: hermes-dSYM-Debug - path: /tmp/hermes/dSYM/Debug - - name: Download hermes dSYM release vartifacts - uses: actions/download-artifact@v4 - with: - name: hermes-dSYM-Release - path: /tmp/hermes/dSYM/Release - - name: Download windows-bin artifacts - uses: actions/download-artifact@v4 - with: - name: hermes-win64-bin - path: /tmp/hermes/win64-bin - - name: Download linux-bin artifacts - uses: actions/download-artifact@v4 - with: - name: hermes-linux-bin - path: /tmp/hermes/linux64-bin - - name: Show /tmp/hermes directory - shell: bash - run: ls -lR /tmp/hermes - - name: Copy Hermes binaries - shell: bash - run: | - mkdir -p ./packages/react-native/sdks/hermesc ./packages/react-native/sdks/hermesc/osx-bin ./packages/react-native/sdks/hermesc/win64-bin ./packages/react-native/sdks/hermesc/linux64-bin - - # When build_hermes_macos runs as a matrix, it outputs - if [[ -d ${{ inputs.hermes-ws-dir }}/osx-bin/Release ]]; then - cp -r ${{ inputs.hermes-ws-dir }}/osx-bin/Release/* ./packages/react-native/sdks/hermesc/osx-bin/. - elif [[ -d ${{ inputs.hermes-ws-dir }}/osx-bin/Debug ]]; then - cp -r ${{ inputs.hermes-ws-dir }}/osx-bin/Debug/* ./packages/react-native/sdks/hermesc/osx-bin/. - else - ls ${{ inputs.hermes-ws-dir }}/osx-bin || echo "hermesc macOS artifacts directory missing." - echo "Could not locate macOS hermesc binary."; exit 1; - fi - - # Sometimes, GHA creates artifacts with lowercase Debug/Release. Make sure that if it happen, we uppercase them. - if [[ -f "${{ inputs.hermes-ws-dir }}/hermes-runtime-darwin/hermes-ios-debug.tar.gz" ]]; then - mv "${{ inputs.hermes-ws-dir }}/hermes-runtime-darwin/hermes-ios-debug.tar.gz" "${{ inputs.hermes-ws-dir }}/hermes-runtime-darwin/hermes-ios-Debug.tar.gz" - fi - - if [[ -f "${{ inputs.hermes-ws-dir }}/hermes-runtime-darwin/hermes-ios-release.tar.gz" ]]; then - mv "${{ inputs.hermes-ws-dir }}/hermes-runtime-darwin/hermes-ios-release.tar.gz" "${{ inputs.hermes-ws-dir }}/hermes-runtime-darwin/hermes-ios-Release.tar.gz" - fi - - cp -r ${{ inputs.hermes-ws-dir }}/win64-bin/* ./packages/react-native/sdks/hermesc/win64-bin/. - cp -r ${{ inputs.hermes-ws-dir }}/linux64-bin/* ./packages/react-native/sdks/hermesc/linux64-bin/. - - # Make sure the hermesc files are actually executable. - chmod -R +x packages/react-native/sdks/hermesc/* - - mkdir -p ./packages/react-native/ReactAndroid/external-artifacts/artifacts/ - cp ${{ inputs.hermes-ws-dir }}/hermes-runtime-darwin/hermes-ios-Debug.tar.gz ./packages/react-native/ReactAndroid/external-artifacts/artifacts/hermes-ios-debug.tar.gz - cp ${{ inputs.hermes-ws-dir }}/hermes-runtime-darwin/hermes-ios-Release.tar.gz ./packages/react-native/ReactAndroid/external-artifacts/artifacts/hermes-ios-release.tar.gz - cp ${{ inputs.hermes-ws-dir }}/dSYM/Debug/hermesvm.framework.dSYM ./packages/react-native/ReactAndroid/external-artifacts/artifacts/hermes-framework-dSYM-debug.tar.gz - cp ${{ inputs.hermes-ws-dir }}/dSYM/Release/hermesvm.framework.dSYM ./packages/react-native/ReactAndroid/external-artifacts/artifacts/hermes-framework-dSYM-release.tar.gz - name: Download ReactNativeDependencies uses: actions/download-artifact@v4 with: diff --git a/.github/actions/prepare-hermes-workspace/action.yml b/.github/actions/prepare-hermes-workspace/action.yml deleted file mode 100644 index 47953b676007..000000000000 --- a/.github/actions/prepare-hermes-workspace/action.yml +++ /dev/null @@ -1,99 +0,0 @@ -name: prepare-hermes-workspace -description: This action prepares the hermes workspace with the right hermes and react-native versions. -inputs: - hermes-ws-dir: - required: true - description: The hermes dir we need to use to setup the workspace - hermes-version-file: - required: true - description: the path to the file that will contain the hermes version -outputs: - hermes-version: - description: the version of Hermes tied to this run - value: ${{ steps.hermes-version.outputs.VERSION }} - react-native-version: - description: the version of React Native tied to this run - value: ${{ steps.react-native-version.outputs.VERSION }} -runs: - using: composite - steps: - - name: Setup hermes version - shell: bash - id: hermes-version - run: | - mkdir -p "/tmp/hermes" "/tmp/hermes/download" "/tmp/hermes/hermes" - - if [ -f "${{ inputs.hermes-version-file }}" ]; then - echo "Hermes Version file found! Using this version for the build:" - echo "VERSION=$(cat ${{ inputs.hermes-version-file }})" >> "$GITHUB_OUTPUT" - else - echo "Hermes Version file not found!!!" - echo "Using the last commit from main for the build:" - HERMES_TAG_SHA=$(git ls-remote https://github.com/facebook/hermes main | cut -f 1 | tr -d '[:space:]') - echo "VERSION=$HERMES_TAG_SHA" >> "$GITHUB_OUTPUT" - fi - echo "Hermes commit is $HERMES_TAG_SHA" - - - name: Get react-native version - shell: bash - id: react-native-version - run: | - VERSION=$(cat packages/react-native/package.json | jq -r '.version') - # Save the react native version we are building in an output variable so we can use that file as part of the cache key. - echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT" - echo "React Native Version is $VERSION" - - - name: Cache hermes workspace - id: restore-hermes - uses: actions/cache/restore@v4 - with: - path: | - /tmp/hermes/download/ - /tmp/hermes/hermes/ - key: v1-hermes-${{ steps.hermes-version.outputs.version }} - enableCrossOsArchive: true - - # It happened while testing that a cache was created from the right folders - # but those folders where empty. Thus, the next check ensures that we can work with those caches. - - name: Check if cache was meaningful - id: meaningful-cache - shell: bash - run: | - if [[ -d /tmp/hermes/hermes ]] && [[ -n "$(ls -A /tmp/hermes/hermes)" ]]; then - echo "Found a good hermes cache" - echo "HERMES_CACHED=true" >> "$GITHUB_OUTPUT" - fi - - - name: Setup node.js - uses: ./.github/actions/setup-node - - name: Yarn- Install Dependencies - if: ${{ steps.meaningful-cache.outputs.HERMES_CACHED != 'true' }} - uses: ./.github/actions/yarn-install - - - name: Download Hermes tarball - if: ${{ steps.meaningful-cache.outputs.HERMES_CACHED != 'true' }} - shell: bash - run: | - node packages/react-native/scripts/hermes/prepare-hermes-for-build ${{ github.event.pull_request.html_url }} - cp packages/react-native/sdks/download/* ${{ inputs.hermes-ws-dir }}/download/. - cp -r packages/react-native/sdks/hermes/* ${{ inputs.hermes-ws-dir }}/hermes/. - - echo ${{ steps.hermes-version.outputs.version }} - - - name: Upload Hermes artifact - uses: actions/upload-artifact@v4.3.4 - with: - name: hermes-workspace - path: | - /tmp/hermes/download/ - /tmp/hermes/hermes/ - - - name: Cache hermes workspace - uses: actions/cache/save@v4 - if: ${{ github.ref == 'refs/heads/main' }} # To avoid that the cache explode. - with: - path: | - /tmp/hermes/download/ - /tmp/hermes/hermes/ - key: v1-hermes-${{ steps.hermes-version.outputs.version }} - enableCrossOsArchive: true diff --git a/.github/actions/restore-hermes-workspace/action.yml b/.github/actions/restore-hermes-workspace/action.yml deleted file mode 100644 index 0b1cb2594357..000000000000 --- a/.github/actions/restore-hermes-workspace/action.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: restore-hermes-workspace -description: "Restore hermes workspace that has been created in Prepare Hermes Workspace" -runs: - using: composite - steps: - - name: Download Previous Artifacts - uses: actions/download-artifact@v4 - with: - name: hermes-workspace - path: /tmp/hermes - - name: Set up workspace - shell: bash - run: | - mkdir -p $HERMES_OSXBIN_ARTIFACTS_DIR ./packages/react-native/sdks/hermes - cp -r $HERMES_WS_DIR/hermes/* ./packages/react-native/sdks/hermes/. - cp -r ./packages/react-native/sdks/hermes-engine/utils ./packages/react-native/sdks/hermes/. diff --git a/.github/actions/test-ios-helloworld/action.yml b/.github/actions/test-ios-helloworld/action.yml index 0a9a6939bba2..0f9461013350 100644 --- a/.github/actions/test-ios-helloworld/action.yml +++ b/.github/actions/test-ios-helloworld/action.yml @@ -10,12 +10,6 @@ inputs: flavor: description: The flavor of the build. Must be one of "Debug", "Release". default: Debug - hermes-version: - description: The version of hermes - required: true - react-native-version: - description: The version of react-native - required: true runs: using: composite steps: @@ -25,21 +19,16 @@ runs: uses: ./.github/actions/setup-node - name: Run yarn install uses: ./.github/actions/yarn-install - - name: Create Hermes folder - shell: bash - run: mkdir -p "$HERMES_WS_DIR" - - name: Download Hermes - uses: actions/download-artifact@v4 - with: - name: hermes-darwin-bin-${{ inputs.flavor }} - path: /tmp/hermes/hermes-runtime-darwin/ - - name: Print Downloaded hermes - shell: bash - run: ls -lR "$HERMES_WS_DIR" - name: Setup ruby uses: ruby/setup-ruby@v1 with: ruby-version: ${{ inputs.ruby-version }} + - name: Set nightly Hermes versions + shell: bash + run: | + node ./scripts/releases/use-hermes-nightly.js + - name: Run yarn install again, with the correct hermes version + uses: ./.github/actions/yarn-install - name: Download ReactNativeDependencies uses: actions/download-artifact@v4 with: @@ -66,20 +55,6 @@ runs: args+=(--frameworks dynamic) fi - # Tarball is restored with capital flavors suffix, but somehow the tarball name from JS at line 96 returns as lowercased. - # Let's ensure that the tarballs have the right names - - if [[ -f "$HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-Debug.tar.gz" ]]; then - mv "$HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-Debug.tar.gz" "$HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-debug.tar.gz" - fi - - if [[ -f "$HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-Release.tar.gz" ]]; then - mv "$HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-Release.tar.gz" "$HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-release.tar.gz" - fi - - BUILD_TYPE="${{ inputs.flavor }}" - TARBALL_FILENAME=$(node ../../packages/react-native/scripts/hermes/get-tarball-name.js --buildType "$BUILD_TYPE") - export HERMES_ENGINE_TARBALL_PATH="$HERMES_WS_DIR/hermes-runtime-darwin/$TARBALL_FILENAME" export RCT_USE_LOCAL_RN_DEP="/tmp/third-party/ReactNativeDependencies${{ inputs.flavor }}.xcframework.tar.gz" export RCT_TESTONLY_RNCORE_TARBALL_PATH="/tmp/ReactCore/ReactCore${{ inputs.flavor }}.xcframework.tar.gz" diff --git a/.github/actions/test-ios-rntester/action.yml b/.github/actions/test-ios-rntester/action.yml index b54e4a36c6e5..918504c6df0a 100644 --- a/.github/actions/test-ios-rntester/action.yml +++ b/.github/actions/test-ios-rntester/action.yml @@ -10,18 +10,9 @@ inputs: run-unit-tests: description: whether unit tests should run or not. default: "false" - hermes-tarball-artifacts-dir: - description: The directory where the hermes tarball artifacts are stored - default: /tmp/hermes/hermes-runtime-darwin flavor: description: The flavor of the build. Must be one of "Debug", "Release". default: Debug - hermes-version: - description: The version of hermes - required: true - react-native-version: - description: The version of react-native - required: true run-e2e-tests: description: Whether we want to run E2E tests or not required: false @@ -36,56 +27,19 @@ runs: uses: ./.github/actions/setup-node - name: Run yarn uses: ./.github/actions/yarn-install - - name: Download Hermes - uses: actions/download-artifact@v4 - with: - name: hermes-darwin-bin-${{ inputs.flavor }} - path: ${{ inputs.hermes-tarball-artifacts-dir }} - name: Setup ruby uses: ruby/setup-ruby@v1 with: ruby-version: ${{ inputs.ruby-version }} + - name: Set nightly Hermes versions + shell: bash + run: | + node ./scripts/releases/use-hermes-nightly.js + - name: Run yarn install again, with the correct hermes version + uses: ./.github/actions/yarn-install - name: Prepare IOS Tests if: ${{ inputs.run-unit-tests == 'true' }} uses: ./.github/actions/prepare-ios-tests - - name: Set HERMES_ENGINE_TARBALL_PATH envvar if Hermes tarball is present - shell: bash - run: | - HERMES_TARBALL_ARTIFACTS_DIR=${{ inputs.hermes-tarball-artifacts-dir }} - if [ ! -d $HERMES_TARBALL_ARTIFACTS_DIR ]; then - echo "Hermes tarball artifacts dir not present ($HERMES_TARBALL_ARTIFACTS_DIR). Build Hermes from source." - exit 0 - fi - - TARBALL_FILENAME=$(node ./packages/react-native/scripts/hermes/get-tarball-name.js --buildType "${{ inputs.flavor }}") - TARBALL_PATH=$HERMES_TARBALL_ARTIFACTS_DIR/$TARBALL_FILENAME - - echo "Looking for $TARBALL_FILENAME in $HERMES_TARBALL_ARTIFACTS_DIR" - echo "$TARBALL_PATH" - - if [ ! -f $TARBALL_PATH ]; then - echo "Hermes tarball not present ($TARBALL_PATH). Build Hermes from source." - exit 0 - fi - - echo "Found Hermes tarball at $TARBALL_PATH" - echo "HERMES_ENGINE_TARBALL_PATH=$TARBALL_PATH" >> $GITHUB_ENV - - name: Print Hermes version - shell: bash - run: | - HERMES_TARBALL_ARTIFACTS_DIR=${{ inputs.hermes-tarball-artifacts-dir }} - TARBALL_FILENAME=$(node ./packages/react-native/scripts/hermes/get-tarball-name.js --buildType "${{ inputs.flavor }}") - TARBALL_PATH=$HERMES_TARBALL_ARTIFACTS_DIR/$TARBALL_FILENAME - if [[ -e $TARBALL_PATH ]]; then - tar -xf $TARBALL_PATH - echo 'print(HermesInternal?.getRuntimeProperties?.()["OSS Release Version"])' > test.js - chmod +x ./destroot/bin/hermes - ./destroot/bin/hermes test.js - rm test.js - rm -rf destroot - else - echo 'No Hermes tarball found.' - fi - name: Download ReactNativeDependencies uses: actions/download-artifact@v4 with: @@ -105,7 +59,6 @@ runs: - name: Install CocoaPods dependencies shell: bash run: | - export HERMES_ENGINE_TARBALL_PATH=$HERMES_ENGINE_TARBALL_PATH export RCT_USE_LOCAL_RN_DEP="/tmp/third-party/ReactNativeDependencies${{ inputs.flavor }}.xcframework.tar.gz" export RCT_TESTONLY_RNCORE_TARBALL_PATH="/tmp/ReactCore/ReactCore${{ inputs.flavor }}.xcframework.tar.gz" @@ -116,7 +69,7 @@ runs: cd packages/rn-tester bundle install - bundle exec pod install + bundle exec pod update hermes-engine --no-repo-update - name: Build RNTester shell: bash run: | diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 3abef2c12729..d68904e7648d 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -21,86 +21,6 @@ jobs: echo "Setting release type to nightly" echo "RELEASE_TYPE=nightly" >> $GITHUB_OUTPUT - prepare_hermes_workspace: - runs-on: ubuntu-latest - if: github.repository == 'facebook/react-native' - env: - HERMES_WS_DIR: /tmp/hermes - HERMES_VERSION_FILE: packages/react-native/sdks/.hermesversion - outputs: - react-native-version: ${{ steps.prepare-hermes-workspace.outputs.react-native-version }} - hermes-version: ${{ steps.prepare-hermes-workspace.outputs.hermes-version }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Prepare Hermes Workspace - id: prepare-hermes-workspace - uses: ./.github/actions/prepare-hermes-workspace - with: - hermes-ws-dir: ${{ env.HERMES_WS_DIR }} - hermes-version-file: ${{ env.HERMES_VERSION_FILE }} - - build_hermesc_apple: - runs-on: macos-14 - needs: prepare_hermes_workspace - env: - HERMES_WS_DIR: /tmp/hermes - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build HermesC Apple - uses: ./.github/actions/build-hermesc-apple - with: - hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }} - react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }} - - build_apple_slices_hermes: - runs-on: macos-14 - needs: [build_hermesc_apple, prepare_hermes_workspace] - env: - HERMES_WS_DIR: /tmp/hermes - HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin - HERMES_OSXBIN_ARTIFACTS_DIR: /tmp/hermes/osx-bin - IOS_DEPLOYMENT_TARGET: "15.1" - XROS_DEPLOYMENT_TARGET: "1.0" - MAC_DEPLOYMENT_TARGET: "10.15" - strategy: - fail-fast: false - matrix: - flavor: [Debug, Release] - slice: [macosx, iphoneos, iphonesimulator, appletvos, appletvsimulator, catalyst, xros, xrsimulator] - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build Slice - uses: ./.github/actions/build-apple-slices-hermes - with: - flavor: ${{ matrix.flavor }} - slice: ${{ matrix.slice }} - hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }} - react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }} - - build_hermes_macos: - runs-on: macos-14 - needs: [build_apple_slices_hermes, prepare_hermes_workspace] - env: - HERMES_WS_DIR: /tmp/hermes - HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin - continue-on-error: true - strategy: - fail-fast: false - matrix: - flavor: [Debug, Release] - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build Hermes MacOS - uses: ./.github/actions/build-hermes-macos - with: - hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }} - react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }} - flavor: ${{ matrix.flavor }} - prebuild_apple_dependencies: if: github.repository == 'facebook/react-native' uses: ./.github/workflows/prebuild-ios-dependencies.yml @@ -108,42 +28,10 @@ jobs: prebuild_react_native_core: uses: ./.github/workflows/prebuild-ios-core.yml + with: + use-hermes-nightly: true secrets: inherit - needs: [prebuild_apple_dependencies, build_hermes_macos] - - build_hermesc_linux: - runs-on: ubuntu-latest - needs: prepare_hermes_workspace - env: - HERMES_WS_DIR: /tmp/hermes - HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build HermesC Linux - uses: ./.github/actions/build-hermesc-linux - with: - hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }} - react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }} - - build_hermesc_windows: - runs-on: windows-2025 - needs: prepare_hermes_workspace - env: - HERMES_WS_DIR: 'C:\tmp\hermes' - HERMES_TARBALL_ARTIFACTS_DIR: 'C:\tmp\hermes\hermes-runtime-darwin' - HERMES_OSXBIN_ARTIFACTS_DIR: 'C:\tmp\hermes\osx-bin' - ICU_URL: "https://github.com/unicode-org/icu/releases/download/release-64-2/icu4c-64_2-Win64-MSVC2017.zip" - MSBUILD_DIR: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin' - CMAKE_DIR: 'C:\Program Files\CMake\bin' - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build HermesC Windows - uses: ./.github/actions/build-hermesc-windows - with: - hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }} - react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }} + needs: [prebuild_apple_dependencies] build_android: runs-on: 8-core-ubuntu @@ -172,10 +60,7 @@ jobs: needs: [ set_release_type, - prepare_hermes_workspace, - build_hermes_macos, - build_hermesc_linux, - build_hermesc_windows, + prepare_workspace, build_android, prebuild_apple_dependencies, prebuild_react_native_core, @@ -188,7 +73,6 @@ jobs: # By default we only build ARM64 to save time/resources. For release/nightlies, we override this value to build all archs. ORG_GRADLE_PROJECT_reactNativeArchitectures: "arm64-v8a" env: - HERMES_WS_DIR: /tmp/hermes GHA_NPM_TOKEN: ${{ secrets.GHA_NPM_TOKEN }} ORG_GRADLE_PROJECT_SIGNING_PWD: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_PWD }} ORG_GRADLE_PROJECT_SIGNING_KEY: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_KEY }} @@ -200,7 +84,6 @@ jobs: - name: Build and Publish NPM Package uses: ./.github/actions/build-npm-package with: - hermes-ws-dir: ${{ env.HERMES_WS_DIR }} release-type: ${{ needs.set_release_type.outputs.RELEASE_TYPE }} gha-npm-token: ${{ env.GHA_NPM_TOKEN }} gradle-cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }} diff --git a/.github/workflows/prebuild-ios-core.yml b/.github/workflows/prebuild-ios-core.yml index b2d05c5e88fe..340cd7098d11 100644 --- a/.github/workflows/prebuild-ios-core.yml +++ b/.github/workflows/prebuild-ios-core.yml @@ -2,7 +2,12 @@ name: Prebuild iOS Dependencies on: workflow_call: # this directive allow us to call this workflow from other workflows - + inputs: + use-hermes-nightly: + description: 'Whether to use the hermes nightly build or read the version from the versions.properties file' + type: boolean + required: false + default: false jobs: build-rn-slice: @@ -36,35 +41,16 @@ jobs: - name: Yarn Install if: steps.restore-ios-slice.outputs.cache-hit != 'true' uses: ./.github/actions/yarn-install - - name: Download Hermes - if: steps.restore-ios-slice.outputs.cache-hit != 'true' - uses: actions/download-artifact@v4 - with: - name: hermes-darwin-bin-${{ matrix.flavor }} - path: /tmp/hermes/hermes-runtime-darwin - - name: Extract Hermes - if: steps.restore-ios-slice.outputs.cache-hit != 'true' + - name: Set Hermes version shell: bash run: | - HERMES_TARBALL_ARTIFACTS_DIR=/tmp/hermes/hermes-runtime-darwin - if [ ! -d $HERMES_TARBALL_ARTIFACTS_DIR ]; then - echo "Hermes tarball artifacts dir not present ($HERMES_TARBALL_ARTIFACTS_DIR)." - exit 0 + if [ "${{ inputs.use-hermes-nightly }}" == "true" ]; then + HERMES_VERSION="nightly" + else + HERMES_VERSION=$(sed -n 's/^HERMES_VERSION_NAME=//p' packages/react-native/sdks/hermes-engine/version.properties) fi - - TARBALL_FILENAME=$(node ./packages/react-native/scripts/hermes/get-tarball-name.js --buildType "${{ matrix.flavor }}") - TARBALL_PATH=$HERMES_TARBALL_ARTIFACTS_DIR/$TARBALL_FILENAME - - echo "Looking for $TARBALL_FILENAME in $HERMES_TARBALL_ARTIFACTS_DIR" - echo "$TARBALL_PATH" - - if [ ! -f $TARBALL_PATH ]; then - echo "Hermes tarball not present ($TARBALL_PATH). Build Hermes from source." - exit 0 - fi - - echo "Found Hermes tarball at $TARBALL_PATH" - echo "HERMES_ENGINE_TARBALL_PATH=$TARBALL_PATH" >> $GITHUB_ENV + echo "Using Hermes version: $HERMES_VERSION" + echo "HERMES_VERSION=$HERMES_VERSION" >> $GITHUB_ENV - name: Download ReactNativeDependencies uses: actions/download-artifact@v4 with: diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index efa432f4542d..6a6799db93f8 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -19,85 +19,6 @@ jobs: echo "Setting release type to release" echo "RELEASE_TYPE=release" >> $GITHUB_OUTPUT - prepare_hermes_workspace: - runs-on: ubuntu-latest - if: github.repository == 'facebook/react-native' - env: - HERMES_WS_DIR: /tmp/hermes - HERMES_VERSION_FILE: packages/react-native/sdks/.hermesversion - outputs: - react-native-version: ${{ steps.prepare-hermes-workspace.outputs.react-native-version }} - hermes-version: ${{ steps.prepare-hermes-workspace.outputs.hermes-version }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Prepare Hermes Workspace - id: prepare-hermes-workspace - uses: ./.github/actions/prepare-hermes-workspace - with: - hermes-ws-dir: ${{ env.HERMES_WS_DIR }} - hermes-version-file: ${{ env.HERMES_VERSION_FILE }} - - build_hermesc_apple: - runs-on: macos-14 - needs: prepare_hermes_workspace - env: - HERMES_WS_DIR: /tmp/hermes - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build HermesC Apple - uses: ./.github/actions/build-hermesc-apple - with: - hermes-version: ${{ needs.prepare_hermes_workspace.output.hermes-version }} - react-native-version: ${{ needs.prepare_hermes_workspace.output.react-native-version }} - build_apple_slices_hermes: - runs-on: macos-14 - needs: [build_hermesc_apple, prepare_hermes_workspace] - env: - HERMES_WS_DIR: /tmp/hermes - HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin - HERMES_OSXBIN_ARTIFACTS_DIR: /tmp/hermes/osx-bin - IOS_DEPLOYMENT_TARGET: "15.1" - XROS_DEPLOYMENT_TARGET: "1.0" - MAC_DEPLOYMENT_TARGET: "10.15" - strategy: - fail-fast: false - matrix: - flavor: [Debug, Release] - slice: [macosx, iphoneos, iphonesimulator, appletvos, appletvsimulator, catalyst, xros, xrsimulator] - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build Slice - uses: ./.github/actions/build-apple-slices-hermes - with: - flavor: ${{ matrix.flavor }} - slice: ${{ matrix.slice}} - hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }} - react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }} - - build_hermes_macos: - runs-on: macos-14 - needs: [build_apple_slices_hermes, prepare_hermes_workspace] - env: - HERMES_WS_DIR: /tmp/hermes - HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin - continue-on-error: true - strategy: - fail-fast: false - matrix: - flavor: [Debug, Release] - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build Hermes MacOS - uses: ./.github/actions/build-hermes-macos - with: - hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }} - react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }} - flavor: ${{ matrix.flavor }} - prebuild_apple_dependencies: if: github.repository == 'facebook/react-native' uses: ./.github/workflows/prebuild-ios-dependencies.yml @@ -106,51 +27,14 @@ jobs: prebuild_react_native_core: uses: ./.github/workflows/prebuild-ios-core.yml secrets: inherit - needs: [prebuild_apple_dependencies, build_hermes_macos] - - build_hermesc_linux: - runs-on: ubuntu-latest - needs: prepare_hermes_workspace - env: - HERMES_WS_DIR: /tmp/hermes - HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build HermesC Linux - uses: ./.github/actions/build-hermesc-linux - with: - hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }} - react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }} - - build_hermesc_windows: - runs-on: windows-2025 - needs: prepare_hermes_workspace - env: - HERMES_WS_DIR: 'C:\tmp\hermes' - HERMES_TARBALL_ARTIFACTS_DIR: 'C:\tmp\hermes\hermes-runtime-darwin' - HERMES_OSXBIN_ARTIFACTS_DIR: 'C:\tmp\hermes\osx-bin' - ICU_URL: "https://github.com/unicode-org/icu/releases/download/release-64-2/icu4c-64_2-Win64-MSVC2017.zip" - MSBUILD_DIR: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin' - CMAKE_DIR: 'C:\Program Files\CMake\bin' - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build HermesC Windows - uses: ./.github/actions/build-hermesc-windows - with: - hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }} - react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }} + needs: [prebuild_apple_dependencies] build_npm_package: runs-on: 8-core-ubuntu needs: [ set_release_type, - prepare_hermes_workspace, - build_hermes_macos, - build_hermesc_linux, - build_hermesc_windows, + prepare_workspace, prebuild_apple_dependencies, prebuild_react_native_core, ] @@ -162,7 +46,6 @@ jobs: # By default we only build ARM64 to save time/resources. For release/nightlies, we override this value to build all archs. ORG_GRADLE_PROJECT_reactNativeArchitectures: "arm64-v8a" env: - HERMES_WS_DIR: /tmp/hermes GHA_NPM_TOKEN: ${{ secrets.GHA_NPM_TOKEN }} ORG_GRADLE_PROJECT_SIGNING_PWD: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_PWD }} ORG_GRADLE_PROJECT_SIGNING_KEY: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_KEY }} @@ -178,7 +61,6 @@ jobs: - name: Build and Publish NPM Package uses: ./.github/actions/build-npm-package with: - hermes-ws-dir: ${{ env.HERMES_WS_DIR }} release-type: ${{ needs.set_release_type.outputs.RELEASE_TYPE }} gha-npm-token: ${{ env.GHA_NPM_TOKEN }} gradle-cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }} diff --git a/.github/workflows/test-all.yml b/.github/workflows/test-all.yml index cca5c3385b31..a8c33b3b5dc0 100644 --- a/.github/workflows/test-all.yml +++ b/.github/workflows/test-all.yml @@ -33,86 +33,6 @@ jobs: echo "Should I run E2E tests? ${{ inputs.run-e2e-tests }}" - prepare_hermes_workspace: - runs-on: ubuntu-latest - if: github.repository == 'facebook/react-native' - env: - HERMES_WS_DIR: /tmp/hermes - HERMES_VERSION_FILE: packages/react-native/sdks/.hermesversion - outputs: - react-native-version: ${{ steps.prepare-hermes-workspace.outputs.react-native-version }} - hermes-version: ${{ steps.prepare-hermes-workspace.outputs.hermes-version }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Prepare Hermes Workspace - id: prepare-hermes-workspace - uses: ./.github/actions/prepare-hermes-workspace - with: - hermes-ws-dir: ${{ env.HERMES_WS_DIR }} - hermes-version-file: ${{ env.HERMES_VERSION_FILE }} - - build_hermesc_apple: - runs-on: macos-14 - needs: prepare_hermes_workspace - env: - HERMES_WS_DIR: /tmp/hermes - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build HermesC Apple - uses: ./.github/actions/build-hermesc-apple - with: - hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }} - react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }} - - build_apple_slices_hermes: - runs-on: macos-14 - needs: [build_hermesc_apple, prepare_hermes_workspace] - env: - HERMES_WS_DIR: /tmp/hermes - HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin - HERMES_OSXBIN_ARTIFACTS_DIR: /tmp/hermes/osx-bin - IOS_DEPLOYMENT_TARGET: "15.1" - XROS_DEPLOYMENT_TARGET: "1.0" - MAC_DEPLOYMENT_TARGET: "10.15" - strategy: - fail-fast: false - matrix: - flavor: [Debug, Release] - slice: [macosx, iphoneos, iphonesimulator, appletvos, appletvsimulator, catalyst, xros, xrsimulator] - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build Slice - uses: ./.github/actions/build-apple-slices-hermes - with: - flavor: ${{ matrix.flavor }} - slice: ${{ matrix.slice}} - hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }} - react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }} - - build_hermes_macos: - runs-on: macos-14 - needs: [build_apple_slices_hermes, prepare_hermes_workspace] - env: - HERMES_WS_DIR: /tmp/hermes - HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin - continue-on-error: true - strategy: - fail-fast: false - matrix: - flavor: [Debug, Release] - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build Hermes MacOS - uses: ./.github/actions/build-hermes-macos - with: - hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }} - react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }} - flavor: ${{ matrix.flavor }} - prebuild_apple_dependencies: if: github.repository == 'facebook/react-native' uses: ./.github/workflows/prebuild-ios-dependencies.yml @@ -120,16 +40,15 @@ jobs: prebuild_react_native_core: uses: ./.github/workflows/prebuild-ios-core.yml + with: + use-hermes-nightly: ${{ !endsWith(github.ref_name, '-stable') }} secrets: inherit - needs: [prebuild_apple_dependencies, build_hermes_macos] + needs: [prebuild_apple_dependencies] test_ios_rntester_ruby_3_2_0: runs-on: macos-14 needs: - [build_apple_slices_hermes, prepare_hermes_workspace, build_hermes_macos, prebuild_apple_dependencies, prebuild_react_native_core] - env: - HERMES_WS_DIR: /tmp/hermes - HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin + [prebuild_apple_dependencies, prebuild_react_native_core] steps: - name: Checkout uses: actions/checkout@v4 @@ -137,17 +56,12 @@ jobs: uses: ./.github/actions/test-ios-rntester with: ruby-version: "3.2.0" - hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }} - react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }} flavor: Debug test_ios_rntester: runs-on: macos-14-large needs: - [build_apple_slices_hermes, prepare_hermes_workspace, build_hermes_macos, prebuild_apple_dependencies, prebuild_react_native_core] - env: - HERMES_WS_DIR: /tmp/hermes - HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin + [prebuild_apple_dependencies, prebuild_react_native_core] continue-on-error: true strategy: fail-fast: false @@ -161,17 +75,12 @@ jobs: uses: ./.github/actions/test-ios-rntester with: use-frameworks: ${{ matrix.frameworks }} - hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }} - react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }} flavor: ${{ matrix.flavor }} test_e2e_ios_rntester: runs-on: macos-14-large needs: [test_ios_rntester] - env: - HERMES_WS_DIR: /tmp/hermes - HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin strategy: fail-fast: false matrix: @@ -201,9 +110,6 @@ jobs: test_e2e_ios_templateapp: runs-on: macos-14-large needs: [build_npm_package, prebuild_apple_dependencies] - env: - HERMES_WS_DIR: /tmp/hermes - HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin strategy: fail-fast: false matrix: @@ -221,11 +127,6 @@ jobs: uses: ruby/setup-ruby@v1 with: ruby-version: 2.6.10 - - name: Download Hermes - uses: actions/download-artifact@v4 - with: - name: hermes-darwin-bin-${{matrix.flavor}} - path: /tmp/react-native-tmp - name: Download React Native Package uses: actions/download-artifact@v4 with: @@ -259,9 +160,6 @@ jobs: REACT_NATIVE_PKG=$(find /tmp/react-native-tmp -type f -name "*.tgz") echo "React Native tgs is $REACT_NATIVE_PKG" - HERMES_PATH=$(find /tmp/react-native-tmp -type f -name "*.tar.gz") - echo "Hermes path is $HERMES_PATH" - # For stable branches, we want to use the stable branch of the template # In all the other cases, we want to use "main" BRANCH=${{ github.ref_name }} @@ -278,7 +176,7 @@ jobs: export RCT_USE_LOCAL_RN_DEP=/tmp/third-party/ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz # Disable prebuilds for now, as they are causing issues with E2E tests for 0.82-stable branch # export RCT_TESTONLY_RNCORE_TARBALL_PATH="/tmp/ReactCore/ReactCore${{ matrix.flavor }}.xcframework.tar.gz" - HERMES_ENGINE_TARBALL_PATH=$HERMES_PATH RCT_NEW_ARCH_ENABLED=$NEW_ARCH_ENABLED bundle exec pod install + RCT_NEW_ARCH_ENABLED=$NEW_ARCH_ENABLED bundle exec pod install xcodebuild \ -scheme "RNTestProject" \ @@ -364,21 +262,6 @@ jobs: flavor: ${{ matrix.flavor }} working-directory: /tmp/RNTestProject - build_hermesc_linux: - runs-on: ubuntu-latest - needs: prepare_hermes_workspace - env: - HERMES_WS_DIR: /tmp/hermes - HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build HermesC Linux - uses: ./.github/actions/build-hermesc-linux - with: - hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }} - react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }} - run_fantom_tests: runs-on: 8-core-ubuntu needs: [set_release_type] @@ -398,25 +281,6 @@ jobs: release-type: ${{ needs.set_release_type.outputs.RELEASE_TYPE }} gradle-cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }} - build_hermesc_windows: - runs-on: windows-2025 - needs: prepare_hermes_workspace - env: - HERMES_WS_DIR: 'C:\tmp\hermes' - HERMES_TARBALL_ARTIFACTS_DIR: 'C:\tmp\hermes\hermes-runtime-darwin' - HERMES_OSXBIN_ARTIFACTS_DIR: 'C:\tmp\hermes\osx-bin' - ICU_URL: "https://github.com/unicode-org/icu/releases/download/release-64-2/icu4c-64_2-Win64-MSVC2017.zip" - MSBUILD_DIR: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin' - CMAKE_DIR: 'C:\Program Files\CMake\bin' - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build HermesC Windows - uses: ./.github/actions/build-hermesc-windows - with: - hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }} - react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }} - build_android: runs-on: 8-core-ubuntu needs: [set_release_type] @@ -471,10 +335,6 @@ jobs: needs: [ set_release_type, - prepare_hermes_workspace, - build_hermes_macos, - build_hermesc_linux, - build_hermesc_windows, build_android, prebuild_apple_dependencies, prebuild_react_native_core, @@ -484,15 +344,12 @@ jobs: env: TERM: "dumb" GRADLE_OPTS: "-Dorg.gradle.daemon=false" - env: - HERMES_WS_DIR: /tmp/hermes steps: - name: Checkout uses: actions/checkout@v4 - name: Build NPM Package uses: ./.github/actions/build-npm-package with: - hermes-ws-dir: ${{ env.HERMES_WS_DIR }} release-type: ${{ needs.set_release_type.outputs.RELEASE_TYPE }} gradle-cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }} @@ -535,6 +392,12 @@ jobs: cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }} - name: Run yarn install uses: ./.github/actions/yarn-install + - name: Set nightly Hermes versions + shell: bash + run: | + node ./scripts/releases/use-hermes-nightly.js + - name: Run yarn install again, with the correct hermes version + uses: ./.github/actions/yarn-install - name: Prepare the Helloworld application shell: bash run: node ./scripts/e2e/init-project-e2e.js --useHelloWorld --pathToLocalReactNative "$GITHUB_WORKSPACE/build/$(cat build/react-native-package-version)" @@ -556,10 +419,9 @@ jobs: test_ios_helloworld_with_ruby_3_2_0: runs-on: macos-14 - needs: [prepare_hermes_workspace, build_hermes_macos, prebuild_apple_dependencies, prebuild_react_native_core] # prepare_hermes_workspace must be there because we need its reference to retrieve a couple of outputs + needs: [prebuild_apple_dependencies, prebuild_react_native_core] env: PROJECT_NAME: iOSTemplateProject - HERMES_WS_DIR: /tmp/hermes YARN_ENABLE_IMMUTABLE_INSTALLS: false steps: - name: Checkout @@ -568,12 +430,10 @@ jobs: with: ruby-version: 3.2.0 flavor: Debug - hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }} - react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }} test_ios_helloworld: runs-on: macos-14 - needs: [prepare_hermes_workspace, build_hermes_macos, prebuild_apple_dependencies, prebuild_react_native_core] # prepare_hermes_workspace must be there because we need its reference to retrieve a couple of outputs + needs: [prebuild_apple_dependencies, prebuild_react_native_core] strategy: matrix: flavor: [Debug, Release] @@ -584,7 +444,6 @@ jobs: use_frameworks: StaticLibraries env: PROJECT_NAME: iOSTemplateProject - HERMES_WS_DIR: /tmp/hermes YARN_ENABLE_IMMUTABLE_INSTALLS: false steps: - name: Checkout @@ -593,8 +452,6 @@ jobs: with: flavor: ${{ matrix.flavor }} use-frameworks: ${{ matrix.use_frameworks }} - hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }} - react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }} test_js: runs-on: ubuntu-latest diff --git a/build.gradle.kts b/build.gradle.kts index f1f420380699..40846ef4e82d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -104,10 +104,6 @@ tasks.register("build") { tasks.register("publishAllToMavenTempLocal") { description = "Publish all the artifacts to be available inside a Maven Local repository on /tmp." dependsOn(":packages:react-native:ReactAndroid:publishAllPublicationsToMavenTempLocalRepository") - // We don't publish the external-artifacts to Maven Local as ci is using it via workspace. - dependsOn( - ":packages:react-native:ReactAndroid:hermes-engine:publishAllPublicationsToMavenTempLocalRepository" - ) } tasks.register("publishAndroidToSonatype") { @@ -135,8 +131,7 @@ if (project.findProperty("react.internal.useHermesNightly")?.toString()?.toBoole configurations.all { resolutionStrategy.dependencySubstitution { substitute(project(":packages:react-native:ReactAndroid:hermes-engine")) - // TODO: T237406039 update coordinates - .using(module("com.facebook.react:hermes-android:0.+")) + .using(module("com.facebook.hermes:hermes-android:0.+")) .because("Users opted to use hermes from nightly") } } diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt index 47e4646f908c..9984aa67ae8a 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt @@ -14,7 +14,6 @@ import com.facebook.react.utils.KotlinStdlibCompatUtils.capitalizeCompat import com.facebook.react.utils.NdkConfiguratorUtils.configureJsEnginePackagingOptions import com.facebook.react.utils.NdkConfiguratorUtils.configureNewArchPackagingOptions import com.facebook.react.utils.ProjectUtils.isHermesEnabled -import com.facebook.react.utils.ProjectUtils.isHermesV1Enabled import com.facebook.react.utils.ProjectUtils.useThirdPartyJSC import com.facebook.react.utils.detectedCliFile import com.facebook.react.utils.detectedEntryFile @@ -49,7 +48,6 @@ internal fun Project.configureReactTasks(variant: Variant, config: ReactExtensio } else { isHermesEnabledInProject } - val isHermesV1Enabled = project.isHermesV1Enabled || rootProject.isHermesV1Enabled val isDebuggableVariant = config.debuggableVariants.get().any { it.equals(variant.name, ignoreCase = true) } val useThirdPartyJSC = project.useThirdPartyJSC @@ -80,7 +78,6 @@ internal fun Project.configureReactTasks(variant: Variant, config: ReactExtensio task.jsBundleDir.set(jsBundleDir) task.resourcesDir.set(resourcesDir) task.hermesEnabled.set(isHermesEnabledInThisVariant) - task.hermesV1Enabled.set(isHermesV1Enabled) task.minifyEnabled.set(!isHermesEnabledInThisVariant) task.devEnabled.set(false) task.jsIntermediateSourceMapsDir.set(jsIntermediateSourceMapsDir) diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BundleHermesCTask.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BundleHermesCTask.kt index 52ec17479639..89ba3656a3e6 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BundleHermesCTask.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BundleHermesCTask.kt @@ -63,8 +63,6 @@ abstract class BundleHermesCTask : DefaultTask() { @get:Input abstract val hermesEnabled: Property - @get:Input abstract val hermesV1Enabled: Property - @get:Input abstract val devEnabled: Property @get:Input abstract val extraPackagerArgs: ListProperty @@ -96,8 +94,7 @@ abstract class BundleHermesCTask : DefaultTask() { runCommand(bundleCommand) if (hermesEnabled.get()) { - val detectedHermesCommand = - detectOSAwareHermesCommand(root.get().asFile, hermesCommand.get(), hermesV1Enabled.get()) + val detectedHermesCommand = detectOSAwareHermesCommand(root.get().asFile, hermesCommand.get()) val bytecodeFile = File("${bundleFile}.hbc") val outputSourceMap = resolveOutputSourceMap(bundleAssetFilename) val compilerSourceMap = resolveCompilerSourceMap(bundleAssetFilename) diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt index 1d8d1c84564e..f93ef2c9c144 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt @@ -14,6 +14,7 @@ import com.facebook.react.utils.PropertyUtils.INCLUDE_JITPACK_REPOSITORY import com.facebook.react.utils.PropertyUtils.INCLUDE_JITPACK_REPOSITORY_DEFAULT import com.facebook.react.utils.PropertyUtils.INTERNAL_HERMES_PUBLISHING_GROUP import com.facebook.react.utils.PropertyUtils.INTERNAL_HERMES_V1_VERSION_NAME +import com.facebook.react.utils.PropertyUtils.INTERNAL_HERMES_VERSION_NAME import com.facebook.react.utils.PropertyUtils.INTERNAL_REACT_NATIVE_MAVEN_LOCAL_REPO import com.facebook.react.utils.PropertyUtils.INTERNAL_REACT_PUBLISHING_GROUP import com.facebook.react.utils.PropertyUtils.INTERNAL_USE_HERMES_NIGHTLY @@ -139,11 +140,7 @@ internal object DependencyUtils { // Contributors only: The hermes-engine version is forced only if the user has // not opted into using nightlies for local development. configuration.resolutionStrategy.force( - // TODO: T237406039 update coordinates - if (hermesV1Enabled) - "${coordinates.hermesGroupString}:hermes-android:${coordinates.hermesV1VersionString}" - else - "${coordinates.reactGroupString}:hermes-android:${coordinates.hermesVersionString}" + "${coordinates.hermesGroupString}:hermes-android:${if (hermesV1Enabled) coordinates.hermesV1VersionString else coordinates.hermesVersionString}" ) } } @@ -154,13 +151,10 @@ internal object DependencyUtils { coordinates: Coordinates, hermesV1Enabled: Boolean = false, ): List> { - // TODO: T231755027 update coordinates and versioning val dependencySubstitution = mutableListOf>() - // TODO: T237406039 update coordinates - val hermesVersionString = - if (hermesV1Enabled) - "${coordinates.hermesGroupString}:hermes-android:${coordinates.hermesV1VersionString}" - else "${coordinates.reactGroupString}:hermes-android:${coordinates.hermesVersionString}" + val hermesVersion = + if (hermesV1Enabled) coordinates.hermesV1VersionString else coordinates.hermesVersionString + val hermesVersionString = "${coordinates.hermesGroupString}:hermes-android:${hermesVersion}" dependencySubstitution.add( Triple( "com.facebook.react:react-native", @@ -175,6 +169,13 @@ internal object DependencyUtils { "The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210.", ) ) + dependencySubstitution.add( + Triple( + "com.facebook.react:hermes-android", + hermesVersionString, + "The hermes-android artifact was moved to com.facebook.hermes publishing group.", + ) + ) if (coordinates.reactGroupString != DEFAULT_INTERNAL_REACT_PUBLISHING_GROUP) { dependencySubstitution.add( Triple( @@ -183,7 +184,6 @@ internal object DependencyUtils { "The react-android dependency was modified to use the correct Maven group.", ) ) - // TODO: T237406039 update coordinates dependencySubstitution.add( Triple( "com.facebook.react:hermes-android", @@ -191,12 +191,13 @@ internal object DependencyUtils { "The hermes-android dependency was modified to use the correct Maven group.", ) ) - } else if (hermesV1Enabled) { + } + if (coordinates.hermesGroupString != DEFAULT_INTERNAL_HERMES_PUBLISHING_GROUP) { dependencySubstitution.add( Triple( - "com.facebook.react:hermes-android", + "com.facebook.hermes:hermes-android", hermesVersionString, - "The hermes-android dependency was modified to use Hermes V1.", + "The hermes-android dependency was modified to use the correct Maven group.", ) ) } @@ -221,11 +222,19 @@ internal object DependencyUtils { val hermesGroupString = reactAndroidProperties[INTERNAL_HERMES_PUBLISHING_GROUP] as? String ?: DEFAULT_INTERNAL_HERMES_PUBLISHING_GROUP - // TODO: T237406039 read both versions from the same file + val hermesVersionProperties = Properties() hermesVersionFile.inputStream().use { hermesVersionProperties.load(it) } - val hermesVersion = versionString + val hermesVersionString = + (hermesVersionProperties[INTERNAL_HERMES_VERSION_NAME] as? String).orEmpty() + val hermesVersion = + if (hermesVersionString.startsWith("0.0.0") || "-commitly-" in hermesVersionString) { + "$hermesVersionString-SNAPSHOT" + } else { + hermesVersionString + } + val hermesV1Version = (hermesVersionProperties[INTERNAL_HERMES_V1_VERSION_NAME] as? String).orEmpty() diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PathUtils.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PathUtils.kt index a69de8b3752a..510b157e6b1e 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PathUtils.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PathUtils.kt @@ -130,7 +130,6 @@ private fun detectCliFile(reactNativeRoot: File, preconfiguredCliFile: File?): F internal fun detectOSAwareHermesCommand( projectRoot: File, hermesCommand: String, - hermesV1Enabled: Boolean = false, ): String { // 1. If the project specifies a Hermes command, don't second guess it. if (hermesCommand.isNotBlank()) { val osSpecificHermesCommand = @@ -151,13 +150,9 @@ internal fun detectOSAwareHermesCommand( return builtHermesc.cliPath(projectRoot) } - // 3. If Hermes V1 is enabled, use hermes-compiler from npm, otherwise, if the - // react-native contains a pre-built hermesc, use it. - // TODO: T237406039 use hermes-compiler from npm for both - val hermesCPath = if (hermesV1Enabled) HERMES_COMPILER_NPM_DIR else HERMESC_IN_REACT_NATIVE_DIR + // 3. Use hermes-compiler from npm val prebuiltHermesPath = - hermesCPath - .plus(getHermesCBin()) + HERMES_COMPILER_NPM_DIR.plus(getHermesCBin()) .replace("%OS-BIN%", getHermesOSBin()) // Execution on Windows fails with / as separator .replace('/', File.separatorChar) @@ -243,6 +238,5 @@ internal fun readPackageJsonFile( } private const val HERMES_COMPILER_NPM_DIR = "node_modules/hermes-compiler/hermesc/%OS-BIN%/" -private const val HERMESC_IN_REACT_NATIVE_DIR = "node_modules/react-native/sdks/hermesc/%OS-BIN%/" private const val HERMESC_BUILT_FROM_SOURCE_DIR = "node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/bin/" diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PropertyUtils.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PropertyUtils.kt index 8f7e4928a81e..fa75308e3616 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PropertyUtils.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PropertyUtils.kt @@ -81,8 +81,9 @@ object PropertyUtils { const val INTERNAL_VERSION_NAME = "VERSION_NAME" /** - * Internal property, shared with iOS, used to control the version name of Hermes Engine. This is - * stored in sdks/hermes-engine/version.properties + * Internal properties, shared with iOS, used to control the version name of Hermes Engine. They + * are stored in sdks/hermes-engine/version.properties */ + const val INTERNAL_HERMES_VERSION_NAME = "HERMES_VERSION_NAME" const val INTERNAL_HERMES_V1_VERSION_NAME = "HERMES_V1_VERSION_NAME" } diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt index 43b6c946ba59..b48ea7984633 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt @@ -289,7 +289,7 @@ class DependencyUtilsTest { val forcedModules = project.configurations.first().resolutionStrategy.forcedModules assertThat(forcedModules.any { it.toString() == "com.facebook.react:react-android:1.2.3" }) .isTrue() - assertThat(forcedModules.any { it.toString() == "com.facebook.react:hermes-android:4.5.6" }) + assertThat(forcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:4.5.6" }) .isTrue() } @@ -324,11 +324,11 @@ class DependencyUtilsTest { val libForcedModules = libProject.configurations.first().resolutionStrategy.forcedModules assertThat(appForcedModules.any { it.toString() == "com.facebook.react:react-android:1.2.3" }) .isTrue() - assertThat(appForcedModules.any { it.toString() == "com.facebook.react:hermes-android:4.5.6" }) + assertThat(appForcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:4.5.6" }) .isTrue() assertThat(libForcedModules.any { it.toString() == "com.facebook.react:react-android:1.2.3" }) .isTrue() - assertThat(libForcedModules.any { it.toString() == "com.facebook.react:hermes-android:4.5.6" }) + assertThat(libForcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:4.5.6" }) .isTrue() } @@ -381,11 +381,15 @@ class DependencyUtilsTest { val libForcedModules = libProject.configurations.first().resolutionStrategy.forcedModules assertThat(appForcedModules.any { it.toString() == "io.github.test:react-android:1.2.3" }) .isTrue() - assertThat(appForcedModules.any { it.toString() == "io.github.test:hermes-android:4.5.6" }) + assertThat( + appForcedModules.any { it.toString() == "io.github.test.hermes:hermes-android:4.5.6" } + ) .isTrue() assertThat(libForcedModules.any { it.toString() == "io.github.test:react-android:1.2.3" }) .isTrue() - assertThat(libForcedModules.any { it.toString() == "io.github.test:hermes-android:4.5.6" }) + assertThat( + libForcedModules.any { it.toString() == "io.github.test.hermes:hermes-android:4.5.6" } + ) .isTrue() } @@ -438,7 +442,7 @@ class DependencyUtilsTest { ) .isEqualTo(dependencySubstitutions[0].third) assertThat("com.facebook.react:hermes-engine").isEqualTo(dependencySubstitutions[1].first) - assertThat("com.facebook.react:hermes-android:0.42.0") + assertThat("com.facebook.hermes:hermes-android:0.42.0") .isEqualTo(dependencySubstitutions[1].second) assertThat( "The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210." @@ -490,19 +494,26 @@ class DependencyUtilsTest { ) .isEqualTo(dependencySubstitutions[0].third) assertThat("com.facebook.react:hermes-engine").isEqualTo(dependencySubstitutions[1].first) - assertThat("io.github.test:hermes-android:0.42.0").isEqualTo(dependencySubstitutions[1].second) + assertThat("io.github.test.hermes:hermes-android:0.42.0") + .isEqualTo(dependencySubstitutions[1].second) assertThat( "The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210." ) .isEqualTo(dependencySubstitutions[1].third) - assertThat("com.facebook.react:react-android").isEqualTo(dependencySubstitutions[2].first) - assertThat("io.github.test:react-android:0.42.0").isEqualTo(dependencySubstitutions[2].second) - assertThat("The react-android dependency was modified to use the correct Maven group.") + assertThat("com.facebook.react:hermes-android").isEqualTo(dependencySubstitutions[2].first) + assertThat("io.github.test.hermes:hermes-android:0.42.0") + .isEqualTo(dependencySubstitutions[2].second) + assertThat("The hermes-android artifact was moved to com.facebook.hermes publishing group.") .isEqualTo(dependencySubstitutions[2].third) - assertThat("com.facebook.react:hermes-android").isEqualTo(dependencySubstitutions[3].first) - assertThat("io.github.test:hermes-android:0.42.0").isEqualTo(dependencySubstitutions[3].second) - assertThat("The hermes-android dependency was modified to use the correct Maven group.") + assertThat("com.facebook.react:react-android").isEqualTo(dependencySubstitutions[3].first) + assertThat("io.github.test:react-android:0.42.0").isEqualTo(dependencySubstitutions[3].second) + assertThat("The react-android dependency was modified to use the correct Maven group.") .isEqualTo(dependencySubstitutions[3].third) + assertThat("com.facebook.react:hermes-android").isEqualTo(dependencySubstitutions[4].first) + assertThat("io.github.test.hermes:hermes-android:0.42.0") + .isEqualTo(dependencySubstitutions[4].second) + assertThat("The hermes-android dependency was modified to use the correct Maven group.") + .isEqualTo(dependencySubstitutions[4].third) } @Test @@ -532,15 +543,20 @@ class DependencyUtilsTest { "The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210." ) .isEqualTo(dependencySubstitutions[1].third) - assertThat("com.facebook.react:react-android").isEqualTo(dependencySubstitutions[2].first) - assertThat("io.github.test:react-android:0.42.0").isEqualTo(dependencySubstitutions[2].second) - assertThat("The react-android dependency was modified to use the correct Maven group.") + assertThat("com.facebook.react:hermes-android").isEqualTo(dependencySubstitutions[2].first) + assertThat("io.github.test.hermes:hermes-android:0.43.0") + .isEqualTo(dependencySubstitutions[2].second) + assertThat("The hermes-android artifact was moved to com.facebook.hermes publishing group.") .isEqualTo(dependencySubstitutions[2].third) - assertThat("com.facebook.react:hermes-android").isEqualTo(dependencySubstitutions[3].first) + assertThat("com.facebook.react:react-android").isEqualTo(dependencySubstitutions[3].first) + assertThat("io.github.test:react-android:0.42.0").isEqualTo(dependencySubstitutions[3].second) + assertThat("The react-android dependency was modified to use the correct Maven group.") + .isEqualTo(dependencySubstitutions[3].third) + assertThat("com.facebook.react:hermes-android").isEqualTo(dependencySubstitutions[4].first) assertThat("io.github.test.hermes:hermes-android:0.43.0") - .isEqualTo(dependencySubstitutions[3].second) + .isEqualTo(dependencySubstitutions[4].second) assertThat("The hermes-android dependency was modified to use the correct Maven group.") - .isEqualTo(dependencySubstitutions[3].third) + .isEqualTo(dependencySubstitutions[4].third) } @Test @@ -560,6 +576,7 @@ class DependencyUtilsTest { tempFolder.newFile("version.properties").apply { writeText( """ + HERMES_VERSION_NAME=1000.0.0 HERMES_V1_VERSION_NAME=1000.0.0 ANOTHER_PROPERTY=true """ @@ -596,6 +613,7 @@ class DependencyUtilsTest { tempFolder.newFile("version.properties").apply { writeText( """ + HERMES_VERSION_NAME=0.14.0 HERMES_V1_VERSION_NAME=250829098.0.0-stable ANOTHER_PROPERTY=true """ @@ -609,7 +627,7 @@ class DependencyUtilsTest { val hermesV1VersionString = strings.hermesV1VersionString assertThat(versionString).isEqualTo("0.0.0-20221101-2019-cfe811ab1-SNAPSHOT") - assertThat(hermesVersionString).isEqualTo("0.0.0-20221101-2019-cfe811ab1-SNAPSHOT") + assertThat(hermesVersionString).isEqualTo("0.14.0") assertThat(hermesV1VersionString).isEqualTo("250829098.0.0-stable") } @@ -661,6 +679,7 @@ class DependencyUtilsTest { tempFolder.newFile("version.properties").apply { writeText( """ + HERMES_VERSION_NAME= HERMES_V1_VERSION_NAME= ANOTHER_PROPERTY=true """ @@ -695,6 +714,7 @@ class DependencyUtilsTest { tempFolder.newFile("version.properties").apply { writeText( """ + HERMES_VERSION_NAME= HERMES_V1_VERSION_NAME= ANOTHER_PROPERTY=true """ @@ -726,6 +746,7 @@ class DependencyUtilsTest { tempFolder.newFile("version.properties").apply { writeText( """ + HERMES_VERSION_NAME= HERMES_V1_VERSION_NAME= ANOTHER_PROPERTY=true """ diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/PathUtilsTest.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/PathUtilsTest.kt index d8690b83ab51..e4c9f5997650 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/PathUtilsTest.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/PathUtilsTest.kt @@ -155,21 +155,11 @@ class PathUtilsTest { @Test @WithOs(OS.MAC) - fun detectOSAwareHermesCommand_withBundledHermescInsideRN() { - tempFolder.newFolder("node_modules/react-native/sdks/hermesc/osx-bin/") - val expected = tempFolder.newFile("node_modules/react-native/sdks/hermesc/osx-bin/hermesc") - - assertThat(detectOSAwareHermesCommand(tempFolder.root, "")).isEqualTo(expected.toString()) - } - - @Test - @WithOs(OS.MAC) - fun detectOSAwareHermesCommand_withHermesV1Enabled() { + fun detectOSAwareHermesCommand_withHermescFromNPM() { tempFolder.newFolder("node_modules/hermes-compiler/hermesc/osx-bin/") val expected = tempFolder.newFile("node_modules/hermes-compiler/hermesc/osx-bin/hermesc") - assertThat(detectOSAwareHermesCommand(tempFolder.root, "", hermesV1Enabled = true)) - .isEqualTo(expected.toString()) + assertThat(detectOSAwareHermesCommand(tempFolder.root, "")).isEqualTo(expected.toString()) } @Test(expected = IllegalStateException::class) diff --git a/packages/react-native/ReactAndroid/external-artifacts/build.gradle.kts b/packages/react-native/ReactAndroid/external-artifacts/build.gradle.kts index 6e4dc499c6d8..1ed2851218df 100644 --- a/packages/react-native/ReactAndroid/external-artifacts/build.gradle.kts +++ b/packages/react-native/ReactAndroid/external-artifacts/build.gradle.kts @@ -17,42 +17,6 @@ version = configurations.maybeCreate("externalArtifacts") -// Those artifacts should be placed inside the `artifacts/hermes-ios-*.tar.gz` location. -val hermesiOSDebugArtifactFile: RegularFile = - layout.projectDirectory.file("artifacts/hermes-ios-debug.tar.gz") -val hermesiOSDebugArtifact: PublishArtifact = - artifacts.add("externalArtifacts", hermesiOSDebugArtifactFile) { - type = "tgz" - extension = "tar.gz" - classifier = "hermes-ios-debug" - } -val hermesiOSReleaseArtifactFile: RegularFile = - layout.projectDirectory.file("artifacts/hermes-ios-release.tar.gz") -val hermesiOSReleaseArtifact: PublishArtifact = - artifacts.add("externalArtifacts", hermesiOSReleaseArtifactFile) { - type = "tgz" - extension = "tar.gz" - classifier = "hermes-ios-release" - } - -// Those artifacts should be placed inside the `artifacts/hermes-*.framework.dSYM` location -val hermesDSYMDebugArtifactFile: RegularFile = - layout.projectDirectory.file("artifacts/hermes-framework-dSYM-debug.tar.gz") -val hermesDSYMDebugArtifact: PublishArtifact = - artifacts.add("externalArtifacts", hermesDSYMDebugArtifactFile) { - type = "tgz" - extension = "tar.gz" - classifier = "hermes-framework-dSYM-debug" - } -val hermesDSYMReleaseArtifactFile: RegularFile = - layout.projectDirectory.file("artifacts/hermes-framework-dSYM-release.tar.gz") -val hermesDSYMReleaseArtifact: PublishArtifact = - artifacts.add("externalArtifacts", hermesDSYMReleaseArtifactFile) { - type = "tgz" - extension = "tar.gz" - classifier = "hermes-framework-dSYM-release" - } - // [iOS] React Native Dependencies val reactNativeDependenciesDebugArtifactFile: RegularFile = layout.projectDirectory.file("artifacts/ReactNativeDependenciesDebug.xcframework.tar.gz") @@ -131,10 +95,6 @@ publishing { publications { getByName("release", MavenPublication::class) { artifactId = "react-native-artifacts" - artifact(hermesiOSDebugArtifact) - artifact(hermesiOSReleaseArtifact) - artifact(hermesDSYMDebugArtifact) - artifact(hermesDSYMReleaseArtifact) artifact(reactNativeDependenciesDebugArtifact) artifact(reactNativeDependenciesReleaseArtifact) artifact(reactNativeDependenciesDebugDSYMArtifact) diff --git a/packages/react-native/ReactAndroid/hermes-engine/build.gradle.kts b/packages/react-native/ReactAndroid/hermes-engine/build.gradle.kts index c59c7c4885f1..f62d5f2960cd 100644 --- a/packages/react-native/ReactAndroid/hermes-engine/build.gradle.kts +++ b/packages/react-native/ReactAndroid/hermes-engine/build.gradle.kts @@ -386,14 +386,3 @@ tasks.withType().configureEach { options.compilerArgs.add("-Xlint:deprecation,unchecked") options.compilerArgs.add("-Werror") } - -/* Publishing Configuration */ -apply(from = "../publish.gradle") - -// We need to override the artifact ID as this project is called `hermes-engine` but -// the maven coordinates are on `hermes-android`. -// Please note that the original coordinates, `hermes-engine`, have been voided -// as they caused https://github.com/facebook/react-native/issues/35210 -publishing { - publications { getByName("release", MavenPublication::class) { artifactId = "hermes-android" } } -} diff --git a/packages/react-native/scripts/hermes/__tests__/hermes-utils-test.js b/packages/react-native/scripts/hermes/__tests__/hermes-utils-test.js index f295569ab721..510000e27afb 100644 --- a/packages/react-native/scripts/hermes/__tests__/hermes-utils-test.js +++ b/packages/react-native/scripts/hermes/__tests__/hermes-utils-test.js @@ -11,142 +11,21 @@ import * as path from 'path'; const { - configureMakeForPrebuiltHermesC, - copyBuildScripts, - copyPodSpec, - createHermesPrebuiltArtifactsTarball, - createTarballFromDirectory, - downloadHermesSourceTarball, - expandHermesSourceTarball, - getHermesPrebuiltArtifactsTarballName, - getHermesTagSHA, - getHermesTarballDownloadPath, readHermesTag, + readHermesV1Tag, setHermesTag, - shouldUsePrebuiltHermesC, } = require('../hermes-utils'); // $FlowFixMe[untyped-import] (OSS) memfs const {memfs} = require('memfs'); -const os = require('os'); const hermesTag = 'hermes-2022-04-28-RNv0.69.0-15d07c2edd29a4ea0b8f15ab0588a0c1adb1200f'; -const tarballContents = 'dummy string'; -const hermescContents = 'dummy string'; -const hermesTagSha = '5244f819b2f3949ca94a3a1bf75d54a8ed59d94a'; +const hermesV1Tag = '250829098.0.0'; const ROOT_DIR = path.normalize(path.join(__dirname, '../../..')); const SDKS_DIR = path.join(ROOT_DIR, 'sdks'); -let execCalls: $FlowFixMe; -let spawnCalls: $FlowFixMe; let fs: $FlowFixMe; -jest.mock('child_process', () => ({ - execSync: jest.fn((command, options) => { - // git is used in getHermesTagSHA to obtain the commit sha for the latest commit to Hermes main - if (command.startsWith('git')) { - execCalls.git = true; - return hermesTagSha + '\n'; - } - }), - spawnSync: jest.fn((command, args, options) => { - // curl is used in downloadHermesSourceTarball to fetch the source code from github.com/facebook/hermes for a specific Hermes commit sha - if (command === 'curl') { - const downloadPath = args[2]; - fs.writeFileSync(downloadPath, tarballContents); - spawnCalls.curl = true; - return {code: 0}; - } - - // tar is used in createTarballFromDirectory - if (command === 'tar') { - spawnCalls.tar = true; - - if (args[0] === '-zxf') { - // We are expanding the tarball - fs.mkdirSync(path.join(SDKS_DIR, 'hermes/utils'), { - recursive: true, - }); - fs.writeFileSync(path.join(SDKS_DIR, 'hermes/package.json'), '{}'); - return {code: 0}; - } else if (args[2] === '-czvf') { - // We are creating the tarball - const filename = args[3]; - fs.writeFileSync(filename, tarballContents); - return {code: 0}; - } - } - - // rsync is used in createHermesPrebuiltArtifactsTarball - if (command === 'rsync') { - spawnCalls.rsync = true; - spawnCalls.rsyncArgs = args; - const destination = args[args.length - 1]; - - // Create destination directory - fs.mkdirSync(path.join(options.cwd, destination), { - recursive: true, - }); - } - }), -})); - -function populateMockFilesystemWithHermesBuildScripts() { - fs.mkdirSync(path.join(SDKS_DIR, 'hermes-engine/utils'), { - recursive: true, - }); - fs.writeFileSync( - path.join(SDKS_DIR, 'hermes-engine/utils/build-apple-framework.sh'), - 'Dummy file', - ); - fs.writeFileSync( - path.join(SDKS_DIR, 'hermes-engine/utils/build-ios-framework.sh'), - 'Dummy file', - ); - fs.writeFileSync( - path.join(SDKS_DIR, 'hermes-engine/utils/build-mac-framework.sh'), - 'Dummy file', - ); - fs.writeFileSync( - path.join(SDKS_DIR, 'hermes-engine/hermes-engine.podspec'), - 'Dummy file', - ); - fs.writeFileSync( - path.join(SDKS_DIR, 'hermes-engine/hermes-utils.rb'), - 'Dummy file', - ); -} - -function populateMockFilesystemWithHermesBuildArtifacts() { - fs.mkdirSync(os.tmpdir(), {recursive: true}); - const frameworksDir = path.join( - SDKS_DIR, - 'hermes/destroot/Library/Frameworks', - ); - fs.mkdirSync(path.join(frameworksDir, 'macosx/hermesvm.framework'), { - recursive: true, - }); - fs.mkdirSync(path.join(frameworksDir, 'universal/hermesvm.xcframework'), { - recursive: true, - }); - - const dsymsDirs = [ - 'macosx', - 'universal/hermesvm.xcframework/ios-arm64/dSYMs', - 'universal/hermesvm.xcframework/ios-arm64_x86_64-simulator/dSYMs', - 'universal/hermesvm.xcframework/ios-arm64_x86_64-maccatalyst/dSYMs', - ]; - - for (const dsymsDir of dsymsDirs) { - fs.mkdirSync( - path.join(frameworksDir, dsymsDir, 'hermesvm.framework.dSYM'), - { - recursive: true, - }, - ); - } -} - describe('hermes-utils', () => { beforeEach(() => { jest.resetModules(); @@ -154,10 +33,9 @@ describe('hermes-utils', () => { jest.mock('fs', () => memfs().fs); fs = require('fs'); - populateMockFilesystemWithHermesBuildScripts(); - - execCalls = Object.create(null); - spawnCalls = Object.create(null); + fs.mkdirSync(SDKS_DIR, { + recursive: true, + }); // Silence logs. jest.spyOn(console, 'log').mockImplementation(() => {}); @@ -166,8 +44,10 @@ describe('hermes-utils', () => { describe('Versioning Hermes', () => { describe('readHermesTag', () => { - it('should return main if .hermesversion does not exist', () => { - expect(readHermesTag()).toEqual('main'); + it('should throw if .hermesversion does not exist', () => { + expect(() => { + readHermesTag(); + }).toThrow('[Hermes] .hermesversion does not exist.'); }); it('should fail if hermes tag is empty', () => { fs.writeFileSync(path.join(SDKS_DIR, '.hermesversion'), ''); @@ -181,268 +61,45 @@ describe('hermes-utils', () => { }); }); - describe('setHermesTag', () => { - it('should write tag to .hermesversion file', () => { - setHermesTag(hermesTag); - expect( - fs.readFileSync(path.join(SDKS_DIR, '.hermesversion'), { - encoding: 'utf8', - flag: 'r', - }), - ).toEqual(hermesTag); + describe('readHermesV1Tag', () => { + it('should throw if .hermesv1version does not exist', () => { + expect(() => { + readHermesV1Tag(); + }).toThrow('[Hermes] .hermesv1version does not exist.'); }); - it('should set Hermes tag and read it back', () => { - setHermesTag(hermesTag); - expect(readHermesTag()).toEqual(hermesTag); + it('should fail if hermes v1 tag is empty', () => { + fs.writeFileSync(path.join(SDKS_DIR, '.hermesv1version'), ''); + expect(() => { + readHermesV1Tag(); + }).toThrow('[Hermes] .hermesv1version file is empty.'); }); - }); - - describe('getHermesTagSHA', () => { - it('should return trimmed commit SHA for Hermes tag', () => { - expect(getHermesTagSHA(hermesTag)).toEqual(hermesTagSha); - expect(execCalls.git).toBe(true); + it('should return tag from .hermesv1version if file exists', () => { + fs.writeFileSync(path.join(SDKS_DIR, '.hermesv1version'), hermesV1Tag); + expect(readHermesV1Tag()).toEqual(hermesV1Tag); }); }); - }); - describe('Downloading Hermes', () => { - describe('getHermesTarballDownloadPath', () => { - it('returns download path with Hermes tag sha', () => { - const hermesTarballDownloadPath = - getHermesTarballDownloadPath(hermesTag); - expect(hermesTarballDownloadPath).toEqual( - path.join( - SDKS_DIR, - 'download', - `hermes-${getHermesTagSHA(hermesTag)}.tgz`, - ), - ); - }); - }); - describe('downloadHermesSourceTarball', () => { - it('should download Hermes source tarball to download dir', () => { - fs.writeFileSync(path.join(SDKS_DIR, '.hermesversion'), hermesTag); - const hermesTarballDownloadPath = - getHermesTarballDownloadPath(hermesTag); - downloadHermesSourceTarball(); - expect(spawnCalls.curl).toBe(true); + describe('setHermesTag', () => { + it('should write tag to .hermesversion file', async () => { + await setHermesTag(hermesTag, hermesV1Tag); expect( - fs.readFileSync(hermesTarballDownloadPath, { + fs.readFileSync(path.join(SDKS_DIR, '.hermesversion'), { encoding: 'utf8', flag: 'r', }), - ).toEqual(tarballContents); - }); - it('should not re-download Hermes source tarball if tarball exists', () => { - fs.mkdirSync(path.join(SDKS_DIR, 'download'), {recursive: true}); - fs.writeFileSync( - path.join(SDKS_DIR, 'download', `hermes-${hermesTagSha}.tgz`), - tarballContents, - ); - - downloadHermesSourceTarball(); - expect(spawnCalls.curl).toBeUndefined(); - }); - }); - - describe('expandHermesSourceTarball', () => { - it('should expand Hermes source tarball to Hermes source dir', () => { - fs.mkdirSync(path.join(SDKS_DIR, 'download'), {recursive: true}); - fs.writeFileSync( - path.join(SDKS_DIR, 'download', `hermes-${hermesTagSha}.tgz`), - tarballContents, - ); - expect(fs.existsSync(path.join(SDKS_DIR, 'hermes'))).toBeFalsy(); - expandHermesSourceTarball(); - expect(fs.existsSync(path.join(SDKS_DIR, 'hermes'))).toBe(true); - }); - it('should fail if Hermes source tarball does not exist', () => { - expect(() => { - expandHermesSourceTarball(); - }).toThrow('[Hermes] Could not locate Hermes tarball.'); - }); - }); - }); - - describe('Configuring Hermes Build', () => { - describe('copyBuildScripts', () => { - it('should copy React Native Hermes build scripts to Hermes source directory', () => { - copyBuildScripts(); + ).toEqual(hermesTag); - [ - 'build-apple-framework.sh', - 'build-ios-framework.sh', - 'build-mac-framework.sh', - ].forEach(buildScript => { - expect( - fs.readFileSync( - path.join(ROOT_DIR, 'sdks/hermes/utils', buildScript), - { - encoding: 'utf8', - flag: 'r', - }, - ), - ).toEqual( - fs.readFileSync( - path.join(ROOT_DIR, 'sdks/hermes-engine/utils', buildScript), - { - encoding: 'utf8', - flag: 'r', - }, - ), - ); - }); - }); - }); - describe('copyPodSpec', () => { - it('should copy React Native Hermes Podspec to Hermes source directory', () => { - copyPodSpec(); - expect( - fs.readFileSync(path.join(SDKS_DIR, 'hermes/hermes-engine.podspec'), { - encoding: 'utf8', - flag: 'r', - }), - ).toEqual( - fs.readFileSync( - path.join(SDKS_DIR, 'hermes-engine/hermes-engine.podspec'), - { - encoding: 'utf8', - flag: 'r', - }, - ), - ); - }); - it('should copy hermes-utils.rb to Hermes source directory', () => { - copyPodSpec(); expect( - fs.readFileSync(path.join(SDKS_DIR, 'hermes/hermes-utils.rb'), { + fs.readFileSync(path.join(SDKS_DIR, '.hermesv1version'), { encoding: 'utf8', flag: 'r', }), - ).toEqual( - fs.readFileSync( - path.join(SDKS_DIR, 'hermes-engine/hermes-utils.rb'), - { - encoding: 'utf8', - flag: 'r', - }, - ), - ); - }); - }); - describe('shouldUsePrebuiltHermesC', () => { - it('returns false if path to osx hermesc does not exist', () => { - expect(shouldUsePrebuiltHermesC('macos')).toBeFalsy(); - }); - it('returns false for non-macOS', () => { - expect(shouldUsePrebuiltHermesC('windows')).toBeFalsy(); - }); - it('return true only if path to hermesc exists', () => { - fs.mkdirSync(path.join(SDKS_DIR, 'hermesc/osx-bin'), { - recursive: true, - }); - fs.writeFileSync( - path.join(SDKS_DIR, 'hermesc/osx-bin/hermesc'), - hermescContents, - ); - expect(shouldUsePrebuiltHermesC('macos')).toBe(true); - }); - }); - - describe('configureMakeForPrebuiltHermesC', () => { - it('creates ImportHermesC file', () => { - fs.mkdirSync(path.join(SDKS_DIR, 'hermesc/osx-bin'), { - recursive: true, - }); - configureMakeForPrebuiltHermesC(); - expect( - fs.existsSync( - path.join(SDKS_DIR, 'hermesc/osx-bin/ImportHostCompilers.cmake'), - ), - ).toBe(true); - }); - }); - }); - - describe('Packaging Hermes', () => { - beforeEach(() => { - populateMockFilesystemWithHermesBuildArtifacts(); - }); - - describe('createTarballFromDirectory', () => { - it('should create the tarball', () => { - fs.mkdirSync(path.join(SDKS_DIR, 'downloads'), {recursive: true}); - const tarballFilename = path.join( - SDKS_DIR, - 'downloads/hermes-runtime-darwin.tar.gz', - ); - createTarballFromDirectory( - path.join(SDKS_DIR, 'hermes/destroot'), - tarballFilename, - ); - expect(spawnCalls.tar).toBe(true); - expect(fs.existsSync(tarballFilename)).toBe(true); - }); - }); - - describe('getHermesPrebuiltArtifactsTarballName', () => { - it('should return Hermes prebuilts tarball name', () => { - expect(getHermesPrebuiltArtifactsTarballName('Debug')).toEqual( - 'hermes-ios-debug.tar.gz', - ); + ).toEqual(hermesV1Tag); }); - it('should throw if build type is undefined', () => { - expect(() => { - getHermesPrebuiltArtifactsTarballName(); - }).toThrow('Did not specify build type.'); - }); - }); - - describe('createHermesPrebuiltArtifactsTarball', () => { - it('creates tarball', () => { - const tarballOutputDir = fs.mkdtempSync( - path.join(os.tmpdir(), 'hermes-prebuilts-'), - ); - fs.mkdirSync(tarballOutputDir, { - recursive: true, - }); - - const excludeDebugSymbols = false; - const tarballOutputPath = createHermesPrebuiltArtifactsTarball( - path.join(SDKS_DIR, 'hermes'), - 'Debug', - tarballOutputDir, - excludeDebugSymbols, - ); - expect(fs.existsSync(tarballOutputPath)).toBe(true); - expect(spawnCalls.rsync).toBe(true); - // rsync -a src dest - expect(spawnCalls.rsyncArgs.length).toEqual(3); - }); - - it('creates tarball with debug symbols excluded', () => { - const tarballOutputDir = fs.mkdtempSync( - path.join(os.tmpdir(), 'hermes-prebuilts-'), - ); - fs.mkdirSync(tarballOutputDir, { - recursive: true, - }); - - const excludeDebugSymbols = true; - const tarballOutputPath = createHermesPrebuiltArtifactsTarball( - path.join(SDKS_DIR, 'hermes'), - 'Debug', - tarballOutputDir, - excludeDebugSymbols, - ); - expect(fs.existsSync(tarballOutputPath)).toBe(true); - expect(spawnCalls.rsync).toBe(true); - - // When the debug symbols are excluded, we pass an additional two parameters to rsync: - // rsync -a --exclude=dSYMs/ --exclude=*.dSYM/ src dest - expect(spawnCalls.rsyncArgs.length).toEqual(5); - expect(spawnCalls.rsyncArgs[1]).toEqual('--exclude=dSYMs/'); - expect(spawnCalls.rsyncArgs[2]).toEqual('--exclude=*.dSYM/'); + it('should set Hermes tag and read it back', async () => { + await setHermesTag(hermesTag, hermesV1Tag); + expect(readHermesTag()).toEqual(hermesTag); + expect(readHermesV1Tag()).toEqual(hermesV1Tag); }); }); }); diff --git a/packages/react-native/scripts/hermes/bump-hermes-version.js b/packages/react-native/scripts/hermes/bump-hermes-version.js index 3ac8c9711b63..a27aabed40d1 100755 --- a/packages/react-native/scripts/hermes/bump-hermes-version.js +++ b/packages/react-native/scripts/hermes/bump-hermes-version.js @@ -11,6 +11,13 @@ 'use strict'; +const { + updateHermesCompilerVersionInDependencies, + updateHermesRuntimeDependenciesVersions, +} = require('../../../../scripts/releases/utils/hermes-utils'); +const { + getPackageVersionStrByTag, +} = require('../../../../scripts/releases/utils/npm-utils'); const {setHermesTag} = require('./hermes-utils'); // $FlowFixMe[untyped-import] const inquirer = require('inquirer'); @@ -21,28 +28,88 @@ const inquirer = require('inquirer'); const {exit} = require('shelljs'); const yargs = require('yargs'); -let argv = yargs.option('t', { - alias: 'tag', - describe: - 'Hermes release tag to use for this React Native release, ex. hermes-2022-02-21-RNv0.68.0', - required: true, -}).argv; +let argv = yargs + .option('t', { + alias: 'tag', + describe: + 'Hermes release tag to use for this React Native release, ex. hermes-2022-02-21-RNv0.68.0. This tag will be used when building Hermes from source.', + required: true, + }) + .option('s', { + alias: 'v1-tag', + describe: + 'Hermes V1 release tag to use for this React Native release, ex. 250829098.0.0. This tag will be used when building Hermes V1 from source.', + required: true, + }) + .option('h', { + alias: 'hermes-version', + describe: + 'Hermes version to use for this React Native release, ex. 250829098.0.0. This version will be used when consuming Hermes from a prebuilt package.', + required: false, + }) + .option('v', { + alias: 'hermes-v1-version', + describe: + 'Hermes V1 version to use for this React Native release, ex. 250829098.0.0. This version will be used when consuming Hermes V1 from a prebuilt package.', + required: false, + }).argv; async function main() { // $FlowFixMe[prop-missing] const hermesTag = argv.tag; - const {confirmHermesTag} = await inquirer.prompt({ + // $FlowFixMe[prop-missing] + const hermesV1Tag = argv['v1-tag']; + // $FlowFixMe[prop-missing] + let hermesVersion = argv['hermes-version']; + // $FlowFixMe[prop-missing] + let hermesV1Version = argv['hermes-v1-version']; + + if (!hermesVersion) { + console.log( + 'No Hermes version provided. Fetching the latest version from NPM...', + ); + hermesVersion = await getPackageVersionStrByTag( + 'hermes-compiler', + 'latest-v0', + ); + } + + if (!hermesV1Version) { + console.log( + 'No Hermes V1 version provided. Fetching the latest version from NPM...', + ); + hermesV1Version = await getPackageVersionStrByTag( + 'hermes-compiler', + 'latest-v1', + ); + } + + const {confirmHermesVersions} = await inquirer.prompt({ type: 'confirm', - name: 'confirmHermesTag', - message: `Do you want to use the Hermes release tagged "${hermesTag}"?`, + name: 'confirmHermesVersions', + message: `Do you want to use the Hermes version "${hermesVersion}" and Hermes V1 version "${hermesV1Version}" (for prebuilt)?`, }); - if (!confirmHermesTag) { + if (!confirmHermesVersions) { console.log('Aborting.'); return; } - setHermesTag(hermesTag); + const {confirmHermesTags} = await inquirer.prompt({ + type: 'confirm', + name: 'confirmHermesTags', + message: `Do you want to use the Hermes release tagged "${hermesTag}" and Hermes V1 release tagged "${hermesV1Tag}" (for building from source)?`, + }); + + if (!confirmHermesTags) { + console.log('Aborting.'); + return; + } + + await setHermesTag(hermesTag, hermesV1Tag); + + await updateHermesCompilerVersionInDependencies(hermesVersion); + await updateHermesRuntimeDependenciesVersions(hermesVersion, hermesV1Version); } void main().then(() => { diff --git a/packages/react-native/scripts/hermes/create-tarball.js b/packages/react-native/scripts/hermes/create-tarball.js deleted file mode 100644 index 7214d5639c4b..000000000000 --- a/packages/react-native/scripts/hermes/create-tarball.js +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow strict-local - * @format - */ - -'use strict'; - -const {createHermesPrebuiltArtifactsTarball} = require('./hermes-utils'); -const fs = require('fs'); -const os = require('os'); -const path = require('path'); -/** - * This script creates a Hermes prebuilt artifacts tarball. - * Must be invoked after Hermes has been built. - */ -const yargs = require('yargs'); - -let argv = yargs - .option('i', { - alias: 'inputDir', - describe: 'Path to directory where Hermes build artifacts were generated.', - }) - .option('b', { - alias: 'buildType', - type: 'string', - describe: 'Specifies whether Hermes was built for Debug or Release.', - default: 'Debug', - }) - .option('o', { - alias: 'outputDir', - describe: 'Location where the tarball will be saved to.', - }) - .option('exclude-debug-symbols', { - describe: 'Whether dSYMs should be excluded from the tarball.', - type: 'boolean', - default: true, - }).argv; - -async function main() { - // $FlowFixMe[prop-missing] - const hermesDir = argv.inputDir; - // $FlowFixMe[prop-missing] - const buildType = argv.buildType; - // $FlowFixMe[prop-missing] - const excludeDebugSymbols = argv.excludeDebugSymbols; - // $FlowFixMe[prop-missing] - let tarballOutputDir = argv.outputDir; - - if (!tarballOutputDir) { - try { - tarballOutputDir = fs.mkdtempSync( - path.join(os.tmpdir(), 'hermes-engine-tarball-'), - ); - } catch (error) { - throw new Error( - `[Hermes] Failed to create temporary output directory: ${error}`, - ); - } - } - - const tarballOutputPath = createHermesPrebuiltArtifactsTarball( - hermesDir, - buildType, - tarballOutputDir, - excludeDebugSymbols, - ); - console.log(tarballOutputPath); - return tarballOutputPath; -} - -void main().then(() => { - process.exit(0); -}); diff --git a/packages/react-native/scripts/hermes/get-tarball-name.js b/packages/react-native/scripts/hermes/get-tarball-name.js deleted file mode 100644 index ace7543b5dd6..000000000000 --- a/packages/react-native/scripts/hermes/get-tarball-name.js +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow strict-local - * @format - */ - -'use strict'; - -const {getHermesPrebuiltArtifactsTarballName} = require('./hermes-utils'); -/** - * This script returns the filename that would be used for a - * Hermes tarball for the given build type and release version. - */ -const yargs = require('yargs'); - -let argv = yargs.option('b', { - alias: 'buildType', - type: 'string', - describe: 'Specifies whether Hermes was built for Debug or Release.', - default: 'Debug', -}).argv; - -async function main() { - // $FlowFixMe[prop-missing] - const tarballName = getHermesPrebuiltArtifactsTarballName(argv.buildType); - console.log(tarballName); - return tarballName; -} - -void main().then(() => { - process.exit(0); -}); diff --git a/packages/react-native/scripts/hermes/hermes-utils.js b/packages/react-native/scripts/hermes/hermes-utils.js index 991a525b52d8..16ee6810b8d5 100644 --- a/packages/react-native/scripts/hermes/hermes-utils.js +++ b/packages/react-native/scripts/hermes/hermes-utils.js @@ -10,9 +10,9 @@ 'use strict'; -const {execSync, spawnSync} = require('child_process'); const fs = require('fs'); -const os = require('os'); +// $FlowFixMe[untyped-import] +const inquirer = require('inquirer'); const path = require('path'); /*:: @@ -20,32 +20,8 @@ type BuildType = 'dry-run' | 'release' | 'nightly'; */ const SDKS_DIR = path.normalize(path.join(__dirname, '..', '..', 'sdks')); -const HERMES_DIR = path.join(SDKS_DIR, 'hermes'); const HERMES_TAG_FILE_PATH = path.join(SDKS_DIR, '.hermesversion'); -const HERMES_SOURCE_TARBALL_BASE_URL = - 'https://github.com/facebook/hermes/tarball/'; -const HERMES_TARBALL_DOWNLOAD_DIR = path.join(SDKS_DIR, 'download'); -const MACOS_BIN_DIR = path.join(SDKS_DIR, 'hermesc', 'osx-bin'); -const MACOS_HERMESC_PATH = path.join(MACOS_BIN_DIR, 'hermesc'); -const MACOS_IMPORT_HOST_COMPILERS_PATH = path.join( - MACOS_BIN_DIR, - 'ImportHostCompilers.cmake', -); - -/** - * Delegate execution to the supplied command. - * - * @param command Path to the command. - * @param args Array of arguments pass to the command. - * @param options child process options. - */ -function delegateSync( - command /*: string */, - args /*: (Array | child_process$spawnSyncOpts) */, - options /*: ?child_process$spawnSyncOpts */, -) { - return spawnSync(command, args, {stdio: 'inherit', ...options}); -} +const HERMES_V1_TAG_FILE_PATH = path.join(SDKS_DIR, '.hermesv1version'); function readHermesTag() /*: string */ { if (fs.existsSync(HERMES_TAG_FILE_PATH)) { @@ -63,281 +39,73 @@ function readHermesTag() /*: string */ { } } - return 'main'; -} - -function setHermesTag(hermesTag /*: string */) { - if (readHermesTag() === hermesTag) { - // No need to update. - return; - } - - if (!fs.existsSync(SDKS_DIR)) { - fs.mkdirSync(SDKS_DIR, {recursive: true}); - } - fs.writeFileSync(HERMES_TAG_FILE_PATH, hermesTag.trim()); - console.log('Hermes tag has been updated. Please commit your changes.'); -} - -function getHermesTagSHA(hermesTag /*: string */) /*: string */ { - return execSync( - `git ls-remote https://github.com/facebook/hermes ${hermesTag} | cut -f 1`, - ) - .toString() - .trim(); -} - -function getHermesTarballDownloadPath(hermesTag /*: string */) /*: string */ { - const hermesTagSHA = getHermesTagSHA(hermesTag); - return path.join(HERMES_TARBALL_DOWNLOAD_DIR, `hermes-${hermesTagSHA}.tgz`); -} - -function downloadHermesSourceTarball() { - const hermesTag = readHermesTag(); - const hermesTagSHA = getHermesTagSHA(hermesTag); - const hermesTarballDownloadPath = getHermesTarballDownloadPath(hermesTag); - let hermesTarballUrl = HERMES_SOURCE_TARBALL_BASE_URL + hermesTag; - - if (fs.existsSync(hermesTarballDownloadPath)) { - return; - } - - if (!fs.existsSync(HERMES_TARBALL_DOWNLOAD_DIR)) { - fs.mkdirSync(HERMES_TARBALL_DOWNLOAD_DIR, {recursive: true}); - } - - console.info( - `[Hermes] Downloading Hermes source code for commit ${hermesTagSHA}`, - ); - try { - delegateSync('curl', [hermesTarballUrl, '-Lo', hermesTarballDownloadPath]); - } catch (error) { - throw new Error(`[Hermes] Failed to download Hermes tarball. ${error}`); - } -} - -function expandHermesSourceTarball() { - const hermesTag = readHermesTag(); - const hermesTagSHA = getHermesTagSHA(hermesTag); - const hermesTarballDownloadPath = getHermesTarballDownloadPath(hermesTag); - - if (!fs.existsSync(hermesTarballDownloadPath)) { - throw new Error('[Hermes] Could not locate Hermes tarball.'); - } - - if (!fs.existsSync(HERMES_DIR)) { - fs.mkdirSync(HERMES_DIR, {recursive: true}); - } - console.info(`[Hermes] Expanding Hermes tarball for commit ${hermesTagSHA}`); - try { - delegateSync('tar', [ - '-zxf', - hermesTarballDownloadPath, - '--strip-components=1', - '--directory', - HERMES_DIR, - ]); - } catch (error) { - throw new Error('[Hermes] Failed to expand Hermes tarball.'); - } -} - -function copyBuildScripts() { - if (!fs.existsSync(SDKS_DIR)) { - throw new Error( - '[Hermes] Failed to copy Hermes build scripts, no SDKs directory found.', - ); - } - - if (!fs.existsSync(HERMES_DIR)) { - fs.mkdirSync(path.join(HERMES_DIR, 'utils'), {recursive: true}); - } - - fs.copyFileSync( - path.join(SDKS_DIR, 'hermes-engine', 'utils', 'build-apple-framework.sh'), - path.join(HERMES_DIR, 'utils', 'build-apple-framework.sh'), - ); - fs.copyFileSync( - path.join(SDKS_DIR, 'hermes-engine', 'utils', 'build-ios-framework.sh'), - path.join(HERMES_DIR, 'utils', 'build-ios-framework.sh'), - ); - fs.copyFileSync( - path.join(SDKS_DIR, 'hermes-engine', 'utils', 'build-mac-framework.sh'), - path.join(HERMES_DIR, 'utils', 'build-mac-framework.sh'), - ); -} - -function copyPodSpec() { - if (!fs.existsSync(SDKS_DIR)) { - throw new Error( - '[Hermes] Failed to copy Hermes Podspec, no SDKs directory found.', - ); - } - - if (!fs.existsSync(HERMES_DIR)) { - fs.mkdirSync(HERMES_DIR, {recursive: true}); - } - const podspec = 'hermes-engine.podspec'; - fs.copyFileSync( - path.join(SDKS_DIR, 'hermes-engine', podspec), - path.join(HERMES_DIR, podspec), - ); - const utils = 'hermes-utils.rb'; - fs.copyFileSync( - path.join(SDKS_DIR, 'hermes-engine', utils), - path.join(HERMES_DIR, utils), - ); -} - -function isTestingAgainstLocalHermesTarball() { - return 'HERMES_ENGINE_TARBALL_PATH' in process.env; -} - -function shouldBuildHermesFromSource(isInCI /*: boolean */) /*: boolean */ { - return !isTestingAgainstLocalHermesTarball() && isInCI; + throw new Error('[Hermes] .hermesversion does not exist.'); } -function shouldUsePrebuiltHermesC( - platform /*: 'macos' | 'windows' */, -) /*: boolean */ { - if (platform === 'macos') { - return fs.existsSync(MACOS_HERMESC_PATH); - } - - return false; -} - -function configureMakeForPrebuiltHermesC() { - const IMPORT_HOST_COMPILERS_TEMPLATE = `add_executable(native-hermesc IMPORTED) -set_target_properties(native-hermesc PROPERTIES - IMPORTED_LOCATION "${MACOS_HERMESC_PATH}" - )`; +function readHermesV1Tag() /*: string */ { + if (fs.existsSync(HERMES_V1_TAG_FILE_PATH)) { + const data = fs + .readFileSync(HERMES_V1_TAG_FILE_PATH, { + encoding: 'utf8', + flag: 'r', + }) + .trim(); - try { - fs.mkdirSync(MACOS_BIN_DIR, {recursive: true}); - fs.writeFileSync( - MACOS_IMPORT_HOST_COMPILERS_PATH, - IMPORT_HOST_COMPILERS_TEMPLATE, - ); - } catch (error) { - console.warn( - `[Hermes] Re-compiling hermesc. Unable to configure make: ${error}`, - ); + if (data.length > 0) { + return data; + } else { + throw new Error('[Hermes] .hermesv1version file is empty.'); + } } -} -function getHermesPrebuiltArtifactsTarballName( - buildType /*:: ?: string */, -) /*: string */ { - if (buildType == null) { - throw Error('Did not specify build type.'); - } - return `hermes-ios-${buildType.toLowerCase()}.tar.gz`; + throw new Error('[Hermes] .hermesv1version does not exist.'); } -/** - * Creates a tarball with the contents of the supplied directory. - */ -function createTarballFromDirectory( - directory /*: string */, - filename /*: string */, +async function updateHermesTag( + tagFile /*: string */, + hermesTag /*: string */, + prompt /*: string */, ) { - const args = ['-C', directory, '-czvf', filename, '.']; - delegateSync('tar', args); -} - -function createHermesPrebuiltArtifactsTarball( - hermesDir /*: string */, - buildType /*: string */, - tarballOutputDir /*: string */, - excludeDebugSymbols /*: boolean */, -) /*: string */ { - validateHermesFrameworksExist(path.join(hermesDir, 'destroot')); - - if (!fs.existsSync(tarballOutputDir)) { - fs.mkdirSync(tarballOutputDir, {recursive: true}); - } - - let tarballTempDir; - try { - tarballTempDir = fs.mkdtempSync( - path.join(os.tmpdir(), 'hermes-engine-destroot-'), - ); - - let args = ['-a']; - if (excludeDebugSymbols) { - args.push('--exclude=dSYMs/'); - args.push('--exclude=*.dSYM/'); - } - args.push('./destroot'); - args.push(tarballTempDir); - delegateSync('rsync', args, { - cwd: hermesDir, + if (!fs.existsSync(tagFile)) { + fs.writeFileSync(tagFile, hermesTag.trim()); + } else { + const previousHermesTag = fs.readFileSync(tagFile, { + encoding: 'utf8', + flag: 'r', }); - if (fs.existsSync(path.join(hermesDir, 'LICENSE'))) { - delegateSync('cp', ['LICENSE', tarballTempDir], {cwd: hermesDir}); - } - } catch (error) { - throw new Error(`Failed to copy destroot to tempdir: ${error}`); - } - - const tarballFilename = path.join( - tarballOutputDir, - getHermesPrebuiltArtifactsTarballName(buildType), - ); - try { - createTarballFromDirectory(tarballTempDir, tarballFilename); - } catch (error) { - throw new Error(`[Hermes] Failed to create tarball: ${error}`); - } - - if (!fs.existsSync(tarballFilename)) { - throw new Error( - `Tarball creation failed, could not locate tarball at ${tarballFilename}`, - ); + if (previousHermesTag.trim() !== hermesTag.trim()) { + const {confirmHermesTag} = await inquirer.prompt({ + type: 'confirm', + name: 'confirmHermesTag', + message: `Do you want to use updtate release tag for ${prompt} from "${previousHermesTag}" to "${hermesTag}"?`, + }); + + if (confirmHermesTag) { + fs.writeFileSync(tagFile, hermesTag.trim()); + } else { + console.log(`[${prompt}] .hermesversion file is unchanged.`); + } + } else { + console.log(`[${prompt}] .hermesversion file is unchanged.`); + } } - - return tarballFilename; } -function validateHermesFrameworksExist(destrootDir /*: string */) { - if ( - !fs.existsSync( - path.join(destrootDir, 'Library/Frameworks/macosx/hermesvm.framework'), - ) - ) { - throw new Error( - 'Error: Hermes macOS Framework not found. Are you sure Hermes has been built?', - ); - } - if ( - !fs.existsSync( - path.join( - destrootDir, - 'Library/Frameworks/universal/hermesvm.xcframework', - ), - ) - ) { - throw new Error( - 'Error: Hermes iOS XCFramework not found. Are you sure Hermes has been built?', - ); +async function setHermesTag( + hermesTag /*: string */, + hermesV1Tag /*: string */, +) { + if (!fs.existsSync(SDKS_DIR)) { + fs.mkdirSync(SDKS_DIR, {recursive: true}); } + + await updateHermesTag(HERMES_TAG_FILE_PATH, hermesTag, 'Hermes'); + await updateHermesTag(HERMES_V1_TAG_FILE_PATH, hermesV1Tag, 'Hermes V1'); } module.exports = { - configureMakeForPrebuiltHermesC, - copyBuildScripts, - copyPodSpec, - createHermesPrebuiltArtifactsTarball, - createTarballFromDirectory, - downloadHermesSourceTarball, - expandHermesSourceTarball, - getHermesTagSHA, - getHermesTarballDownloadPath, - getHermesPrebuiltArtifactsTarballName, readHermesTag, + readHermesV1Tag, setHermesTag, - shouldBuildHermesFromSource, - shouldUsePrebuiltHermesC, }; diff --git a/packages/react-native/scripts/hermes/prepare-hermes-for-build.js b/packages/react-native/scripts/hermes/prepare-hermes-for-build.js deleted file mode 100644 index fb9c95361f46..000000000000 --- a/packages/react-native/scripts/hermes/prepare-hermes-for-build.js +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow strict-local - * @format - */ - -'use strict'; - -/** - * This script prepares Hermes to be built as part of the - * iOS build pipeline on macOS. - */ -const { - configureMakeForPrebuiltHermesC, - copyBuildScripts, - copyPodSpec, - downloadHermesSourceTarball, - expandHermesSourceTarball, - shouldBuildHermesFromSource, - shouldUsePrebuiltHermesC, -} = require('./hermes-utils'); - -async function main(isInCI /*: boolean */) { - if (!shouldBuildHermesFromSource(isInCI)) { - copyPodSpec(); - return; - } - downloadHermesSourceTarball(); - expandHermesSourceTarball(); - copyPodSpec(); - copyBuildScripts(); - - if (shouldUsePrebuiltHermesC('macos')) { - console.log('[Hermes] Using pre-built HermesC'); - configureMakeForPrebuiltHermesC(); - } -} - -const isInCI = process.env.CI === 'true'; - -void main(isInCI).then(() => { - process.exit(0); -}); diff --git a/packages/react-native/scripts/ios-prebuild/hermes.js b/packages/react-native/scripts/ios-prebuild/hermes.js index 1adab0fc4a1e..72c0c4c2073a 100644 --- a/packages/react-native/scripts/ios-prebuild/hermes.js +++ b/packages/react-native/scripts/ios-prebuild/hermes.js @@ -29,7 +29,7 @@ import type {BuildFlavor, Destination, Platform} from './types'; * environment variable. If this varuable is set, the script will use the local tarball instead of downloading it. */ async function prepareHermesArtifactsAsync( - version /*:string*/, + reactNativeVersion /*:string*/, buildType /*: BuildFlavor */, ) /*: Promise */ { hermesLog(`Preparing Hermes...`); @@ -54,7 +54,7 @@ async function prepareHermesArtifactsAsync( // Only check if the artifacts folder exists if we are not using a local tarball if (!localPath) { // Resolve the version from the environment variable or use the default version - let resolvedVersion = process.env.HERMES_VERSION ?? version; + let resolvedVersion = process.env.HERMES_VERSION ?? 'nightly'; if (resolvedVersion === 'nightly') { hermesLog('Using latest nightly tarball'); @@ -104,7 +104,7 @@ async function prepareHermesArtifactsAsync( async function getNightlyVersionFromNPM() /*: Promise */ { const npmResponse /*: Response */ = await fetch( - 'https://registry.npmjs.org/react-native/nightly', + 'https://registry.npmjs.org/hermes-compiler/nightly', ); if (!npmResponse.ok) { @@ -191,15 +191,15 @@ function getTarballUrl( // The mirror's structure must be the same of the Maven repo the react-native core team publishes on Maven Central. const mavenRepoUrl = process.env.ENTERPRISE_REPOSITORY ?? 'https://repo1.maven.org/maven2'; - const namespace = 'com/facebook/react'; - return `${mavenRepoUrl}/${namespace}/react-native-artifacts/${version}/react-native-artifacts-${version}-hermes-ios-${buildType.toLowerCase()}.tar.gz`; + const namespace = 'com/facebook/hermes'; + return `${mavenRepoUrl}/${namespace}/hermes-ios/${version}/hermes-ios-${version}-hermes-ios-${buildType.toLowerCase()}.tar.gz`; } async function getNightlyTarballUrl( version /*: string */, buildType /*: BuildFlavor */, ) /*: Promise */ { - const artifactCoordinate = 'react-native-artifacts'; + const artifactCoordinate = 'hermes-ios'; const artifactName = `hermes-ios-${buildType.toLowerCase()}.tar.gz`; return await computeNightlyTarballURL( version, diff --git a/packages/react-native/scripts/ios-prebuild/utils.js b/packages/react-native/scripts/ios-prebuild/utils.js index d9dec121dd55..6e8c2c77644e 100644 --- a/packages/react-native/scripts/ios-prebuild/utils.js +++ b/packages/react-native/scripts/ios-prebuild/utils.js @@ -65,7 +65,7 @@ async function computeNightlyTarballURL( artifactCoordinate /*: string */, artifactName /*: string */, ) /*: Promise */ { - const xmlUrl = `https://central.sonatype.com/repository/maven-snapshots/com/facebook/react/${artifactCoordinate}/${version}-SNAPSHOT/maven-metadata.xml`; + const xmlUrl = `https://central.sonatype.com/repository/maven-snapshots/com/facebook/hermes/${artifactCoordinate}/${version}-SNAPSHOT/maven-metadata.xml`; const response = await fetch(xmlUrl); if (!response.ok) { @@ -97,7 +97,7 @@ async function computeNightlyTarballURL( const buildNumber = buildNumberMatch[1]; const fullVersion = `${version}-${timestamp}-${buildNumber}`; - const finalUrl = `https://central.sonatype.com/repository/maven-snapshots/com/facebook/react/${artifactCoordinate}/${version}-SNAPSHOT/${artifactCoordinate}-${fullVersion}-${artifactName}`; + const finalUrl = `https://central.sonatype.com/repository/maven-snapshots/com/facebook/hermes/${artifactCoordinate}/${version}-SNAPSHOT/${artifactCoordinate}-${fullVersion}-${artifactName}`; return finalUrl; } diff --git a/packages/react-native/sdks/hermes-engine/hermes-engine.podspec b/packages/react-native/sdks/hermes-engine/hermes-engine.podspec index 4ea59808e3db..9482518ba593 100644 --- a/packages/react-native/sdks/hermes-engine/hermes-engine.podspec +++ b/packages/react-native/sdks/hermes-engine/hermes-engine.podspec @@ -20,12 +20,12 @@ end # package.json package = JSON.parse(File.read(File.join(react_native_path, "package.json"))) -# TODO: T231755000 read hermes version from version.properties when consuming hermes -version = package['version'] +versionProperties = Hash[*File.read("version.properties").split(/[=\n]+/)] if ENV['RCT_HERMES_V1_ENABLED'] == "1" - versionProperties = Hash[*File.read("version.properties").split(/[=\n]+/)] version = versionProperties['HERMES_V1_VERSION_NAME'] +else + version = versionProperties['HERMES_VERSION_NAME'] end source_type = hermes_source_type(version, react_native_path) @@ -70,8 +70,7 @@ Pod::Spec.new do |spec| # When using the local prebuilt tarball, it should include hermesc compatible with the used VM. # In other cases, when using Hermes V1, the prebuilt versioned binaries can be used. - # TODO: T236142916 hermesc should be consumed from NPM even when not using Hermes V1 - if source_type != HermesEngineSourceType::LOCAL_PREBUILT_TARBALL && ENV['RCT_HERMES_V1_ENABLED'] == "1" + if source_type != HermesEngineSourceType::LOCAL_PREBUILT_TARBALL hermes_compiler_path = File.dirname(Pod::Executable.execute_command('node', ['-p', 'require.resolve( "hermes-compiler", diff --git a/packages/react-native/sdks/hermes-engine/hermes-utils.rb b/packages/react-native/sdks/hermes-engine/hermes-utils.rb index 828370929978..f264ec1f3801 100644 --- a/packages/react-native/sdks/hermes-engine/hermes-utils.rb +++ b/packages/react-native/sdks/hermes-engine/hermes-utils.rb @@ -225,17 +225,10 @@ def release_tarball_url(version, build_type) ENV['ENTERPRISE_REPOSITORY'] : "https://repo1.maven.org/maven2" - if hermes_v1_enabled() - namespace = "com/facebook/hermes" - # Sample url from Maven: - # https://repo1.maven.org/maven2/com/facebook/hermes/hermes-ios/0.14.0/hermes-ios-0.14.0-hermes-ios-debug.tar.gz - return "#{maven_repo_url}/#{namespace}/hermes-ios/#{version}/hermes-ios-#{version}-hermes-ios-#{build_type.to_s}.tar.gz" - else - namespace = "com/facebook/react" - # Sample url from Maven: - # https://repo1.maven.org/maven2/com/facebook/react/react-native-artifacts/0.71.0/react-native-artifacts-0.71.0-hermes-ios-debug.tar.gz - return "#{maven_repo_url}/#{namespace}/react-native-artifacts/#{version}/react-native-artifacts-#{version}-hermes-ios-#{build_type.to_s}.tar.gz" - end + namespace = "com/facebook/hermes" + # Sample url from Maven: + # https://repo1.maven.org/maven2/com/facebook/hermes/hermes-ios/0.14.0/hermes-ios-0.14.0-hermes-ios-debug.tar.gz + return "#{maven_repo_url}/#{namespace}/hermes-ios/#{version}/hermes-ios-#{version}-hermes-ios-#{build_type.to_s}.tar.gz" end def download_stable_hermes(react_native_path, version, configuration) @@ -257,16 +250,9 @@ def download_hermes_tarball(react_native_path, tarball_url, version, configurati end def nightly_tarball_url(version) - # TODO: T231755027 update coordinates and versioning - artifact_coordinate = "react-native-artifacts" + artifact_coordinate = "hermes-ios" artifact_name = "hermes-ios-debug.tar.gz" - namespace = "com/facebook/react" - - if hermes_v1_enabled() - artifact_coordinate = "hermes-ios" - artifact_name = "hermes-ios-debug.tar.gz" - namespace = "com/facebook/hermes" - end + namespace = "com/facebook/hermes" xml_url = "https://central.sonatype.com/repository/maven-snapshots/#{namespace}/#{artifact_coordinate}/#{version}-SNAPSHOT/maven-metadata.xml" diff --git a/packages/react-native/sdks/hermes-engine/version.properties b/packages/react-native/sdks/hermes-engine/version.properties index 0f5449c49f60..81629a9921cc 100644 --- a/packages/react-native/sdks/hermes-engine/version.properties +++ b/packages/react-native/sdks/hermes-engine/version.properties @@ -1 +1,2 @@ +HERMES_VERSION_NAME=1000.0.0 HERMES_V1_VERSION_NAME=250829098.0.1 diff --git a/private/helloworld/android/app/build.gradle b/private/helloworld/android/app/build.gradle index b7518d235d4b..2b7bf819e0b1 100644 --- a/private/helloworld/android/app/build.gradle +++ b/private/helloworld/android/app/build.gradle @@ -115,5 +115,5 @@ android { dependencies { // The version of react-native is set by the React Native Gradle Plugin implementation("com.facebook.react:react-android") - implementation("com.facebook.react:hermes-android") + implementation("com.facebook.hermes:hermes-android") } diff --git a/scripts/release-testing/test-release-local.js b/scripts/release-testing/test-release-local.js index fba9a0254ff6..b0cfebf19ba5 100644 --- a/scripts/release-testing/test-release-local.js +++ b/scripts/release-testing/test-release-local.js @@ -17,6 +17,8 @@ * and to make it more accessible for other devs to play around with. */ +import {getPackageVersionStrByTag} from '../releases/utils/npm-utils'; + const {initNewProjectFromSource} = require('../e2e/init-project-e2e'); const {REPO_ROOT} = require('../shared/consts'); const { @@ -248,7 +250,28 @@ async function testRNTestProject( ? path.join(ciArtifacts.baseTmpPath(), 'maven-local') : '/private/tmp/maven-local'; - const {hermesPath, newLocalNodeTGZ} = await prepareArtifacts( + const latestHermesCommitly = await getPackageVersionStrByTag( + 'hermes-compiler', + 'nightly', + ); + const latestHermesV1 = await getPackageVersionStrByTag( + 'hermes-compiler', + 'latest-v1', + ); + sed( + '-i', + 'HERMES_VERSION_NAME=.*', + `HERMES_VERSION_NAME=${latestHermesCommitly}`, + 'sdks/hermes-engine/version.properties', + ); + sed( + '-i', + 'HERMES_V1_VERSION_NAME=.*', + `HERMES_V1_VERSION_NAME=${latestHermesV1}`, + 'sdks/hermes-engine/version.properties', + ); + + const {newLocalNodeTGZ} = await prepareArtifacts( ciArtifacts, mavenLocalPath, localNodeTGZPath, @@ -313,9 +336,7 @@ async function testRNTestProject( // doing the pod install here so that it's easier to play around RNTestProject cd('ios'); exec('bundle install'); - exec( - `HERMES_ENGINE_TARBALL_PATH=${hermesPath} USE_HERMES=1 bundle exec pod install --ansi`, - ); + exec(`USE_HERMES=1 bundle exec pod install --ansi`); cd('..'); exec('npm run ios'); diff --git a/scripts/release-testing/utils/testing-utils.js b/scripts/release-testing/utils/testing-utils.js index 866478f3effb..629fe271a5c7 100644 --- a/scripts/release-testing/utils/testing-utils.js +++ b/scripts/release-testing/utils/testing-utils.js @@ -10,13 +10,8 @@ 'use strict'; -const { - downloadHermesSourceTarball, - expandHermesSourceTarball, -} = require('../../../packages/react-native/scripts/hermes/hermes-utils.js'); const { generateAndroidArtifacts, - generateiOSArtifacts, } = require('../../releases/utils/release-utils'); const ghaArtifactsUtils = require('./github-actions-utils.js'); const fs = require('fs'); @@ -24,7 +19,7 @@ const fs = require('fs'); const {spawn} = require('node:child_process'); const os = require('os'); const path = require('path'); -const {cp, exec} = require('shelljs'); +const {exec} = require('shelljs'); /*:: type BuildType = 'dry-run' | 'release' | 'nightly'; @@ -182,18 +177,12 @@ async function downloadArtifacts( localNodeTGZPath /*: string */, ) { const mavenLocalURL = await ciArtifacts.artifactURLForMavenLocal(); - const hermesURLZip = await ciArtifacts.artifactURLHermesDebug(); const reactNativeURLZip = await ciArtifacts.artifactURLForReactNative(); // Cleanup destination folder exec(`rm -rf ${ciArtifacts.baseTmpPath()}`); exec(`mkdir ${ciArtifacts.baseTmpPath()}`); - const hermesPathZip = path.join( - ciArtifacts.baseTmpPath(), - 'hermes-ios-debug.zip', - ); - const mavenLocalZipPath = `${mavenLocalPath}.zip`; console.info( `\n[Download] Maven Local Artifacts from ${mavenLocalURL} into ${mavenLocalZipPath}`, @@ -202,15 +191,6 @@ async function downloadArtifacts( console.info(`Unzipping into ${mavenLocalPath}`); exec(`unzip -oq ${mavenLocalZipPath} -d ${mavenLocalPath}`); - console.info('\n[Download] Hermes'); - ciArtifacts.downloadArtifact(hermesURLZip, hermesPathZip); - exec(`unzip ${hermesPathZip} -d ${ciArtifacts.baseTmpPath()}/hermes`); - const hermesPath = path.join( - ciArtifacts.baseTmpPath(), - 'hermes', - 'hermes-ios-debug.tar.gz', - ); - console.info(`\n[Download] React Native from ${reactNativeURLZip}`); const reactNativeDestPath = path.join( ciArtifacts.baseTmpPath(), @@ -239,7 +219,7 @@ async function downloadArtifacts( const reactNativeTGZ = path.join(reactNativeDestPath, tgzName); exec(`mv ${reactNativeTGZ} ${newLocalNodeTGZ}`); - return {hermesPath, newLocalNodeTGZ}; + return {newLocalNodeTGZ}; } function buildArtifactsLocally( @@ -261,48 +241,6 @@ function buildArtifactsLocally( // Generate native files for Android generateAndroidArtifacts(releaseVersion); - - // Generate iOS Artifacts - const jsiFolder = `${reactNativePackagePath}/ReactCommon/jsi`; - const hermesCoreSourceFolder = `${reactNativePackagePath}/sdks/hermes`; - - if (!fs.existsSync(hermesCoreSourceFolder)) { - console.info('The Hermes source folder is missing. Downloading...'); - downloadHermesSourceTarball(); - expandHermesSourceTarball(); - } - - // need to move the scripts inside the local hermes cloned folder - // cp sdks/hermes-engine/utils/*.sh /utils/. - cp( - `${reactNativePackagePath}/sdks/hermes-engine/hermes-engine.podspec`, - `${reactNativePackagePath}/sdks/hermes/hermes-engine.podspec`, - ); - cp( - `${reactNativePackagePath}/sdks/hermes-engine/hermes-utils.rb`, - `${reactNativePackagePath}/sdks/hermes/hermes-utils.rb`, - ); - cp( - `${reactNativePackagePath}/sdks/hermes-engine/utils/*.sh`, - `${reactNativePackagePath}/sdks/hermes/utils/.`, - ); - - // for this scenario, we only need to create the debug build - // (env variable PRODUCTION defines that podspec side) - const buildTypeiOSArtifacts = 'Debug'; - - // the android ones get set into /private/tmp/maven-local - const localMavenPath = '/private/tmp/maven-local'; - - // Generate native files for iOS - const hermesPath = generateiOSArtifacts( - jsiFolder, - hermesCoreSourceFolder, - buildTypeiOSArtifacts, - localMavenPath, - ); - - return hermesPath; } /** @@ -315,9 +253,6 @@ function buildArtifactsLocally( * - @releaseVersion the version that is about to be released. * - @buildType the type of build we want to execute if we build locally. * - @reactNativePackagePath the path to the react native package within the repo. - * - * Returns: - * - @hermesPath the path to hermes for iOS */ async function prepareArtifacts( ciArtifacts /*: ?typeof ghaArtifactsUtils */, @@ -326,17 +261,16 @@ async function prepareArtifacts( releaseVersion /*: string */, buildType /*: BuildType */, reactNativePackagePath /*: string */, -) /*: Promise<{hermesPath: string, newLocalNodeTGZ: string }> */ { - return ciArtifacts != null - ? await downloadArtifacts(ciArtifacts, mavenLocalPath, localNodeTGZPath) - : { - hermesPath: buildArtifactsLocally( - releaseVersion, - buildType, - reactNativePackagePath, - ), - newLocalNodeTGZ: localNodeTGZPath, - }; +) /*: Promise<{newLocalNodeTGZ: string }> */ { + if (ciArtifacts == null) { + buildArtifactsLocally(releaseVersion, buildType, reactNativePackagePath); + + return { + newLocalNodeTGZ: localNodeTGZPath, + }; + } + + return downloadArtifacts(ciArtifacts, mavenLocalPath, localNodeTGZPath); } module.exports = { diff --git a/scripts/releases-ci/__tests__/publish-npm-test.js b/scripts/releases-ci/__tests__/publish-npm-test.js index 28f711b17ab1..a494dc31a57e 100644 --- a/scripts/releases-ci/__tests__/publish-npm-test.js +++ b/scripts/releases-ci/__tests__/publish-npm-test.js @@ -20,6 +20,7 @@ const publishPackageMock = jest.fn(); const getNpmInfoMock = jest.fn(); const generateAndroidArtifactsMock = jest.fn(); const getPackagesMock = jest.fn(); +const updateHermesVersionsToNightlyMock = jest.fn(); const {REPO_ROOT} = require('../../shared/consts'); const {publishNpm} = require('../publish-npm'); @@ -53,6 +54,9 @@ describe('publish-npm', () => { ...jest.requireActual('../../releases/utils/npm-utils'), publishPackage: publishPackageMock, getNpmInfo: getNpmInfoMock, + })) + .mock('../../releases/utils/hermes-utils', () => ({ + updateHermesVersionsToNightly: updateHermesVersionsToNightlyMock, })); }); @@ -98,6 +102,7 @@ describe('publish-npm', () => { await publishNpm('dry-run'); + expect(updateHermesVersionsToNightlyMock).toHaveBeenCalled(); expect(setVersionMock).not.toBeCalled(); expect(updateReactNativeArtifactsMock).toBeCalledWith(version, 'dry-run'); @@ -155,6 +160,8 @@ describe('publish-npm', () => { // Generate Android artifacts is now delegate to build_android entirely expect(generateAndroidArtifactsMock).not.toHaveBeenCalled(); + expect(updateHermesVersionsToNightlyMock).toHaveBeenCalled(); + expect(publishPackageMock.mock.calls).toEqual([ [ 'path/to/monorepo/pkg-a', diff --git a/scripts/releases-ci/publish-npm.js b/scripts/releases-ci/publish-npm.js index 8d5b8ff2e1f1..75193c1f4ca7 100755 --- a/scripts/releases-ci/publish-npm.js +++ b/scripts/releases-ci/publish-npm.js @@ -18,6 +18,9 @@ const { updateReactNativeArtifacts, } = require('../releases/set-rn-artifacts-version'); const {setVersion} = require('../releases/set-version'); +const { + updateHermesVersionsToNightly, +} = require('../releases/utils/hermes-utils'); const {getNpmInfo, publishPackage} = require('../releases/utils/npm-utils'); const { publishAndroidArtifactsToMaven, @@ -96,6 +99,9 @@ async function publishNpm(buildType /*: BuildType */) /*: Promise */ { // For stable releases, ci job `prepare_package_for_release` handles this if (buildType === 'nightly') { + // Set hermes versions to latest available + await updateHermesVersionsToNightly(); + // Set same version for all monorepo packages await setVersion(version); await publishMonorepoPackages(tag); @@ -113,6 +119,8 @@ async function publishNpm(buildType /*: BuildType */) /*: Promise */ { const packageJson = JSON.parse(packageJsonContent); if (packageJson.version === '1000.0.0') { + // Set hermes versions to latest available + await updateHermesVersionsToNightly(); await updateReactNativeArtifacts(version, buildType); } } diff --git a/scripts/releases/set-rn-artifacts-version.js b/scripts/releases/set-rn-artifacts-version.js index 9341d5951062..bf8671237180 100755 --- a/scripts/releases/set-rn-artifacts-version.js +++ b/scripts/releases/set-rn-artifacts-version.js @@ -155,8 +155,6 @@ function updateTestFiles( async function updateGradleFile(version /*: string */) /*: Promise */ { const contents = await fs.readFile(GRADLE_FILE_PATH, 'utf-8'); - // TODO: T231755027 set HERMES_VERSION_NAME - return fs.writeFile( GRADLE_FILE_PATH, contents.replace(/^VERSION_NAME=.*/, `VERSION_NAME=${version}`), diff --git a/scripts/releases/use-hermes-nightly.js b/scripts/releases/use-hermes-nightly.js new file mode 100644 index 000000000000..5dc782e93d14 --- /dev/null +++ b/scripts/releases/use-hermes-nightly.js @@ -0,0 +1,21 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + */ + +'use strict'; + +const {updateHermesVersionsToNightly} = require('./utils/hermes-utils'); + +async function main() { + await updateHermesVersionsToNightly(); +} + +if (require.main === module) { + void main(); +} diff --git a/scripts/releases/utils/hermes-utils.js b/scripts/releases/utils/hermes-utils.js new file mode 100644 index 000000000000..37b57893663c --- /dev/null +++ b/scripts/releases/utils/hermes-utils.js @@ -0,0 +1,99 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + */ + +const {REACT_NATIVE_PACKAGE_DIR} = require('../../shared/consts'); +const { + getPackages, + getWorkspaceRoot, + updatePackageJson, +} = require('../../shared/monorepoUtils'); +const {getPackageVersionStrByTag} = require('./npm-utils'); +const {promises: fs} = require('fs'); +const path = require('path'); + +const MAVEN_VERSIONS_FILE_PATH = path.join( + REACT_NATIVE_PACKAGE_DIR, + 'sdks', + 'hermes-engine', + 'version.properties', +); + +async function getLatestHermesNightlyVersion() /*: Promise<{ + compilerVersion: string, + runtimeVersion: string, + runtimeV1Version: string, +}> */ { + // fetch the latest commitly version of hermes v0 + const compilerVersion = await getPackageVersionStrByTag( + 'hermes-compiler', + 'nightly', + ); + // fetch the latest version of hermes v1 + const compilerV1Version = await getPackageVersionStrByTag( + 'hermes-compiler', + 'latest-v1', + ); + + return { + compilerVersion, + // runtime version should match the compiler version + runtimeVersion: compilerVersion, + runtimeV1Version: compilerV1Version, + }; +} + +async function updateHermesCompilerVersionInDependencies( + hermesVersion /*: string */, +) /*: Promise */ { + const packages = await getPackages({ + includePrivate: true, + includeReactNative: true, + }); + + const packagesToUpdate = [ + await getWorkspaceRoot(), + ...Object.values(packages), + ]; + + // Update generated files in packages/react-native/ + await Promise.all( + packagesToUpdate.map(pkg => + updatePackageJson(pkg, {'hermes-compiler': hermesVersion}), + ), + ); +} + +async function updateHermesRuntimeDependenciesVersions( + hermesVersion /*: string */, + hermesV1Version /*: string */, +) /*: Promise */ { + const newVersionsFile = + `HERMES_VERSION_NAME=${hermesVersion}\n` + + `HERMES_V1_VERSION_NAME=${hermesV1Version}`; + + await fs.writeFile(MAVEN_VERSIONS_FILE_PATH, newVersionsFile.trim() + '\n'); +} + +async function updateHermesVersionsToNightly() { + const hermesVersions = await getLatestHermesNightlyVersion(); + await updateHermesCompilerVersionInDependencies( + hermesVersions.compilerVersion, + ); + await updateHermesRuntimeDependenciesVersions( + hermesVersions.runtimeVersion, + hermesVersions.runtimeV1Version, + ); +} + +module.exports = { + updateHermesVersionsToNightly, + updateHermesCompilerVersionInDependencies, + updateHermesRuntimeDependenciesVersions, +}; diff --git a/scripts/releases/utils/npm-utils.js b/scripts/releases/utils/npm-utils.js index 97889e85d540..fa721ad59054 100644 --- a/scripts/releases/utils/npm-utils.js +++ b/scripts/releases/utils/npm-utils.js @@ -174,4 +174,5 @@ function getPackageVersionStrByTag( module.exports = { getNpmInfo, publishPackage, + getPackageVersionStrByTag, }; diff --git a/scripts/releases/utils/release-utils.js b/scripts/releases/utils/release-utils.js index e577cc0543b1..207d6ded4ab1 100644 --- a/scripts/releases/utils/release-utils.js +++ b/scripts/releases/utils/release-utils.js @@ -10,10 +10,7 @@ 'use strict'; -const { - createHermesPrebuiltArtifactsTarball, -} = require('../../../packages/react-native/scripts/hermes/hermes-utils'); -const {echo, exec, exit, popd, pushd, test} = require('shelljs'); +const {echo, exec, exit, test} = require('shelljs'); /*:: type BuildType = 'dry-run' | 'release' | 'nightly'; @@ -120,35 +117,6 @@ function publishExternalArtifactsToMaven( echo('Finished publishing external artifacts to Maven Central'); } -function generateiOSArtifacts( - jsiFolder /*: string */, - hermesCoreSourceFolder /*: string */, - buildType /*: 'Debug' | string */, - targetFolder /*: string */, -) /*: string */ { - pushd(`${hermesCoreSourceFolder}`); - - //Generating iOS Artifacts - exec( - `JSI_PATH=${jsiFolder} BUILD_TYPE=${buildType} ${hermesCoreSourceFolder}/utils/build-mac-framework.sh`, - ); - - exec( - `JSI_PATH=${jsiFolder} BUILD_TYPE=${buildType} ${hermesCoreSourceFolder}/utils/build-ios-framework.sh`, - ); - - popd(); - - const tarballOutputPath = createHermesPrebuiltArtifactsTarball( - hermesCoreSourceFolder, - buildType, - targetFolder, - true, // this is excludeDebugSymbols, we keep it as the default - ); - - return tarballOutputPath; -} - function failIfTagExists(version /*: string */, buildType /*: BuildType */) { // When dry-run in stable branch, the tag already exists. // We are bypassing the tag-existence check when in a dry-run to have the CI pass @@ -175,7 +143,6 @@ function checkIfTagExists(version /*: string */) { module.exports = { generateAndroidArtifacts, - generateiOSArtifacts, publishAndroidArtifactsToMaven, publishExternalArtifactsToMaven, failIfTagExists,