Preland support for monorepo engine hashing (#157138)

Tested on Windows and Mac

Documentation on hashing here: https://github.com/flutter/engine/blob/main/docs/monorepo/engine_binary_hashing.md#recommended-formula-and-implementation

CAVEAT: This is testing git tracked changes from HEAD, which could be a branch with local modifications to the engine. To find the engine version for AB testing, you would need the hash from:
  `git merge-base HEAD upstream/master`

The assumption is the hash calculation at that point is done by the Flutter CLI or Engine Tool.
This commit is contained in:
John McDole 2024-10-18 15:55:07 -07:00 committed by GitHub
parent cd0aa2b537
commit 4f8a6c30d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 2 deletions

View File

@ -20,9 +20,16 @@ $cachePath = "$flutterRoot\bin\cache"
$dartSdkPath = "$cachePath\dart-sdk" $dartSdkPath = "$cachePath\dart-sdk"
$dartSdkLicense = "$cachePath\LICENSE.dart_sdk_archive.md" $dartSdkLicense = "$cachePath\LICENSE.dart_sdk_archive.md"
$engineStamp = "$cachePath\engine-dart-sdk.stamp" $engineStamp = "$cachePath\engine-dart-sdk.stamp"
$engineVersion = (Get-Content "$flutterRoot\bin\internal\engine.version")
$engineRealm = (Get-Content "$flutterRoot\bin\internal\engine.realm") $engineRealm = (Get-Content "$flutterRoot\bin\internal\engine.realm")
if (Test-Path "$flutterRoot\bin\internal\engine.version") {
$engineVersion = (Get-Content "$flutterRoot\bin\internal\engine.version")
} else {
# Calculate the engine hash from tracked git files.
$lsTree = ((git ls-tree -r HEAD engine DEPS) | Out-String).Replace("`r`n", "`n")
$engineVersion = (Get-FileHash -InputStream ([System.IO.MemoryStream] [System.Text.Encoding]::UTF8.GetBytes($lsTree)) -Algorithm SHA1 | ForEach-Object { $_.Hash }).ToLower()
}
$oldDartSdkPrefix = "dart-sdk.old" $oldDartSdkPrefix = "dart-sdk.old"
# Make sure that PowerShell has expected version. # Make sure that PowerShell has expected version.

View File

@ -19,10 +19,18 @@ FLUTTER_ROOT="$(dirname "$(dirname "$(dirname "${BASH_SOURCE[0]}")")")"
DART_SDK_PATH="$FLUTTER_ROOT/bin/cache/dart-sdk" DART_SDK_PATH="$FLUTTER_ROOT/bin/cache/dart-sdk"
DART_SDK_PATH_OLD="$DART_SDK_PATH.old" DART_SDK_PATH_OLD="$DART_SDK_PATH.old"
ENGINE_STAMP="$FLUTTER_ROOT/bin/cache/engine-dart-sdk.stamp" ENGINE_STAMP="$FLUTTER_ROOT/bin/cache/engine-dart-sdk.stamp"
ENGINE_VERSION=$(cat "$FLUTTER_ROOT/bin/internal/engine.version")
ENGINE_REALM=$(cat "$FLUTTER_ROOT/bin/internal/engine.realm" | tr -d '[:space:]') ENGINE_REALM=$(cat "$FLUTTER_ROOT/bin/internal/engine.realm" | tr -d '[:space:]')
OS="$(uname -s)" OS="$(uname -s)"
ENGINE_VERSION=""
if [ -f "$FLUTTER_ROOT/bin/internal/engine.version" ]; then
ENGINE_VERSION=$(cat "$FLUTTER_ROOT/bin/internal/engine.version")
else
# Calculate the engine hash from tracked git files.
# The array takes the first part of the sha1sum string.
ENGINE_VERSION=($(git ls-tree HEAD -r engine DEPS | sha1sum))
fi
if [ ! -f "$ENGINE_STAMP" ] || [ "$ENGINE_VERSION" != `cat "$ENGINE_STAMP"` ]; then if [ ! -f "$ENGINE_STAMP" ] || [ "$ENGINE_VERSION" != `cat "$ENGINE_STAMP"` ]; then
command -v curl > /dev/null 2>&1 || { command -v curl > /dev/null 2>&1 || {
>&2 echo >&2 echo