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
09bdab20
Commit
09bdab20
authored
Jun 23, 2017
by
Zachary Anderson
Committed by
GitHub
Jun 23, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[fuchsia_reload] Use ssh instead of netcp/netruncmd (#10436)
parent
0426fb60
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
35 deletions
+70
-35
fuchsia_reload.dart
packages/flutter_tools/lib/src/commands/fuchsia_reload.dart
+23
-35
fuchsia_reload_test.dart
...ages/flutter_tools/test/commands/fuchsia_reload_test.dart
+47
-0
No files found.
packages/flutter_tools/lib/src/commands/fuchsia_reload.dart
View file @
09bdab20
...
...
@@ -4,12 +4,12 @@
import
'dart:async'
;
import
'dart:collection'
;
import
'dart:math'
;
import
'../base/common.dart'
;
import
'../base/file_system.dart'
;
import
'../base/io.dart'
;
import
'../base/platform.dart'
;
import
'../base/process_manager.dart'
;
import
'../base/utils.dart'
;
import
'../cache.dart'
;
import
'../device.dart'
;
...
...
@@ -70,6 +70,7 @@ class FuchsiaReloadCommand extends FlutterCommand {
final
String
description
=
'Hot reload on Fuchsia.'
;
String
_fuchsiaRoot
;
String
_buildType
;
String
_projectRoot
;
String
_projectName
;
String
_binaryName
;
...
...
@@ -278,6 +279,10 @@ class FuchsiaReloadCommand extends FlutterCommand {
if
(
_address
==
null
)
throwToolExit
(
'Give the address of the device running Fuchsia with --address.'
);
_buildType
=
argResults
[
'build-type'
];
if
(
_buildType
==
null
)
throwToolExit
(
'Give the build type with --build-type.'
);
_list
=
argResults
[
'list'
];
if
(
_list
)
{
// For --list, we only need the device address and the Fuchsia tree root.
...
...
@@ -301,11 +306,8 @@ class FuchsiaReloadCommand extends FlutterCommand {
if
(!
_fileExists
(
_target
))
throwToolExit
(
'Couldn
\'
t find application entry point at
$_target
.'
);
final
String
buildType
=
argResults
[
'build-type'
];
if
(
buildType
==
null
)
throwToolExit
(
'Give the build type with --build-type.'
);
final
String
packagesFileName
=
'
${_projectName}
_dart_package.packages'
;
_dotPackagesPath
=
'
$_fuchsiaRoot
/out/
$buildType
/gen/
$_projectRoot
/
$packagesFileName
'
;
_dotPackagesPath
=
'
$_fuchsiaRoot
/out/
$
_
buildType
/gen/
$_projectRoot
/
$packagesFileName
'
;
if
(!
_fileExists
(
_dotPackagesPath
))
throwToolExit
(
'Couldn
\'
t find .packages file at
$_dotPackagesPath
.'
);
...
...
@@ -341,7 +343,8 @@ class FuchsiaReloadCommand extends FlutterCommand {
}
Future
<
List
<
int
>>
_getServicePorts
()
async
{
final
FuchsiaDeviceCommandRunner
runner
=
new
FuchsiaDeviceCommandRunner
(
_fuchsiaRoot
);
final
FuchsiaDeviceCommandRunner
runner
=
new
FuchsiaDeviceCommandRunner
(
_address
,
_fuchsiaRoot
,
_buildType
);
final
List
<
String
>
lsOutput
=
await
runner
.
run
(
'ls /tmp/dart.services'
);
final
List
<
int
>
ports
=
<
int
>[];
for
(
String
s
in
lsOutput
)
{
...
...
@@ -369,41 +372,26 @@ class FuchsiaReloadCommand extends FlutterCommand {
}
// TODO(zra): When Fuchsia has ssh, this should be changed to use that instead.
class
FuchsiaDeviceCommandRunner
{
// TODO(zra): Get rid of _address and instead use
// $_fuchsiaRoot/out/build-magenta/tools/netaddr --fuchsia
final
String
_address
;
final
String
_buildType
;
final
String
_fuchsiaRoot
;
final
Random
_rng
=
new
Random
(
new
DateTime
.
now
().
millisecondsSinceEpoch
);
FuchsiaDeviceCommandRunner
(
this
.
_
fuchsiaRoot
);
FuchsiaDeviceCommandRunner
(
this
.
_
address
,
this
.
_fuchsiaRoot
,
this
.
_buildType
);
Future
<
List
<
String
>>
run
(
String
command
)
async
{
final
int
tag
=
_rng
.
nextInt
(
999999
);
const
String
kNetRunCommand
=
'out/build-magenta/tools/netruncmd'
;
final
String
netruncmd
=
fs
.
path
.
join
(
_fuchsiaRoot
,
kNetRunCommand
);
const
String
kNetCP
=
'out/build-magenta/tools/netcp'
;
final
String
netcp
=
fs
.
path
.
join
(
_fuchsiaRoot
,
kNetCP
);
final
String
remoteStdout
=
'/tmp/netruncmd.
$tag
'
;
final
String
localStdout
=
'
${fs.systemTempDirectory.path}
/netruncmd.
$tag
'
;
final
String
redirectedCommand
=
'
$command
>
$remoteStdout
'
;
// Run the command with output directed to a tmp file.
ProcessResult
result
=
await
Process
.
run
(
netruncmd
,
<
String
>[
':'
,
redirectedCommand
]);
if
(
result
.
exitCode
!=
0
)
final
String
config
=
'
$_fuchsiaRoot
/out/
$_buildType
/ssh-keys/ssh_config'
;
final
List
<
String
>
args
=
<
String
>[
'-F'
,
config
,
_address
,
command
];
printTrace
(
'ssh
${args.join(' ')}
'
);
final
ProcessResult
result
=
await
processManager
.
run
(<
String
>[
'ssh'
,
'-F'
,
config
,
_address
,
command
]);
if
(
result
.
exitCode
!=
0
)
{
printStatus
(
"Command failed:
$command
\n
stdout:
${result.stdout}
\n
stderr:
${result.stderr}
"
);
return
null
;
// Copy that file to the local filesystem.
result
=
await
Process
.
run
(
netcp
,
<
String
>[
':
$remoteStdout
'
,
localStdout
]);
// Try to delete the remote file. Don't care about the result;
Process
.
run
(
netruncmd
,
<
String
>[
':'
,
'rm
$remoteStdout
'
]);
if
(
result
.
exitCode
!=
0
)
return
null
;
// Read the local file.
final
File
f
=
fs
.
file
(
localStdout
);
List
<
String
>
lines
;
try
{
lines
=
await
f
.
readAsLines
();
}
finally
{
f
.
delete
();
}
return
lines
;
printTrace
(
result
.
stdout
);
return
result
.
stdout
.
split
(
'
\n
'
);
}
}
packages/flutter_tools/test/commands/fuchsia_reload_test.dart
0 → 100644
View file @
09bdab20
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:convert'
;
import
'dart:io'
;
import
'package:flutter_tools/src/commands/fuchsia_reload.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:process/process.dart'
;
import
'package:test/test.dart'
;
import
'../src/context.dart'
;
void
main
(
)
{
group
(
'FuchsiaDeviceCommandRunner'
,
()
{
testUsingContext
(
'a test'
,
()
async
{
final
FuchsiaDeviceCommandRunner
commandRunner
=
new
FuchsiaDeviceCommandRunner
(
'8.8.9.9'
,
'~/fuchsia'
,
'release-x86-64'
);
final
List
<
String
>
ports
=
await
commandRunner
.
run
(
'ls /tmp'
);
expect
(
ports
,
hasLength
(
3
));
expect
(
ports
[
0
],
equals
(
'1234'
));
expect
(
ports
[
1
],
equals
(
'5678'
));
expect
(
ports
[
2
],
equals
(
'5'
));
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
new
MockProcessManager
(),
});
});
}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{
@override
Future
<
ProcessResult
>
run
(
List
<
dynamic
>
command
,
{
String
workingDirectory
,
Map
<
String
,
String
>
environment
,
bool
includeParentEnvironment:
true
,
bool
runInShell:
false
,
Encoding
stdoutEncoding:
SYSTEM_ENCODING
,
Encoding
stderrEncoding:
SYSTEM_ENCODING
,
})
async
{
return
new
ProcessResult
(
0
,
0
,
'1234
\n
5678
\n
5'
,
''
);
}
}
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