-
Notifications
You must be signed in to change notification settings - Fork 29.7k
[Windows] Add version info migration #123414
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
[Windows] Add version info migration #123414
Conversation
071d32f to
a184698
Compare
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.
So we're sure this will end in \r\n because when you use git on Windows, and it checks out https://github.com/flutter/flutter/blob/master/packages/flutter_tools/templates/app_shared/windows.tmpl/CMakeLists.txt.tmpl, it will auto convert \n -> \r\n, or is there some other OS-level magic? Or are there some configurations of git that might lead to this file having only \n between lines?
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.
Or, do we know this must have \r\n because otherwise windows cmake will explode?
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.
Good question. Somehow this has \r\n line endings on my computer, let me investigate how that happens.
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.
It turns out it's because I've enabled autocrlf globally on git. This converts my Flutter SDK's template files from LF to CRLF on checkout. It's likely most users have LF line endings, so we should support that 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.
I'm gonna be out for a week, however this change LGTM provided we're confident it will work no matter which settings they have in their windows git config :)
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.
to clarify, we only want to do any migrations if BOTH of these files exist?
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.
Yup. I'd like to make this migration conservative and only run on projects that are clearly safe. If one of these files is missing, it indicates the app has done non-trivial changes to its runner.
That said, this migration should be safe even if one file is missing: each file's changes are backwards compatible and would work even if the other file's migration wasn't applied.
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.
Is there a docs page we can point people to when this fails, so they can do it by hand if desired? If so, in addition, log something like "For more information see: URL".
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.
I added some more information to the trace to make it more actionable. This failure scenario seems unlikely (it wouldn't be unreasonable for flutter build windows to break if the runner's CMakeLists.txt file was missing), so I don't think it warrants a dedicated docs page.
packages/flutter_tools/lib/src/windows/migrations/version_migration.dart
Outdated
Show resolved
Hide resolved
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 be preferable to put these long hardcoded strings into their own file(s)?
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.
Prior art also hardcodes strings inside the migration itself:
Lines 41 to 62 in 2379b18
| const String thinBinaryBuildPhaseOriginal = ''' | |
| 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { | |
| isa = PBXShellScriptBuildPhase; | |
| alwaysOutOfDate = 1; | |
| buildActionMask = 2147483647; | |
| files = ( | |
| ); | |
| inputPaths = ( | |
| ); | |
| '''; | |
| const String thinBinaryBuildPhaseReplacement = r''' | |
| 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { | |
| isa = PBXShellScriptBuildPhase; | |
| alwaysOutOfDate = 1; | |
| buildActionMask = 2147483647; | |
| files = ( | |
| ); | |
| inputPaths = ( | |
| "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", | |
| ); | |
| '''; |
I can move this to another file if folks feel strongly about this.
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.
I weakly would prefer it inlined to make it easier to grep for a string and then see the usage within the tool.
yaakovschectman
left a comment
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 then
packages/flutter_tools/lib/src/windows/migrations/version_migration.dart
Outdated
Show resolved
Hide resolved
packages/flutter_tools/lib/src/windows/migrations/version_migration.dart
Outdated
Show resolved
Hide resolved
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.
Even though it's private, consider adding a doc comment stating what this does. The name sounds like it might have to do with replacing window resources of some sort (if such a thing exists).
Do we already have a _replaceFirst? I'd be tempted to just name it that, since that's what it does. That it handles windows line-endings is more of an implementation detail.
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.
Updated! Let me know if you have additional feedback here!
cbracken
left a comment
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.
Looks good modulo minor nits!
a845615 to
659486b
Compare
[Windows] Add version info migration
Windows apps can set version information but this requires a manual migration for projects created before Flutter 3.3. This change automates that migration.
Addresses #121724
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.