Repository navigation
Commit 3238466
fix: forward --build-name and --build-number to desktop version.json (flutter#190130)
On desktop, `flutter build linux --build-name=4.5.6` produces a
`flutter_assets/version.json` that still shows the pubspec default
(`1.0.0`) instead of the value passed on the command line. The same
happens with `--build-number`. That `version.json` (read by
`package_info_plus`) is generated by the assemble target's
`getVersionInfo`, which already honors the `BuildName` and `BuildNumber`
defines. The break is upstream in the desktop build pipeline: those
defines never reach `flutter assemble`.
`BuildInfo.toEnvironmentConfig()`, which produces the environment map
written into the generated CMake config, leaves the build name and
number out, and `tool_backend.dart` does not forward them when it
invokes assemble. Android and web are unaffected because they go through
`toBuildSystemEnvironment()`, which already includes both values.
This forwards the two values through the desktop path, following the
same pattern already used for split-debug-info and tree-shake-icons.
`toEnvironmentConfig()` now emits `BUILD_NAME` and `BUILD_NUMBER` via
the existing null-aware map entries, and `tool_backend.dart` reads them
and adds `-dBuildName` and `-dBuildNumber` to the assemble invocation
next to the other optional defines. Because the map entries are
null-aware, the keys are simply absent when the flags are not supplied,
so default behavior is unchanged. No change is needed in `linux.dart`,
which already applies these defines when they are present.
Reproduced by the issue triager and reconfirmed by another user on
3.29.2. I added a `toEnvironmentConfig` unit test in
`build_info_test.dart` that asserts the new keys appear when a build
name and number are set. The existing encoding test keeps passing
because null values stay omitted.
Fixes flutter#152236
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Co-authored-by: Ben Konyi <[email protected]>1 parent 72311a8 commit 3238466
3 files changed
Lines changed: 20 additions & 0 deletions
File tree
- packages/flutter_tools
- bin
- lib/src
- test/general.shard
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
| |||
98 | 100 | | |
99 | 101 | | |
100 | 102 | | |
| 103 | + | |
| 104 | + | |
101 | 105 | | |
102 | 106 | | |
103 | 107 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
417 | 417 | | |
418 | 418 | | |
419 | 419 | | |
| 420 | + | |
| 421 | + | |
420 | 422 | | |
421 | 423 | | |
422 | 424 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
292 | 292 | | |
293 | 293 | | |
294 | 294 | | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
295 | 309 | | |
296 | 310 | | |
297 | 311 | | |
| |||
0 commit comments