Skip to content

Conversation

@andrewkolos
Copy link
Contributor

Fixes #134197

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.

@andrewkolos andrewkolos added the tool Affects the "flutter" command-line tool. See also t: labels. label Nov 27, 2023
@andrewkolos andrewkolos force-pushed the throw-if-device-does-not-support-flavor branch from 210b8cb to 5ee78c6 Compare November 29, 2023 23:33
@andrewkolos andrewkolos force-pushed the throw-if-device-does-not-support-flavor branch from 5ee78c6 to 84e55e1 Compare December 6, 2023 23:55
@github-actions github-actions bot added the platform-ios iOS applications specifically label Dec 7, 2023
@andrewkolos
Copy link
Contributor Author

fyi @christopherfujino, this is now ready for review again (assuming my last commit doesn't break test)

Copy link
Member

Choose a reason for hiding this comment

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

Was macOS flavor support removed while I was gone?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I previously assumed macOS was supported, but I don't think this is the case?

macOS support is not documented. I also think flutter build macos --flavor results in a ToolExit saying Could not find an option named "flavor".

Copy link
Contributor

Choose a reason for hiding this comment

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

Does it work with flutter run -d macos? If so, fixing flutter build macos might be a one line fix?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then we should document flavors support for macOS (assuming it works). IIRC the setup process in Xcode would be similar but not identical. I'll do more research.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like we deleted the test in april. Not sure what we should do moving forward... #125581

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If

  1. macOS support is not documented,
  2. macOS support is not under test, and most importantly
  3. users can't even build with flavors on macOS (unless they are publishing builds produced by flutter run),

then it's clear to me that macOS is not supported. If support is desired, then it should go through the normal feature request process, no?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Chatted with @christopherfujino. I still think it's fair for this PR to merge as is, but it's arguably worth seeing if macOS flavor support can be easily fixed before making it officially unsupported.

I will see what the current state of macOS flavor support is (i.e. does flutter run --flavor even work properly for macOS?). Then, I'll check in with Hans and see if they have any opinions on the matter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Important correction: flutter build macos --flavor does work. I was accidentally doing flutter run -d macos --flavor instead. Still, the other two points are valid, so I will file an issue and get Hans' input.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had some offline conversations about this, so I'm adding an update here for posterity's sake. I'm allotting myself some time to investigate #139774. If getting flavors for macOS back under test proves simple enough, I'll do that and get support for it publicly documented.

@andrewkolos andrewkolos force-pushed the throw-if-device-does-not-support-flavor branch from 4565874 to 6188b2e Compare January 3, 2024 01:47
@github-actions github-actions bot added the a: desktop Running on desktop label Jan 3, 2024
// Useful for test readability.
// ignore: avoid_redundant_argument_values
final FakeDevice device = FakeDevice(supportsFlavors: false);
testDeviceManager.devices = <Device>[device];
Copy link
Contributor

Choose a reason for hiding this comment

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

can we have two devices, one of which IS supported, and another that is NOT supported, and then pass the --all flag? I'm guessing in that case we should throw tool exit, right?

final bool flavorsSupportedOnEveryDevice = devices!
.every((Device device) => device.supportsFlavors);
if (flavor != null && !flavorsSupportedOnEveryDevice) {
throwToolExit('--flavor is only supported for Android, macOS, and iOS devices.');
Copy link
Contributor

Choose a reason for hiding this comment

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

A few thoughts:

  1. The API here of List<Device>? devices here is unfortunate, but I won't ask you to refactor this in this PR. I'm guessing late final Future<List<Devices>> devices = findAllTargetDevices(); would probably be more readable (although it's unfortunate that findAllTargetDevices() has hidden dependencies, but alas)
  2. I'm guessing that here devices will be only devices that: are available AND we have determined we will be running the app on, right? In which case, it seems like this validation logic is correct.
  3. Do we also need validation logic for flutter test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

2. I'm guessing that here devices will be only devices that: are available AND we have determined we will be running the app on, right? In which case, it seems like this validation logic is correct.

This was my understanding from the last time I read the code. It also makes sense with the name of findAllTargetDevices.

3. Do we also need validation logic for flutter test

This seems like a good idea. I first need to figure out how device selection works for flutter test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added the validation for flutter test. It is unclear to me whether or not this validation should itself be under test. Given its simplicity and that most of the neighboring throwToolExits also do not seem to be under test, I've elected to not create an integration test for this (perhaps I'm succumbing to broken window theory here). I did manually test this.

@gspencergoog gspencergoog requested a review from cbracken January 4, 2024 19:14
Copy link
Member

@jmagman jmagman left a comment

Choose a reason for hiding this comment

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

The iOS and macOS parts LGTM, I'll let @christopherfujino finish his review.

Thank you so much for tracking down the macOS flavor issues. Just today I was able to implement something in packages tooling for iOS and macOS and it's so much nicer when the tool works the same for both!

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

@andrewkolos andrewkolos added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 5, 2024
@auto-submit auto-submit bot merged commit e90e488 into flutter:master Jan 5, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 16, 2024
@mauriziopinotti
Copy link

What's the sense of this change? Now developers have to duplicate all run configurations, one for Web (without flavor option) and one for Mobile (with flavor option), causing massive inconvenience for no gain!

@andrewkolos
Copy link
Contributor Author

What's the sense of this change? Now developers have to duplicate all run configurations, one for Web (without flavor option) and one for Mobile (with flavor option), causing massive inconvenience for no gain!

When questioning the purpose of a PR, I recommend first reading both the PR and the issue associated with it. One or both of these should include the reason for the change. In this case, the original issue, #134197, includes the reasoning.

Regardless, a new issue has been opened to discuss this further, #143574.

@josehigroup
Copy link

It would be excellent if we could continue using the flavor flag without breaking the build. that way we can continue using our run configuration for mobile and web.

@mauriziopinotti
Copy link

mauriziopinotti commented Feb 21, 2024

What's the sense of this change? Now developers have to duplicate all run configurations, one for Web (without flavor option) and one for Mobile (with flavor option), causing massive inconvenience for no gain!

When questioning the purpose of a PR, I recommend first reading both the PR and the issue associated with it. One or both of these should include the reason for the change. In this case, the original issue, #134197, includes the reasoning.

Regardless, a new issue has been opened to discuss this further, #143574.

It's a rhetorical question: I did read the PR and I just think the solution is causing more problems than it's supposed to fix.

@andrewkolos andrewkolos deleted the throw-if-device-does-not-support-flavor branch April 29, 2024 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: desktop Running on desktop autosubmit Merge PR when tree becomes green via auto submit App platform-ios iOS applications specifically tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flutter run -d chrome --flavor <flavor> runs without error but flutter build web --flavor results in tool exiting

5 participants