-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Get flavor/scheme in assemble command from the build configuration #162907
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
Get flavor/scheme in assemble command from the build configuration #162907
Conversation
matanlurey
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.
A few comments/questions. In general LGTM.
| Future<TaskResult> _testFlavorWhenBuiltFromXcode(String projectDir) async { | ||
| final Device device = await devices.workingDevice; | ||
| await inDirectory(projectDir, () async { | ||
| await flutter('clean'); |
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.
Just curious, why was this needed?
If you know, please add 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.
It was to ensure the app bundle was left over from the previous parts of the test. I changed it to just delete the app bundle since that's faster the flutter clean
| '-dTargetFile=$targetPath', | ||
| '-dBuildMode=$buildMode', | ||
| if (environment['FLAVOR'] != null) '-dFlavor=${environment['FLAVOR']}', | ||
| '-dConfiguration=${environment['CONFIGURATION']}', |
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 threre a reason this isn't similar to line 442; that is, if this is null, we would print=null, which I'm not sure is intended (if it is, probably deserves 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.
Yes, so FLAVOR is set by the Flutter CLI in Flutter/Generated.xcconfig when the --flavor is used, so may not always be present. CONFIGURATION is provided by Xcode/xcodebuild and should always be present. I'll add a comment explaining why FLAVOR may be null
packages/flutter_tools/lib/src/build_system/targets/common.dart
Outdated
Show resolved
Hide resolved
packages/flutter_tools/lib/src/build_system/targets/common.dart
Outdated
Show resolved
Hide resolved
matanlurey
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, but I'll defer final approval to Jenn and Ben.
|
|
||
| // Delete app bundle before build to ensure checks below do not use previously | ||
| // built bundle. | ||
| final String appPath = '$projectDir/$buildDir/$configuration-iphoneos/$productName.app'; |
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.
Nit: should we consider using path.join(...) here instead of building the path manually?
…#163737) <!-- Thanks for filing a pull request! Reviewers are typically assigned within a week of filing a request. To learn more about code review, see our documentation on Tree Hygiene: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md --> This request is a subset of #157871 and follows up #162907. #162907 actually fixed behaviour of building with native tooling not only for iOS/macOS, but also for Android builds too: now on master, if you start build with `gradle` instead of `flutter build ...` – you also get the correct behaviour and `appFlavor` won't be null in runtime. Tests in this PR will check exactly this behavior. Another diff is the change in the method of obtaining flavor at runtime inside test project. Before this change, method channels were used for this, after – `appFlavor` constant. Both methods do more or less the same thing right now, but they may diverge in future, so I guess this is the right way to check correctness here. Also, this change was requested and approved by Andrew in #157871 (comment) issue for checklist: #155951 New test was tested here: https://ci.chromium.org/ui/p/flutter/builders/try/Linux_pixel_7pro%20flavors_test/63/overview ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [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. - [x] 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. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [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/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
|
I know there don't exist flavors on web, but some use the So it would be good to have an option on web to set this variable (e.g. via |
This moves the logic for
FLUTTER_APP_FLAVORintoflutter assemble, so that it also works when ran through Xcode and not just through the Flutter CLI.However, there's no definitive way to get the the flavor/scheme in
flutter assemble, so this makes a best effort to get it by parsing it out of theCONFIGURATION.CONFIGURATIONshould have the name of the scheme in it, although, this is only semi-enforced, so may not always work. If it's unable to get the scheme name from theCONFIGURATION, it falls back to using theFLAVORenvironment variable, which is set by the Flutter CLI and used currently.Verified
Mac_ios flavors_test_iospasses: https://ci.chromium.org/ui/p/flutter/builders/prod.shadow/Mac_ios%20flavors_test_ios/7/overviewVerified
Mac flavors_test_macospasses: https://ci.chromium.org/ui/p/flutter/builders/try.shadow/Mac%20flavors_test_macos/2/overviewFixes #155951.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.