Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
acda272c
Unverified
Commit
acda272c
authored
Mar 08, 2021
by
Jonah Williams
Committed by
GitHub
Mar 08, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] add tool feature/scaffold for UWP (#77399)
parent
a0ba6464
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
198 additions
and
54 deletions
+198
-54
application_package.dart
packages/flutter_tools/lib/src/application_package.dart
+2
-0
artifacts.dart
packages/flutter_tools/lib/src/artifacts.dart
+3
-0
build_info.dart
packages/flutter_tools/lib/src/build_info.dart
+4
-1
device.dart
packages/flutter_tools/lib/src/device.dart
+1
-0
features.dart
packages/flutter_tools/lib/src/features.dart
+16
-0
flutter_command.dart
packages/flutter_tools/lib/src/runner/flutter_command.dart
+1
-0
windows_device.dart
packages/flutter_tools/lib/src/windows/windows_device.dart
+65
-0
features_test.dart
packages/flutter_tools/test/general.shard/features_test.dart
+80
-52
windows_device_test.dart
...tools/test/general.shard/windows/windows_device_test.dart
+20
-1
fakes.dart
packages/flutter_tools/test/src/fakes.dart
+6
-0
No files found.
packages/flutter_tools/lib/src/application_package.dart
View file @
acda272c
...
...
@@ -111,6 +111,8 @@ class ApplicationPackageFactory {
return
applicationBinary
==
null
?
FuchsiaApp
.
fromFuchsiaProject
(
FlutterProject
.
current
().
fuchsia
)
:
FuchsiaApp
.
fromPrebuiltApp
(
applicationBinary
);
case
TargetPlatform
.
windows_uwp_x64
:
throw
UnsupportedError
(
'Cannot build for windows_uwp_x64'
);
}
assert
(
platform
!=
null
);
return
null
;
...
...
packages/flutter_tools/lib/src/artifacts.dart
View file @
acda272c
...
...
@@ -521,6 +521,9 @@ class CachedArtifacts implements Artifacts {
case
TargetPlatform
.
android
:
assert
(
false
,
'cannot use TargetPlatform.android to look up artifacts'
);
return
null
;
case
TargetPlatform
.
windows_uwp_x64
:
assert
(
false
,
'cannot use TargetPlatform.windows_uwp_x64 to look up artifacts'
);
return
null
;
}
assert
(
false
,
'Invalid platform
$platform
.'
);
return
null
;
...
...
packages/flutter_tools/lib/src/build_info.dart
View file @
acda272c
...
...
@@ -485,6 +485,7 @@ enum TargetPlatform {
linux_x64
,
linux_arm64
,
windows_x64
,
windows_uwp_x64
,
fuchsia_arm64
,
fuchsia_x64
,
tester
,
...
...
@@ -578,10 +579,12 @@ String getNameForTargetPlatform(TargetPlatform platform, {DarwinArch darwinArch}
return
'darwin-x64'
;
case
TargetPlatform
.
linux_x64
:
return
'linux-x64'
;
case
TargetPlatform
.
linux_arm64
:
case
TargetPlatform
.
linux_arm64
:
return
'linux-arm64'
;
case
TargetPlatform
.
windows_x64
:
return
'windows-x64'
;
case
TargetPlatform
.
windows_uwp_x64
:
return
'windows-uwp-x64'
;
case
TargetPlatform
.
fuchsia_arm64
:
return
'fuchsia-arm64'
;
case
TargetPlatform
.
fuchsia_x64
:
...
...
packages/flutter_tools/lib/src/device.dart
View file @
acda272c
...
...
@@ -418,6 +418,7 @@ class FlutterDeviceManager extends DeviceManager {
logger:
logger
,
fileSystem:
fileSystem
,
windowsWorkflow:
windowsWorkflow
,
featureFlags:
featureFlags
,
),
WebDevices
(
featureFlags:
featureFlags
,
...
...
packages/flutter_tools/lib/src/features.dart
View file @
acda272c
...
...
@@ -54,6 +54,9 @@ abstract class FeatureFlags {
/// Whether the CFE experimental invalidation strategy is enabled.
bool
get
isExperimentalInvalidationStrategyEnabled
=>
true
;
/// Whether the windows UWP embedding is enabled.
bool
get
isWindowsUwpEnabled
=>
false
;
/// Whether a particular feature is enabled for the current channel.
///
/// Prefer using one of the specific getters above instead of this API.
...
...
@@ -100,6 +103,9 @@ class FlutterFeatureFlags implements FeatureFlags {
@override
bool
get
isExperimentalInvalidationStrategyEnabled
=>
isEnabled
(
experimentalInvalidationStrategy
);
@override
bool
get
isWindowsUwpEnabled
=>
isEnabled
(
windowsUwpEmbedding
);
@override
bool
isEnabled
(
Feature
feature
)
{
final
String
currentChannel
=
_flutterVersion
.
channel
;
...
...
@@ -336,6 +342,16 @@ const Feature experimentalInvalidationStrategy = Feature(
),
);
/// The feature for enabling the Windows UWP embeding.
const
Feature
windowsUwpEmbedding
=
Feature
(
name:
'Flutter for Windows UWP'
,
configSetting:
'enable-windows-uwp-desktop'
,
master:
FeatureChannelSetting
(
available:
true
,
enabledByDefault:
false
,
),
);
/// A [Feature] is a process for conditionally enabling tool features.
///
/// All settings are optional, and if not provided will generally default to
...
...
packages/flutter_tools/lib/src/runner/flutter_command.dart
View file @
acda272c
...
...
@@ -1430,6 +1430,7 @@ DevelopmentArtifact _artifactFromTargetPlatform(TargetPlatform targetPlatform) {
case
TargetPlatform
.
fuchsia_arm64
:
case
TargetPlatform
.
fuchsia_x64
:
case
TargetPlatform
.
tester
:
case
TargetPlatform
.
windows_uwp_x64
:
// No artifacts currently supported.
return
null
;
}
...
...
packages/flutter_tools/lib/src/windows/windows_device.dart
View file @
acda272c
...
...
@@ -7,12 +7,14 @@
import
'package:meta/meta.dart'
;
import
'package:process/process.dart'
;
import
'../application_package.dart'
;
import
'../base/file_system.dart'
;
import
'../base/logger.dart'
;
import
'../base/os.dart'
;
import
'../build_info.dart'
;
import
'../desktop_device.dart'
;
import
'../device.dart'
;
import
'../features.dart'
;
import
'../project.dart'
;
import
'application_package.dart'
;
import
'build_windows.dart'
;
...
...
@@ -68,6 +70,59 @@ class WindowsDevice extends DesktopDevice {
}
}
// A device that represents a desktop Windows UWP target.
class
WindowsUWPDevice
extends
DesktopDevice
{
WindowsUWPDevice
({
@required
ProcessManager
processManager
,
@required
Logger
logger
,
@required
FileSystem
fileSystem
,
@required
OperatingSystemUtils
operatingSystemUtils
,
})
:
super
(
'windows-uwp'
,
platformType:
PlatformType
.
windows
,
ephemeral:
false
,
processManager:
processManager
,
logger:
logger
,
fileSystem:
fileSystem
,
operatingSystemUtils:
operatingSystemUtils
,
);
@override
bool
isSupported
()
=>
false
;
@override
String
get
name
=>
'Windows (UWP)'
;
@override
Future
<
TargetPlatform
>
get
targetPlatform
async
=>
TargetPlatform
.
windows_uwp_x64
;
@override
bool
isSupportedForProject
(
FlutterProject
flutterProject
)
{
// TODO(flutter): update with detection once FlutterProject knows
// about the UWP structure.
return
false
;
}
@override
Future
<
void
>
buildForDevice
(
covariant
WindowsApp
package
,
{
String
mainPath
,
BuildInfo
buildInfo
,
})
async
{
await
buildWindows
(
FlutterProject
.
current
().
windows
,
buildInfo
,
target:
mainPath
,
);
}
@override
String
executablePathForDevice
(
ApplicationPackage
package
,
BuildMode
buildMode
)
{
// TODO(flutter): update once application package factory knows about UWP bundle.
throw
UnsupportedError
(
'Windows UWP device not implemented.'
);
}
}
class
WindowsDevices
extends
PollingDeviceDiscovery
{
WindowsDevices
({
@required
ProcessManager
processManager
,
...
...
@@ -75,11 +130,13 @@ class WindowsDevices extends PollingDeviceDiscovery {
@required
FileSystem
fileSystem
,
@required
OperatingSystemUtils
operatingSystemUtils
,
@required
WindowsWorkflow
windowsWorkflow
,
@required
FeatureFlags
featureFlags
,
})
:
_fileSystem
=
fileSystem
,
_logger
=
logger
,
_processManager
=
processManager
,
_operatingSystemUtils
=
operatingSystemUtils
,
_windowsWorkflow
=
windowsWorkflow
,
_featureFlags
=
featureFlags
,
super
(
'windows devices'
);
final
FileSystem
_fileSystem
;
...
...
@@ -87,6 +144,7 @@ class WindowsDevices extends PollingDeviceDiscovery {
final
ProcessManager
_processManager
;
final
OperatingSystemUtils
_operatingSystemUtils
;
final
WindowsWorkflow
_windowsWorkflow
;
final
FeatureFlags
_featureFlags
;
@override
bool
get
supportsPlatform
=>
_windowsWorkflow
.
appliesToHostPlatform
;
...
...
@@ -106,6 +164,13 @@ class WindowsDevices extends PollingDeviceDiscovery {
processManager:
_processManager
,
operatingSystemUtils:
_operatingSystemUtils
,
),
if
(
_featureFlags
.
isWindowsUwpEnabled
)
WindowsUWPDevice
(
fileSystem:
_fileSystem
,
logger:
_logger
,
processManager:
_processManager
,
operatingSystemUtils:
_operatingSystemUtils
,
)
];
}
...
...
packages/flutter_tools/test/general.shard/features_test.dart
View file @
acda272c
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/general.shard/windows/windows_device_test.dart
View file @
acda272c
...
...
@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/base/logger.dart';
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/build_info.dart'
;
import
'package:flutter_tools/src/device.dart'
;
import
'package:flutter_tools/src/features.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'package:flutter_tools/src/windows/application_package.dart'
;
import
'package:flutter_tools/src/windows/windows_device.dart'
;
...
...
@@ -43,8 +44,9 @@ void main() {
expect
(
await
WindowsDevices
(
windowsWorkflow:
WindowsWorkflow
(
featureFlags:
TestFeatureFlags
(
isWindowsEnabled:
false
),
platform:
FakePlatform
(
operatingSystem:
'windows'
)
platform:
FakePlatform
(
operatingSystem:
'windows'
)
,
),
featureFlags:
TestFeatureFlags
(
isWindowsEnabled:
false
),
operatingSystemUtils:
FakeOperatingSystemUtils
(),
logger:
BufferLogger
.
test
(),
processManager:
FakeProcessManager
.
any
(),
...
...
@@ -62,9 +64,25 @@ void main() {
logger:
BufferLogger
.
test
(),
processManager:
FakeProcessManager
.
any
(),
fileSystem:
MemoryFileSystem
.
test
(),
featureFlags:
TestFeatureFlags
(
isWindowsEnabled:
true
),
).
devices
,
hasLength
(
1
));
});
testWithoutContext
(
'WindowsDevices lists a UWP Windows device if feature is enabled'
,
()
async
{
final
FeatureFlags
featureFlags
=
TestFeatureFlags
(
isWindowsEnabled:
true
,
isWindowsUwpEnabled:
true
);
expect
(
await
WindowsDevices
(
windowsWorkflow:
WindowsWorkflow
(
featureFlags:
featureFlags
,
platform:
FakePlatform
(
operatingSystem:
'windows'
)
),
operatingSystemUtils:
FakeOperatingSystemUtils
(),
logger:
BufferLogger
.
test
(),
processManager:
FakeProcessManager
.
any
(),
fileSystem:
MemoryFileSystem
.
test
(),
featureFlags:
featureFlags
,
).
devices
,
hasLength
(
2
));
});
testWithoutContext
(
'WindowsDevices ignores the timeout provided to discoverDevices'
,
()
async
{
final
WindowsDevices
windowsDevices
=
WindowsDevices
(
windowsWorkflow:
WindowsWorkflow
(
...
...
@@ -75,6 +93,7 @@ void main() {
logger:
BufferLogger
.
test
(),
processManager:
FakeProcessManager
.
any
(),
fileSystem:
MemoryFileSystem
.
test
(),
featureFlags:
TestFeatureFlags
(
isWindowsEnabled:
true
),
);
// Timeout ignored.
final
List
<
Device
>
devices
=
await
windowsDevices
.
discoverDevices
(
timeout:
const
Duration
(
seconds:
10
));
...
...
packages/flutter_tools/test/src/fakes.dart
View file @
acda272c
...
...
@@ -552,6 +552,7 @@ class TestFeatureFlags implements FeatureFlags {
this
.
isIOSEnabled
=
true
,
this
.
isFuchsiaEnabled
=
false
,
this
.
isExperimentalInvalidationStrategyEnabled
=
false
,
this
.
isWindowsUwpEnabled
=
false
,
});
@override
...
...
@@ -581,6 +582,9 @@ class TestFeatureFlags implements FeatureFlags {
@override
final
bool
isExperimentalInvalidationStrategyEnabled
;
@override
final
bool
isWindowsUwpEnabled
;
@override
bool
isEnabled
(
Feature
feature
)
{
switch
(
feature
)
{
...
...
@@ -602,6 +606,8 @@ class TestFeatureFlags implements FeatureFlags {
return
isFuchsiaEnabled
;
case
experimentalInvalidationStrategy:
return
isExperimentalInvalidationStrategyEnabled
;
case
windowsUwpEmbedding:
return
isWindowsUwpEnabled
;
}
return
false
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment