Roll-forward #164317: Use bin/cache/engine.stamp (#164401)

... and this time, create `bin/cache` before trying to write to it!

(Tests updated to catch this regression)
This commit is contained in:
Matan Lurey
2025-02-28 16:10:44 -08:00
committed by GitHub
parent 246d6c6834
commit d859e2f43e
5 changed files with 219 additions and 19 deletions

View File

@@ -19,9 +19,13 @@ $ErrorActionPreference = "Stop"
$progName = Split-Path -parent $MyInvocation.MyCommand.Definition
$flutterRoot = (Get-Item $progName).parent.parent.FullName
# Generate a bin/cache directory, which won't initially exist for a fresh checkout.
New-Item -Path "$flutterRoot/bin/cache" -ItemType Directory -Force | Out-Null
# On stable, beta, and release tags, the engine.version is tracked by git - do not override it.
$trackedEngine = (git -C "$flutterRoot" ls-files bin/internal/engine.version) | Out-String
if ($trackedEngine.length -ne 0) {
Copy-Item -Path "$flutterRoot/bin/internal/engine.version" -Destination "$flutterRoot/bin/cache/engine.stamp" -Force
return
}
@@ -40,7 +44,7 @@ if (![string]::IsNullOrEmpty($env:FLUTTER_PREBUILT_ENGINE_VERSION)) {
}
# Test for fusion repository
if ([string]::IsNullOrEmpty($engineVersion) -and (Test-Path "$flutterRoot\DEPS" -PathType Leaf) -and (Test-Path "$flutterRoot\engine\src\.gn" -PathType Leaf)) {
if ([string]::IsNullOrEmpty($engineVersion) -and (Test-Path "$flutterRoot/DEPS" -PathType Leaf) -and (Test-Path "$flutterRoot/engine/src/.gn" -PathType Leaf)) {
if ($null -eq $Env:LUCI_CONTEXT) {
$ErrorActionPreference = "Continue"
git -C "$flutterRoot" remote get-url upstream *> $null
@@ -59,9 +63,17 @@ if ([string]::IsNullOrEmpty($engineVersion) -and (Test-Path "$flutterRoot\DEPS"
# Write the engine version out so downstream tools know what to look for.
$utf8NoBom = New-Object System.Text.UTF8Encoding($false)
[System.IO.File]::WriteAllText("$flutterRoot\bin\internal\engine.version", $engineVersion, $utf8NoBom)
[System.IO.File]::WriteAllText("$flutterRoot/bin/cache/engine.stamp", $engineVersion, $utf8NoBom)
# TODO(matanlurey): Stop writing to internal/engine.version. https://github.com/flutter/flutter/issues/164315.
[System.IO.File]::WriteAllText("$flutterRoot/bin/internal/engine.version", $engineVersion, $utf8NoBom)
# The realm on CI is passed in.
if ($Env:FLUTTER_REALM) {
[System.IO.File]::WriteAllText("$flutterRoot\bin\internal\engine.realm", $Env:FLUTTER_REALM, $utf8NoBom)
[System.IO.File]::WriteAllText("$flutterRoot/bin/cache/engine.realm", $Env:FLUTTER_REALM, $utf8NoBom)
# TODO(matanlurey): Stop writing to internal/engine.realm. https://github.com/flutter/flutter/issues/164315.
[System.IO.File]::WriteAllText("$flutterRoot/bin/internal/engine.realm", $Env:FLUTTER_REALM, $utf8NoBom)
} else {
[System.IO.File]::WriteAllText("$flutterRoot/bin/cache/engine.realm", "", $utf8NoBom)
# TODO(matanlurey): Stop writing to internal/engine.realm. https://github.com/flutter/flutter/issues/164315.
[System.IO.File]::WriteAllText("$flutterRoot/bin/internal/engine.realm", "", $utf8NoBom)
}

View File

@@ -33,9 +33,13 @@ fi
FLUTTER_ROOT="$(dirname "$(dirname "$(dirname "${BASH_SOURCE[0]}")")")"
# Generate a bin/cache directory, which won't initially exist for a fresh checkout.
mkdir -p "$FLUTTER_ROOT/bin/cache"
# On stable, beta, and release tags, the engine.version is tracked by git - do not override it.
TRACKED_ENGINE="$(git -C "$FLUTTER_ROOT" ls-files bin/internal/engine.version)"
if [[ -n "$TRACKED_ENGINE" ]]; then
cp $FLUTTER_ROOT/bin/internal/engine.version $FLUTTER_ROOT/bin/cache/engine.stamp
exit
fi
@@ -60,9 +64,17 @@ if [ -z "$ENGINE_VERSION" ] && [ -f "$FLUTTER_ROOT/DEPS" ] && [ -f "$FLUTTER_ROO
fi
# Write the engine version out so downstream tools know what to look for.
echo $ENGINE_VERSION > "$FLUTTER_ROOT/bin/cache/engine.stamp"
# TODO(matanlurey): Stop writing to internal/engine.version. https://github.com/flutter/flutter/issues/164315.
echo $ENGINE_VERSION > "$FLUTTER_ROOT/bin/internal/engine.version"
# The realm on CI is passed in.
if [ -n "${FLUTTER_REALM}" ]; then
echo $FLUTTER_REALM > "$FLUTTER_ROOT/bin/cache/engine.realm"
# TODO(matanlurey): Stop writing to internal/engine.realm. https://github.com/flutter/flutter/issues/164315.
echo $FLUTTER_REALM > "$FLUTTER_ROOT/bin/internal/engine.realm"
else
echo "" > "$FLUTTER_ROOT/bin/cache/engine.realm"
# TODO(matanlurey): Stop writing to internal/engine.realm. https://github.com/flutter/flutter/issues/164315.
echo "" > "$FLUTTER_ROOT/bin/internal/engine.realm"
fi