Skip to content

Use FlutterFeatures to configure web and desktop devices#36465

Merged
jonahwilliams merged 9 commits intoflutter:masterfrom
jonahwilliams:use_web_config
Jul 22, 2019
Merged

Use FlutterFeatures to configure web and desktop devices#36465
jonahwilliams merged 9 commits intoflutter:masterfrom
jonahwilliams:use_web_config

Conversation

@jonahwilliams
Copy link
Copy Markdown
Contributor

@jonahwilliams jonahwilliams commented Jul 18, 2019

Description

A follow up to #36138, this PR enables the usage of flutter config for web, Linux, macOS, and Windows features. This removes the on-by default behavior of these features on master branch and instead replaces it with a configurable flag. For backwards compatibility, the old environment variables ENABLE_FLUTER_DESKTOP and FLUTTER_WEB still exist. I would like to deprecate and remove these at some point in the future, and encourage user to provide config values.

Example:

> flutter config
Usage: flutter config [arguments]
-h, --help                           Print this usage information.
    --[no-]analytics                 Enable or disable reporting anonymously tool usage statistics and crash reports.
    --clear-ios-signing-cert         Clear the saved development certificate choice used to sign apps for iOS device deployment.
    --gradle-dir                     The gradle install directory.
    --android-sdk                    The Android SDK directory.
    --android-studio-dir             The Android Studio install directory.
    --[no-]enable-web                Enable or disable Flutter Web on master, dev channels.
    --[no-]enable-linux-desktop      Enable or disable Flutter Desktop for Linux on the master channel.
    --[no-]enable-macos-desktop      Enable or disable Flutter Desktop for macOS on the master channel.
    --[no-]enable-windows-desktop    Enable or disable Flutter Desktop for Windows on the master channel.
    --clear-features                 Remove all configured features and restore them to the default values.

Run "flutter help" to see global options.

@fluttergithubbot fluttergithubbot added the tool Affects the "flutter" command-line tool. See also t: labels. label Jul 18, 2019
@codecov
Copy link
Copy Markdown

codecov bot commented Jul 18, 2019

Codecov Report

Merging #36465 into master will increase coverage by 0.72%.
The diff coverage is 72.09%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #36465      +/-   ##
==========================================
+ Coverage   54.03%   54.75%   +0.72%     
==========================================
  Files         188      188              
  Lines       17344    17303      -41     
==========================================
+ Hits         9372     9475     +103     
+ Misses       7972     7828     -144
Flag Coverage Δ
#flutter_tool 54.75% <72.09%> (+0.72%) ⬆️
Impacted Files Coverage Δ
...ackages/flutter_tools/lib/src/commands/unpack.dart 6.93% <ø> (+0.06%) ⬆️
packages/flutter_tools/lib/src/desktop.dart 86.95% <ø> (+8.38%) ⬆️
...kages/flutter_tools/lib/src/commands/assemble.dart 64.86% <ø> (-0.96%) ⬇️
.../flutter_tools/lib/src/commands/build_fuchsia.dart 81.81% <ø> (ø) ⬆️
packages/flutter_tools/lib/src/device.dart 65.06% <ø> (-2.56%) ⬇️
...ackages/flutter_tools/lib/src/commands/create.dart 67.54% <0%> (-5.25%) ⬇️
.../flutter_tools/lib/src/runner/flutter_command.dart 82.43% <0%> (-0.24%) ⬇️
...lutter_tools/lib/src/windows/windows_workflow.dart 100% <100%> (ø) ⬆️
packages/flutter_tools/lib/src/plugins.dart 86.23% <100%> (ø) ⬆️
...es/flutter_tools/lib/src/macos/macos_workflow.dart 100% <100%> (ø) ⬆️
... and 33 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 578204d...14220b9. Read the comment docs.

@jonahwilliams jonahwilliams marked this pull request as ready for review July 18, 2019 20:18
Copy link
Copy Markdown
Member

@zanderso zanderso left a comment

Choose a reason for hiding this comment

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

lgtm w/ nit

@@ -101,10 +101,18 @@ class BuildBundleCommand extends BuildSubCommand {
// Check for target platforms that are only allowed on unstable Flutter.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this comment need an update?

// Check for target platforms that are only allowed on unstable Flutter.
switch (platform) {
case TargetPlatform.darwin_x64:
if (featureFlags.isMacOSEnabled) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Aren't these all backwards?

(Follow-up: does that mean this codepath isn't tested?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These were wrong, I've added positive/negative test cases for both

@@ -21,10 +21,10 @@ class LinuxWorkflow implements Workflow {
bool get appliesToHostPlatform => platform.isLinux;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't these be gated on it being enabled too? That's how web is done, and it seems odd to be inconsistent about it. That would also simplify other code, since, e.g., the doctor conditions wouldn't need to check the feature flag.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, moving the check here simplifies the rest of the code

/// Only add desktop devices if the flag is enabled.
static List<DeviceDiscovery> get _conditionalDesktopDevices {
return flutterDesktopEnabled ? <DeviceDiscovery>[
if (featureFlags.isMacOSEnabled)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we actually need any of these checks? The devices object will say it can't discover devices anyways, right? Having the checks consolidated in fewer places seems easier.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

if (linuxWorkflow.appliesToHostPlatform) LinuxDoctorValidator(),
if (windowsWorkflow.appliesToHostPlatform) visualStudioValidator,
],
if (featureFlags.isLinuxEnabled && linuxWorkflow.appliesToHostPlatform)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Linux and Windows are behind a check here, but macOS isn't; it should be consistent (even though in practice it doesn't matter, since iOS applying is the same as being on macOS). Per my later comment I think the better option is to remove them all here, but if you don't go that route you should add the check for macOS.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@jonahwilliams
Copy link
Copy Markdown
Contributor Author

I've also removed the isExperimental command property, since I do not want to have two distinct ways to control feature visibility.

@jonahwilliams jonahwilliams merged commit bd52a78 into flutter:master Jul 22, 2019
@jonahwilliams jonahwilliams deleted the use_web_config branch July 22, 2019 01:21
jonahwilliams pushed a commit that referenced this pull request Jul 22, 2019
@jonahwilliams jonahwilliams restored the use_web_config branch July 22, 2019 04:47
jonahwilliams pushed a commit that referenced this pull request Jul 22, 2019
johnsonmh pushed a commit to johnsonmh/flutter that referenced this pull request Jul 30, 2019
johnsonmh pushed a commit to johnsonmh/flutter that referenced this pull request Jul 30, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

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