Skip to content

Commit d859e2f

Browse files
authored
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)
1 parent 246d6c6 commit d859e2f

File tree

5 files changed

+219
-19
lines changed

5 files changed

+219
-19
lines changed

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# Do not remove or rename entries in this file, only add new ones
22
# See https://github.com/flutter/flutter/issues/128635 for more context.
33

4-
# This is dynamic in a monorepo
5-
bin/internal/engine.version
6-
74
# Miscellaneous
85
*.class
96
*.lock
@@ -33,6 +30,8 @@ bin/internal/engine.version
3330
/bin/cache/
3431
/bin/internal/bootstrap.bat
3532
/bin/internal/bootstrap.sh
33+
/bin/internal/engine.realm
34+
/bin/internal/engine.version
3635
/bin/mingit/
3736
/dev/benchmarks/mega_gallery/
3837
/dev/bots/.recipe_deps

bin/internal/engine.realm

Whitespace-only changes.

bin/internal/update_engine_version.ps1

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@ $ErrorActionPreference = "Stop"
1919
$progName = Split-Path -parent $MyInvocation.MyCommand.Definition
2020
$flutterRoot = (Get-Item $progName).parent.parent.FullName
2121

22+
# Generate a bin/cache directory, which won't initially exist for a fresh checkout.
23+
New-Item -Path "$flutterRoot/bin/cache" -ItemType Directory -Force | Out-Null
24+
2225
# On stable, beta, and release tags, the engine.version is tracked by git - do not override it.
2326
$trackedEngine = (git -C "$flutterRoot" ls-files bin/internal/engine.version) | Out-String
2427
if ($trackedEngine.length -ne 0) {
28+
Copy-Item -Path "$flutterRoot/bin/internal/engine.version" -Destination "$flutterRoot/bin/cache/engine.stamp" -Force
2529
return
2630
}
2731

@@ -40,7 +44,7 @@ if (![string]::IsNullOrEmpty($env:FLUTTER_PREBUILT_ENGINE_VERSION)) {
4044
}
4145

4246
# Test for fusion repository
43-
if ([string]::IsNullOrEmpty($engineVersion) -and (Test-Path "$flutterRoot\DEPS" -PathType Leaf) -and (Test-Path "$flutterRoot\engine\src\.gn" -PathType Leaf)) {
47+
if ([string]::IsNullOrEmpty($engineVersion) -and (Test-Path "$flutterRoot/DEPS" -PathType Leaf) -and (Test-Path "$flutterRoot/engine/src/.gn" -PathType Leaf)) {
4448
if ($null -eq $Env:LUCI_CONTEXT) {
4549
$ErrorActionPreference = "Continue"
4650
git -C "$flutterRoot" remote get-url upstream *> $null
@@ -59,9 +63,17 @@ if ([string]::IsNullOrEmpty($engineVersion) -and (Test-Path "$flutterRoot\DEPS"
5963

6064
# Write the engine version out so downstream tools know what to look for.
6165
$utf8NoBom = New-Object System.Text.UTF8Encoding($false)
62-
[System.IO.File]::WriteAllText("$flutterRoot\bin\internal\engine.version", $engineVersion, $utf8NoBom)
66+
[System.IO.File]::WriteAllText("$flutterRoot/bin/cache/engine.stamp", $engineVersion, $utf8NoBom)
67+
# TODO(matanlurey): Stop writing to internal/engine.version. https://github.com/flutter/flutter/issues/164315.
68+
[System.IO.File]::WriteAllText("$flutterRoot/bin/internal/engine.version", $engineVersion, $utf8NoBom)
6369

6470
# The realm on CI is passed in.
6571
if ($Env:FLUTTER_REALM) {
66-
[System.IO.File]::WriteAllText("$flutterRoot\bin\internal\engine.realm", $Env:FLUTTER_REALM, $utf8NoBom)
72+
[System.IO.File]::WriteAllText("$flutterRoot/bin/cache/engine.realm", $Env:FLUTTER_REALM, $utf8NoBom)
73+
# TODO(matanlurey): Stop writing to internal/engine.realm. https://github.com/flutter/flutter/issues/164315.
74+
[System.IO.File]::WriteAllText("$flutterRoot/bin/internal/engine.realm", $Env:FLUTTER_REALM, $utf8NoBom)
75+
} else {
76+
[System.IO.File]::WriteAllText("$flutterRoot/bin/cache/engine.realm", "", $utf8NoBom)
77+
# TODO(matanlurey): Stop writing to internal/engine.realm. https://github.com/flutter/flutter/issues/164315.
78+
[System.IO.File]::WriteAllText("$flutterRoot/bin/internal/engine.realm", "", $utf8NoBom)
6779
}

bin/internal/update_engine_version.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@ fi
3333

3434
FLUTTER_ROOT="$(dirname "$(dirname "$(dirname "${BASH_SOURCE[0]}")")")"
3535

36+
# Generate a bin/cache directory, which won't initially exist for a fresh checkout.
37+
mkdir -p "$FLUTTER_ROOT/bin/cache"
38+
3639
# On stable, beta, and release tags, the engine.version is tracked by git - do not override it.
3740
TRACKED_ENGINE="$(git -C "$FLUTTER_ROOT" ls-files bin/internal/engine.version)"
3841
if [[ -n "$TRACKED_ENGINE" ]]; then
42+
cp $FLUTTER_ROOT/bin/internal/engine.version $FLUTTER_ROOT/bin/cache/engine.stamp
3943
exit
4044
fi
4145

@@ -60,9 +64,17 @@ if [ -z "$ENGINE_VERSION" ] && [ -f "$FLUTTER_ROOT/DEPS" ] && [ -f "$FLUTTER_ROO
6064
fi
6165

6266
# Write the engine version out so downstream tools know what to look for.
67+
echo $ENGINE_VERSION > "$FLUTTER_ROOT/bin/cache/engine.stamp"
68+
# TODO(matanlurey): Stop writing to internal/engine.version. https://github.com/flutter/flutter/issues/164315.
6369
echo $ENGINE_VERSION > "$FLUTTER_ROOT/bin/internal/engine.version"
6470

6571
# The realm on CI is passed in.
6672
if [ -n "${FLUTTER_REALM}" ]; then
73+
echo $FLUTTER_REALM > "$FLUTTER_ROOT/bin/cache/engine.realm"
74+
# TODO(matanlurey): Stop writing to internal/engine.realm. https://github.com/flutter/flutter/issues/164315.
6775
echo $FLUTTER_REALM > "$FLUTTER_ROOT/bin/internal/engine.realm"
76+
else
77+
echo "" > "$FLUTTER_ROOT/bin/cache/engine.realm"
78+
# TODO(matanlurey): Stop writing to internal/engine.realm. https://github.com/flutter/flutter/issues/164315.
79+
echo "" > "$FLUTTER_ROOT/bin/internal/engine.realm"
6880
fi

0 commit comments

Comments
 (0)