Skip to content

Conversation

@loic-sharma
Copy link
Member

@loic-sharma loic-sharma commented Jun 16, 2022

Background

Currently developers have to edit their Runner.rc file to update their executable's version information. Now, version information will automatically be set from flutter build's arguments or the pubspec.yaml file.

Addresses #73652

How it works

The version information flows to the build output using these steps:

  1. The generated CMake config file contains additional version information
  2. CMake sets preprocessor definitions for the version info using the generated CMake config
  3. The Runner.rc file uses these preprocessor definitions to apply the version information

Upgrading an existing project

Customers that already have a Windows Flutter project will need to update their projects for the version information to flow to the build output. This should be feasible using the upcoming flutter migrate command. Or, developers can update their projects manually:

  1. Backup the project, possibly using version control system
  2. Delete the windows/runner/CMakeLists.txt and windows/runner/Runner.rc files
  3. Run flutter create --platforms=windows .

Customers that choose not to upgrade their project won't be affected by this change.

This PR also updates all Flutter Windows projects in the flutter repository.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard flutter-dashboard bot added d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos documentation c: contributor-productivity Team-specific productivity, code health, technical debt. tool Affects the "flutter" command-line tool. See also t: labels. labels Jun 16, 2022
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was re-generated using flutter create --platforms=windows .

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was re-generated using flutter create --platforms=windows .

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was re-generated using flutter create --platforms=windows .

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was re-generated using flutter create --platforms=windows .

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was re-generated using flutter create --platforms=windows .

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was re-generated using flutter create --platforms=windows .

@loic-sharma loic-sharma force-pushed the flow-version-to-exe branch from b9e05b7 to 4056573 Compare June 16, 2022 23:59
@loic-sharma loic-sharma force-pushed the flow-version-to-exe branch from 33a9b2c to 851ae10 Compare June 18, 2022 00:24
@loic-sharma loic-sharma requested a review from GaryQian June 21, 2022 18:44
@loic-sharma
Copy link
Member Author

/cc @GaryQian as this is a candidate for the upcoming flutter migrate command.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding migration tool, is this file ever modified by the developer?

If this file is untouched by the developer, the migrate tool will handle it cleanly.

If it is user-modified, the tool will attempt to merge. Most small changes can be merged easily, but if there are conflicts, then they need to be resolved manually.

In general, the changes made in this PR don't seem to be in user-owned files, so migrate tool should be able to handle silently.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything in runner/ is user-owned. Developers who have released updates to apps on Windows have almost certainly edited parts of this file that will conflict.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep - this is all user-owned, and I'd expect potentially extensive additions to the rc file, but I suspect there are ways we could programmatically check that the migration of the version info is safe.

All of the following would need to be true:

  1. The patch applies cleanly
  2. VERSION_AS_NUMBER and VERSION_AS_STRING don't exist outside the patched area and the VS_VERSION_INFO block.
  3. The VS_VERSION_INFO block is unchanged in any way, other than the expected templated strings.

If any of the above is not true, we couldn't apply the migration, and instead should emit a pointer to what the user can (optionally) do by hand.

@stuartmorgan are there cases you can think of where the above are true where this would break things?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can plausibly validate 2; it could be set in the project itself, or in an included file.

I think the sane options would be:

  1. Just do the migration if it doesn't conflict. For some people things will just start working (the updated PR won't conflict with nearly as many people, so it could even be most people), for some it'll be a no-op because they've replaced the use of the variables with hard-coded values, and for a very small number who plumbed this into their build system themselves it'll replace their workaround with something that works automatically (which seems pretty low-risk to me).
  2. Don't ever try to auto-migrate; instead just warn if the new code can't be found and suggest they update manually (with instructions).

Copy link
Member Author

@loic-sharma loic-sharma Jun 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the design doc on the upcoming flutter migrate command: flutter.dev/go/flutter-migrate

From my understanding, flutter migrate does option 2: flutter upgrade and flutter doctor will warn if your project needs to be updated, and the user will need to run flutter migrate to apply the migration.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah that makes sense; at least this is a user-initiated action, so assuming it emits appropriate messages informing the user of what we're about to attempt and whether or not it was successful, it should be pretty unsurprising to the user. If they've got their app under source control (and hopefully they do), they can inspect the diffs themselves after the action is complete and elect not to commit if they don't like what they see.

@loic-sharma loic-sharma force-pushed the flow-version-to-exe branch from a04da09 to 07a707a Compare June 21, 2022 22:55
@loic-sharma loic-sharma force-pushed the flow-version-to-exe branch from fbd84b9 to 7700d91 Compare June 22, 2022 23:48
Copy link
Contributor

@christopherfujino christopherfujino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo stuart's nits

@loic-sharma
Copy link
Member Author

FYI I added one last commit that:

  1. Warns on Windows if the build number conversion fails
  2. Allows --build-number without --build-name (previously --build-number was ignored unless --build-name was also provided)

@loic-sharma loic-sharma merged commit 6026eea into flutter:master Jun 27, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Jun 27, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Jun 28, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 28, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Jun 28, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Jun 28, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Jun 28, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Jun 28, 2022
camsim99 pushed a commit to camsim99/flutter that referenced this pull request Aug 10, 2022
Previously developers had to edit their `Runner.rc` file to update their executable's version information. Now, version information will automatically be set from `flutter build`'s arguments or the `pubspec.yaml` file for new projects. 

Addresses flutter#73652
@dhzdhd dhzdhd mentioned this pull request Aug 28, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 30, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Aug 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: contributor-productivity Team-specific productivity, code health, technical debt. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants