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
61236c87
Unverified
Commit
61236c87
authored
May 06, 2019
by
Zachary Anderson
Committed by
GitHub
May 06, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tool] In 'attach' use platform dill and patched sdk dir from the Fuchsia SDK (#32071)
parent
dd5d0d6c
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
156 additions
and
43 deletions
+156
-43
attach.dart
packages/flutter_tools/lib/src/commands/attach.dart
+15
-3
device.dart
packages/flutter_tools/lib/src/device.dart
+4
-0
fuchsia_device.dart
packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
+11
-0
fuchsia_sdk.dart
packages/flutter_tools/lib/src/fuchsia/fuchsia_sdk.dart
+18
-2
fuchsa_device_test.dart
packages/flutter_tools/test/fuchsia/fuchsa_device_test.dart
+108
-38
No files found.
packages/flutter_tools/lib/src/commands/attach.dart
View file @
61236c87
...
...
@@ -6,7 +6,9 @@ import 'dart:async';
import
'package:multicast_dns/multicast_dns.dart'
;
import
'../artifacts.dart'
;
import
'../base/common.dart'
;
import
'../base/context.dart'
;
import
'../base/file_system.dart'
;
import
'../base/io.dart'
;
import
'../base/utils.dart'
;
...
...
@@ -160,8 +162,6 @@ class AttachCommand extends FlutterCommand {
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
final
FlutterProject
flutterProject
=
FlutterProject
.
current
();
Cache
.
releaseLockEarly
();
await
_validateArguments
();
...
...
@@ -169,6 +169,19 @@ class AttachCommand extends FlutterCommand {
writePidFile
(
argResults
[
'pid-file'
]);
final
Device
device
=
await
findTargetDevice
();
final
Artifacts
artifacts
=
device
.
artifactOverrides
??
Artifacts
.
instance
;
await
context
.
run
<
void
>(
body:
()
=>
_attachToDevice
(
device
),
overrides:
<
Type
,
Generator
>{
Artifacts:
()
=>
artifacts
,
});
return
null
;
}
Future
<
void
>
_attachToDevice
(
Device
device
)
async
{
final
FlutterProject
flutterProject
=
FlutterProject
.
current
();
Future
<
int
>
getDevicePort
()
async
{
if
(
debugPort
!=
null
)
{
return
debugPort
;
...
...
@@ -310,7 +323,6 @@ class AttachCommand extends FlutterCommand {
await
device
.
portForwarder
.
unforward
(
port
);
}
}
return
null
;
}
Future
<
void
>
_validateArguments
()
async
{
}
...
...
packages/flutter_tools/lib/src/device.dart
View file @
61236c87
...
...
@@ -7,6 +7,7 @@ import 'dart:math' as math;
import
'android/android_device.dart'
;
import
'application_package.dart'
;
import
'artifacts.dart'
;
import
'base/context.dart'
;
import
'base/file_system.dart'
;
import
'base/utils.dart'
;
...
...
@@ -274,6 +275,9 @@ abstract class Device {
/// Clear the device's logs.
void
clearLogs
();
/// Optional device-specific artifact overrides.
OverrideArtifacts
get
artifactOverrides
=>
null
;
/// Start an app package on the current device.
///
/// [platformArgs] allows callers to pass platform-specific arguments to the
...
...
packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
View file @
61236c87
...
...
@@ -7,6 +7,7 @@ import 'dart:async';
import
'package:meta/meta.dart'
;
import
'../application_package.dart'
;
import
'../artifacts.dart'
;
import
'../base/common.dart'
;
import
'../base/io.dart'
;
import
'../base/logger.dart'
;
...
...
@@ -223,6 +224,16 @@ class FuchsiaDevice extends Device {
@override
void
clearLogs
()
{}
@override
OverrideArtifacts
get
artifactOverrides
{
return
_artifactOverrides
??=
OverrideArtifacts
(
parent:
Artifacts
.
instance
,
platformKernelDill:
fuchsiaArtifacts
.
platformKernelDill
,
flutterPatchedSdk:
fuchsiaArtifacts
.
flutterPatchedSdk
,
);
}
OverrideArtifacts
_artifactOverrides
;
@override
bool
get
supportsScreenshot
=>
false
;
...
...
packages/flutter_tools/lib/src/fuchsia/fuchsia_sdk.dart
View file @
61236c87
...
...
@@ -81,7 +81,12 @@ class FuchsiaSdk {
/// Fuchsia-specific artifacts used to interact with a device.
class
FuchsiaArtifacts
{
/// Creates a new [FuchsiaArtifacts].
FuchsiaArtifacts
({
this
.
sshConfig
,
this
.
devFinder
});
FuchsiaArtifacts
({
this
.
sshConfig
,
this
.
devFinder
,
this
.
platformKernelDill
,
this
.
flutterPatchedSdk
,
});
/// Creates a new [FuchsiaArtifacts] using the cached Fuchsia SDK.
///
...
...
@@ -92,6 +97,7 @@ class FuchsiaArtifacts {
factory
FuchsiaArtifacts
.
find
()
{
final
String
fuchsia
=
Cache
.
instance
.
getArtifactDirectory
(
'fuchsia'
).
path
;
final
String
tools
=
fs
.
path
.
join
(
fuchsia
,
'tools'
);
final
String
dartPrebuilts
=
fs
.
path
.
join
(
tools
,
'dart_prebuilts'
);
// If FUCHSIA_BUILD_DIR is defined, then look for the ssh_config dir
// relative to it. Next, if FUCHSIA_SSH_CONFIG is defined, then use it.
...
...
@@ -99,13 +105,17 @@ class FuchsiaArtifacts {
File
sshConfig
;
if
(
platform
.
environment
.
containsKey
(
_kFuchsiaBuildDir
))
{
sshConfig
=
fs
.
file
(
fs
.
path
.
join
(
platform
.
environment
[
_kFuchsia
SshConfig
],
'ssh-keys'
,
'ssh_config'
));
platform
.
environment
[
_kFuchsia
BuildDir
],
'ssh-keys'
,
'ssh_config'
));
}
else
if
(
platform
.
environment
.
containsKey
(
_kFuchsiaSshConfig
))
{
sshConfig
=
fs
.
file
(
platform
.
environment
[
_kFuchsiaSshConfig
]);
}
return
FuchsiaArtifacts
(
sshConfig:
sshConfig
,
devFinder:
fs
.
file
(
fs
.
path
.
join
(
tools
,
'dev_finder'
)),
platformKernelDill:
fs
.
file
(
fs
.
path
.
join
(
dartPrebuilts
,
'flutter_runner'
,
'platform_strong.dill'
)),
flutterPatchedSdk:
fs
.
file
(
fs
.
path
.
join
(
dartPrebuilts
,
'flutter_runner'
)),
);
}
...
...
@@ -119,4 +129,10 @@ class FuchsiaArtifacts {
/// The location of the dev finder tool used to locate connected
/// Fuchsia devices.
final
File
devFinder
;
/// The location of the Fuchsia-specific platform dill.
final
File
platformKernelDill
;
/// The directory containing [platformKernelDill].
final
File
flutterPatchedSdk
;
}
packages/flutter_tools/test/fuchsia/fuchsa_device_test.dart
View file @
61236c87
...
...
@@ -10,7 +10,9 @@ import 'package:flutter_tools/src/vmservice.dart';
import
'package:mockito/mockito.dart'
;
import
'package:process/process.dart'
;
import
'package:flutter_tools/src/artifacts.dart'
;
import
'package:flutter_tools/src/base/common.dart'
;
import
'package:flutter_tools/src/base/context.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/time.dart'
;
...
...
@@ -58,10 +60,74 @@ void main() {
});
});
group
(
'Fuchsia device artifact overrides'
,
()
{
MockFile
devFinder
;
MockFile
sshConfig
;
MockFile
platformDill
;
MockFile
patchedSdk
;
setUp
(()
{
devFinder
=
MockFile
();
sshConfig
=
MockFile
();
platformDill
=
MockFile
();
patchedSdk
=
MockFile
();
when
(
devFinder
.
absolute
).
thenReturn
(
devFinder
);
when
(
sshConfig
.
absolute
).
thenReturn
(
sshConfig
);
when
(
platformDill
.
absolute
).
thenReturn
(
platformDill
);
when
(
patchedSdk
.
absolute
).
thenReturn
(
patchedSdk
);
});
testUsingContext
(
'exist'
,
()
async
{
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'fuchsia-device'
);
expect
(
device
.
artifactOverrides
,
isNotNull
);
expect
(
device
.
artifactOverrides
.
platformKernelDill
,
equals
(
platformDill
));
expect
(
device
.
artifactOverrides
.
flutterPatchedSdk
,
equals
(
patchedSdk
));
},
overrides:
<
Type
,
Generator
>{
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
sshConfig
,
devFinder:
devFinder
,
platformKernelDill:
platformDill
,
flutterPatchedSdk:
patchedSdk
,
),
});
testUsingContext
(
'are used'
,
()
async
{
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'fuchsia-device'
);
expect
(
device
.
artifactOverrides
,
isNotNull
);
expect
(
device
.
artifactOverrides
.
platformKernelDill
,
equals
(
platformDill
));
expect
(
device
.
artifactOverrides
.
flutterPatchedSdk
,
equals
(
patchedSdk
));
await
context
.
run
<
void
>(
body:
()
{
expect
(
Artifacts
.
instance
.
getArtifactPath
(
Artifact
.
platformKernelDill
),
equals
(
platformDill
.
path
));
expect
(
Artifacts
.
instance
.
getArtifactPath
(
Artifact
.
flutterPatchedSdkPath
),
equals
(
patchedSdk
.
path
));
},
overrides:
<
Type
,
Generator
>{
Artifacts:
()
=>
device
.
artifactOverrides
,
},
);
},
overrides:
<
Type
,
Generator
>{
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
sshConfig
,
devFinder:
devFinder
,
platformKernelDill:
platformDill
,
flutterPatchedSdk:
patchedSdk
,
),
});
});
group
(
'displays friendly error when'
,
()
{
final
MockProcessManager
mockProcessManager
=
MockProcessManager
();
final
MockProcessResult
mockProcessResult
=
MockProcessResult
();
final
MockFile
mockFile
=
MockFile
();
MockProcessManager
mockProcessManager
;
MockProcessResult
mockProcessResult
;
MockFile
mockFile
;
MockProcessManager
emptyStdoutProcessManager
;
MockProcessResult
emptyStdoutProcessResult
;
setUp
(()
{
mockProcessManager
=
MockProcessManager
();
mockProcessResult
=
MockProcessResult
();
mockFile
=
MockFile
();
when
(
mockProcessManager
.
run
(
any
,
environment:
anyNamed
(
'environment'
),
...
...
@@ -74,8 +140,8 @@ void main() {
when
(
mockFile
.
absolute
).
thenReturn
(
mockFile
);
when
(
mockFile
.
path
).
thenReturn
(
''
);
final
MockProcessManager
emptyStdoutProcessManager
=
MockProcessManager
();
final
MockProcessResult
emptyStdoutProcessResult
=
MockProcessResult
();
emptyStdoutProcessManager
=
MockProcessManager
();
emptyStdoutProcessResult
=
MockProcessResult
();
when
(
emptyStdoutProcessManager
.
run
(
any
,
environment:
anyNamed
(
'environment'
),
...
...
@@ -85,6 +151,7 @@ void main() {
when
(
emptyStdoutProcessResult
.
exitCode
).
thenReturn
(
0
);
when
<
String
>(
emptyStdoutProcessResult
.
stdout
).
thenReturn
(
''
);
when
<
String
>(
emptyStdoutProcessResult
.
stderr
).
thenReturn
(
''
);
});
testUsingContext
(
'No vmservices found'
,
()
async
{
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'id'
);
...
...
@@ -116,26 +183,29 @@ void main() {
[2018-11-09 01:30:12][52580][52983][log] INFO: example_app.cmx(flutter): Did thing this time
'''
;
final
MockProcessManager
mockProcessManager
=
MockProcessManager
()
;
final
MockProcess
mockProcess
=
MockProcess
()
;
MockProcessManager
mockProcessManager
;
MockProcess
mockProcess
;
Completer
<
int
>
exitCode
;
StreamController
<
List
<
int
>>
stdout
;
StreamController
<
List
<
int
>>
stderr
;
MockFile
devFinder
;
MockFile
sshConfig
;
setUp
(()
{
mockProcessManager
=
MockProcessManager
();
mockProcess
=
MockProcess
();
stdout
=
StreamController
<
List
<
int
>>(
sync:
true
);
stderr
=
StreamController
<
List
<
int
>>(
sync:
true
);
exitCode
=
Completer
<
int
>();
when
(
mockProcessManager
.
start
(
any
))
.
thenAnswer
((
Invocation
_
)
=>
Future
<
Process
>.
value
(
mockProcess
));
when
(
mockProcess
.
exitCode
).
thenAnswer
((
Invocation
_
)
=>
exitCode
.
future
);
when
(
mockProcess
.
stdout
).
thenAnswer
((
Invocation
_
)
=>
stdout
.
stream
);
when
(
mockProcess
.
stderr
).
thenAnswer
((
Invocation
_
)
=>
stderr
.
stream
);
final
MockFile
devFinder
=
MockFile
();
final
MockFile
sshConfig
=
MockFile
();
devFinder
=
MockFile
();
sshConfig
=
MockFile
();
when
(
devFinder
.
absolute
).
thenReturn
(
devFinder
);
when
(
sshConfig
.
absolute
).
thenReturn
(
sshConfig
);
setUp
(()
{
stdout
=
StreamController
<
List
<
int
>>(
sync:
true
);
stderr
=
StreamController
<
List
<
int
>>(
sync:
true
);
exitCode
=
Completer
<
int
>();
});
tearDown
(()
{
...
...
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