-
Notifications
You must be signed in to change notification settings - Fork 28.7k
[flutter_tools] cache flutter sdk version to disk #124558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -123,7 +123,10 @@ function upgrade_flutter () ( | |||
# * STAMP_PATH is an empty file, or | |||
# * Contents of STAMP_PATH is not what we are going to compile, or | |||
# * pubspec.yaml last modified after pubspec.lock | |||
if [[ ! -f "$SNAPSHOT_PATH" || ! -s "$STAMP_PATH" || "$(cat "$STAMP_PATH")" != "$compilekey" || "$FLUTTER_TOOLS_DIR/pubspec.yaml" -nt "$FLUTTER_TOOLS_DIR/pubspec.lock" ]]; then | |||
if [[ ! -f "$SNAPSHOT_PATH" || \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a formatting change that makes it more legible
1529476
to
0926016
Compare
fd582af
to
c2e57ee
Compare
92ae949
to
110f7aa
Compare
b740229
to
9d92fd4
Compare
.gitignore
Outdated
@@ -39,6 +39,7 @@ | |||
/dev/integration_tests/**/Pods | |||
/packages/flutter/coverage/ | |||
version | |||
.version.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately if a user tries out a beta flutter version that generates this file, then switches back to stable that doesn't, it won't be gitignored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it worth getting a hot fix into stable that just adds this into the gitignore as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zanderso what do you think? Having a dirty checkout of the framework would cause flutter upgrade
to fail, so I think it would make sense to cherrypick this. If not, then we should probably land the gitignore change first, and then only land the rest of this once that's reached stable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the .version.json
live in a directory that's already .gitignore
'd? Maybe bin/cache
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a good idea!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like moving into the cache directory is causing errors when trying to find the version file.
We may need to first create the version file recursively before we try to write to it now that it is in a nested directory?
Is this vulnerable to the staleness concerns you had with #111392? |
Good question, but this is covered by https://github.com/flutter/flutter/pull/124558/files#diff-092e00109d9e1589fbc7c6de750e29a6ae512b2dd44e85d60028953561201605R91 // if we are fetching tags, ignore cached versionFile
if (fetchTags && versionFile.existsSync()) {
versionFile.deleteSync();
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with minor question.
I still advise a second thorough review from @eliasyishak.
Yep still reviewing on my end as well |
b4b62aa
to
8d4c751
Compare
flutter/flutter@95be76a...b0188cd 2023-06-15 [email protected] [web] Pass creation params to the platform view factory (flutter/flutter#128146) 2023-06-15 [email protected] [flutter_tools] cache flutter sdk version to disk (flutter/flutter#124558) 2023-06-14 [email protected] Fix inconsistently suffixed macOS flavored bundle directory (flutter/flutter#127997) 2023-06-14 [email protected] Update golden tests for material (flutter/flutter#128839) 2023-06-14 [email protected] Update getChildrenSummaryTree to handle Diagnosticable as input. (flutter/flutter#128833) 2023-06-14 [email protected] Improve the error message for non-normalized constraints (flutter/flutter#127906) 2023-06-14 [email protected] ContextAction.isEnabled needs a context (flutter/flutter#127721) 2023-06-14 [email protected] Remove temporary default case for PointerSignalKind (flutter/flutter#128900) 2023-06-14 [email protected] Respect allowlisted count of leaks. (flutter/flutter#128823) 2023-06-14 [email protected] Unpin flutter_plugin_android_lifecycle (flutter/flutter#128898) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Fixes #133093 When I introduced the new, more robust version file `//flutter/bin/cache/version.json` in #124558, I changed `class FlutterVersion` into an abstract interface, implemented by `_FlutterVersionFromGit` (which is essentially the previous behavior) and `_FlutterVersionFromFile`, which merely reads the data it would have computed via git from `//flutter/bin/cache/version.json`. While doing this, I made `_FlutterVersionFromGit.ensureVersionFile()` to be a no-op, since I assumed this would not be necessary since we already had a version file in the cache. However, this method was what was previously responsible for ensuring `//flutter/version` existed on disk. This means that if, for whatever reason, the user had `//flutter/bin/cache/flutter.version.json` present but NOT `//flutter/version`, the tool would have never created that file, and they would hit the tool crash seen in #133093. This fixes the tool by ensuring `//flutter/version` exists regardless of if we're hydrating `FlutterVersion` from `//flutter/bin/cache/flutter.version.json` or not.
Fixes #112833
Most of the actual changes here are in packages/flutter_tools/lib/src/version.dart, while the rest is largely just addressing changes to the constructor of
FlutterVersion
which now has different dependencies.This change makes
FlutterVersion
an interface with two concrete implementations:_FlutterVersionGit
which is mostly the previous implementation, and_FlutterVersionFromFile
which will read a new.version.json
file from the root of the repoThe
FlutterVersion
constructor is now a factory that first checks if.version.json
exists, and if so returns an instance of_FlutterVersionFromGit
else it returns the fallback_FlutterVersionGit
which will end up writing.version.json
so that we don't need to re-calculate the version on the next invocation..version.json
will be deleted in the bash/batch entrypoints any time we need to rebuild he tool (this will usually be because the user didflutter upgrade
orflutter channel
, or manually changed the commit with git).