[stable] [flutter_tools] Fix native assets crash on Linux custom devices#189088
Conversation
…ter#188384) When native assets are enabled, the Flutter tool attempts to resolve the C compiler configuration. On Linux, this is done by reading `CMakeCache.txt` from the native build directory to align toolchains. However, for custom devices or `flutter build bundle` commands, no native app build is performed, meaning `CMakeCache.txt` does not exist. This previously caused the tool to crash unconditionally. This PR: 1. Adds a `throwIfNotFound` parameter to `cCompilerConfigLinux` (defaulting to `true`) to allow graceful failures (returning `null`) when the CMake cache or toolchain is missing. 2. Updates `LinuxAssetTarget.setCCompilerConfig` to only require the compiler configuration (passing `throwIfNotFound: true`) if a native app build directory actually exists. Otherwise, it allows it to be optional and return `null`. 3. Fixes and adds unit tests, and introduces a new integration test verifying that `flutter build bundle` succeeds on Linux with native assets. Fixes flutter#187980
|
This pull request was opened from and to a release candidate branch. This should only be done as part of the official Flutter release process. If you are attempting to make a regular contribution to the Flutter project, please close this PR and follow the instructions at Tree Hygiene for detailed instructions on contributing to Flutter. Reviewers: Use caution before merging pull requests to release branches. Ensure the proper procedure has been followed. |
There was a problem hiding this comment.
Code Review
This pull request introduces a throwIfNotFound parameter to cCompilerConfigLinux to allow returning null instead of throwing exceptions when compiler configurations or tools are missing, and updates LinuxAssetTarget and tests accordingly. The reviewer recommends documenting this new parameter to comply with the repository style guide.
4561c36
into
flutter:flutter-3.44-candidate.0
This pull request is created by automatic cherry pick workflow
Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request.
Issue Link:
#187980
Impact Description:
When native assets are enabled on Linux, building asset bundles (e.g.,
flutter build bundleor running on custom devices without a native CMake build) crashes with a tool exit becauseCMakeCache.txtis missing.Changelog Description:
flutter/187980: On Linux, building asset bundles with native assets enabled without a native app build directory crashes due to missing
CMakeCache.txt.Workaround:
None for custom devices or bundle builds where CMake is not executed.
Risk:
What is the risk level of this cherry-pick?
Test Coverage:
Are you confident that your fix is well-tested by automated tests?
Validation Steps:
flutter config --enable-native-assets).flutter build bundlein a project with a native asset hook.flutter build bundlesucceeds without crashing due to missingCMakeCache.txt.