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
c9ca7c49
Unverified
Commit
c9ca7c49
authored
Oct 16, 2018
by
Jonah Williams
Committed by
GitHub
Oct 16, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add override frontend_server snapshot for fuchsia_reload command (#23162)
parent
fd02bdf1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
99 additions
and
64 deletions
+99
-64
artifacts.dart
packages/flutter_tools/lib/src/artifacts.dart
+28
-0
fuchsia_reload.dart
packages/flutter_tools/lib/src/commands/fuchsia_reload.dart
+71
-64
No files found.
packages/flutter_tools/lib/src/artifacts.dart
View file @
c9ca7c49
...
...
@@ -299,3 +299,31 @@ class LocalEngineArtifacts extends Artifacts {
throw
Exception
(
'Unsupported platform
$platform
.'
);
}
}
/// An implementation of [Artifacts] that provides individual overrides.
///
/// If an artifact is not provided, the lookup delegates to the parent.
/// Currently only allows overriding the location of the [frontendServer].
class
OverrideArtifacts
implements
Artifacts
{
/// Creates a new [OverrideArtifacts].
///
/// [parent] must be provided.
OverrideArtifacts
({
@required
this
.
parent
,
this
.
frontendServer
,
})
:
assert
(
parent
!=
null
);
final
Artifacts
parent
;
final
File
frontendServer
;
@override
String
getArtifactPath
(
Artifact
artifact
,
[
TargetPlatform
platform
,
BuildMode
mode
])
{
if
(
artifact
==
Artifact
.
frontendServerSnapshotForEngineDartSdk
&&
frontendServer
!=
null
)
{
return
frontendServer
.
path
;
}
return
parent
.
getArtifactPath
(
artifact
,
platform
,
mode
);
}
@override
String
getEngineType
(
TargetPlatform
platform
,
[
BuildMode
mode
])
=>
parent
.
getEngineType
(
platform
,
mode
);
}
packages/flutter_tools/lib/src/commands/fuchsia_reload.dart
View file @
c9ca7c49
...
...
@@ -6,7 +6,9 @@ import 'dart:async';
import
'dart:collection'
;
import
'dart:convert'
;
import
'../artifacts.dart'
;
import
'../base/common.dart'
;
import
'../base/context.dart'
;
import
'../base/file_system.dart'
;
import
'../base/io.dart'
;
import
'../base/process_manager.dart'
;
...
...
@@ -14,6 +16,7 @@ import '../base/terminal.dart';
import
'../base/utils.dart'
;
import
'../bundle.dart'
as
bundle
;
import
'../cache.dart'
;
import
'../context_runner.dart'
;
import
'../device.dart'
;
import
'../fuchsia/fuchsia_device.dart'
;
import
'../globals.dart'
;
...
...
@@ -43,6 +46,9 @@ final String ipv4Loopback = InternetAddress.loopbackIPv4.address;
class
FuchsiaReloadCommand
extends
FlutterCommand
{
FuchsiaReloadCommand
()
{
addBuildModeFlags
(
defaultToRelease:
false
);
argParser
.
addOption
(
'frontend-server'
,
abbr:
'f'
,
help:
'The frontend server location'
);
argParser
.
addOption
(
'address'
,
abbr:
'a'
,
help:
'Fuchsia device network name or address.'
);
...
...
@@ -98,79 +104,75 @@ class FuchsiaReloadCommand extends FlutterCommand {
String
_address
;
String
_dotPackagesPath
;
String
_sshConfig
;
File
_frontendServerSnapshot
;
bool
_list
;
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Cache
.
releaseLockEarly
();
await
_validateArguments
();
await
runInContext
<
void
>(()
async
{
// Find the network ports used on the device by VM service instances.
final
List
<
int
>
deviceServicePorts
=
await
_getServicePorts
();
if
(
deviceServicePorts
.
isEmpty
)
throwToolExit
(
'Couldn
\'
t find any running Observatory instances.'
);
for
(
int
port
in
deviceServicePorts
)
printTrace
(
'Fuchsia service port:
$port
'
);
// Set up ssh tunnels to forward the device ports to local ports.
final
List
<
_PortForwarder
>
forwardedPorts
=
await
_forwardPorts
(
deviceServicePorts
);
// Wrap everything in try/finally to make sure we kill the ssh processes
// doing the port forwarding.
try
{
final
List
<
int
>
servicePorts
=
forwardedPorts
.
map
<
int
>((
_PortForwarder
pf
)
=>
pf
.
port
).
toList
();
if
(
_list
)
{
await
_listVMs
(
servicePorts
);
// Port forwarding stops when the command ends. Keep the program running
// until directed by the user so that Observatory URLs that we print
// continue to work.
printStatus
(
'Press Enter to exit.'
);
await
stdin
.
first
;
return
null
;
}
// Find the network ports used on the device by VM service instances.
final
List
<
int
>
deviceServicePorts
=
await
_getServicePorts
();
if
(
deviceServicePorts
.
isEmpty
)
throwToolExit
(
'Couldn
\'
t find any running Observatory instances.'
);
for
(
int
port
in
deviceServicePorts
)
printTrace
(
'Fuchsia service port:
$port
'
);
// Set up ssh tunnels to forward the device ports to local ports.
final
List
<
_PortForwarder
>
forwardedPorts
=
await
_forwardPorts
(
deviceServicePorts
);
// Wrap everything in try/finally to make sure we kill the ssh processes
// doing the port forwarding.
try
{
final
List
<
int
>
servicePorts
=
forwardedPorts
.
map
<
int
>(
(
_PortForwarder
pf
)
=>
pf
.
port
).
toList
();
if
(
_list
)
{
await
_listVMs
(
servicePorts
);
// Port forwarding stops when the command ends. Keep the program running
// until directed by the user so that Observatory URLs that we print
// continue to work.
printStatus
(
'Press Enter to exit.'
);
await
stdin
.
first
;
return
null
;
// Check that there are running VM services on the returned
// ports, and find the Isolates that are running the target app.
final
String
isolateName
=
'
$_modName
\
$main$_isolateNumber
'
;
final
List
<
int
>
targetPorts
=
await
_filterPorts
(
servicePorts
,
isolateName
);
if
(
targetPorts
.
isEmpty
)
throwToolExit
(
'No VMs found running
$_modName
.'
);
for
(
int
port
in
targetPorts
)
printTrace
(
'Found
$_modName
at
$port
'
);
// Set up a device and hot runner and attach the hot runner to the first
// vm service we found.
final
List
<
String
>
fullAddresses
=
targetPorts
.
map
<
String
>((
int
p
)
=>
'
$ipv4Loopback
:
$p
'
).
toList
();
final
List
<
Uri
>
observatoryUris
=
fullAddresses
.
map
<
Uri
>((
String
a
)
=>
Uri
.
parse
(
'http://
$a
'
))
.
toList
();
final
FuchsiaDevice
device
=
FuchsiaDevice
(
fullAddresses
[
0
],
name:
_address
);
final
FlutterDevice
flutterDevice
=
FlutterDevice
(
device
,
trackWidgetCreation:
false
,
);
flutterDevice
.
observatoryUris
=
observatoryUris
;
final
HotRunner
hotRunner
=
HotRunner
(<
FlutterDevice
>[
flutterDevice
],
debuggingOptions:
DebuggingOptions
.
enabled
(
getBuildInfo
()),
target:
_target
,
projectRootPath:
_fuchsiaProjectPath
,
packagesFilePath:
_dotPackagesPath
);
printStatus
(
'Connecting to
$_modName
'
);
await
hotRunner
.
attach
(
viewFilter:
isolateName
);
}
finally
{
await
Future
.
wait
<
void
>(
forwardedPorts
.
map
<
Future
<
void
>>((
_PortForwarder
pf
)
=>
pf
.
stop
()));
}
// Check that there are running VM services on the returned
// ports, and find the Isolates that are running the target app.
final
String
isolateName
=
'
$_modName
\
$main$_isolateNumber
'
;
final
List
<
int
>
targetPorts
=
await
_filterPorts
(
servicePorts
,
isolateName
);
if
(
targetPorts
.
isEmpty
)
throwToolExit
(
'No VMs found running
$_modName
.'
);
for
(
int
port
in
targetPorts
)
printTrace
(
'Found
$_modName
at
$port
'
);
// Set up a device and hot runner and attach the hot runner to the first
// vm service we found.
final
List
<
String
>
fullAddresses
=
targetPorts
.
map
<
String
>(
(
int
p
)
=>
'
$ipv4Loopback
:
$p
'
).
toList
();
final
List
<
Uri
>
observatoryUris
=
fullAddresses
.
map
<
Uri
>(
(
String
a
)
=>
Uri
.
parse
(
'http://
$a
'
)
).
toList
();
final
FuchsiaDevice
device
=
FuchsiaDevice
(
fullAddresses
[
0
],
name:
_address
);
final
FlutterDevice
flutterDevice
=
FlutterDevice
(
device
,
trackWidgetCreation:
false
,
);
flutterDevice
.
observatoryUris
=
observatoryUris
;
final
HotRunner
hotRunner
=
HotRunner
(
<
FlutterDevice
>[
flutterDevice
],
debuggingOptions:
DebuggingOptions
.
enabled
(
getBuildInfo
()),
target:
_target
,
projectRootPath:
_fuchsiaProjectPath
,
packagesFilePath:
_dotPackagesPath
);
printStatus
(
'Connecting to
$_modName
'
);
await
hotRunner
.
attach
(
viewFilter:
isolateName
);
}
finally
{
await
Future
.
wait
<
void
>(
forwardedPorts
.
map
<
Future
<
void
>>((
_PortForwarder
pf
)
=>
pf
.
stop
()));
}
},
overrides:
<
Type
,
Generator
>{
Artifacts:
()
=>
OverrideArtifacts
(
parent:
artifacts
,
frontendServer:
_frontendServerSnapshot
),
});
return
null
;
}
...
...
@@ -300,6 +302,11 @@ class FuchsiaReloadCommand extends FlutterCommand {
Future
<
void
>
_validateArguments
()
async
{
final
String
fuchsiaBuildDir
=
argResults
[
'build-dir'
];
final
String
gnTarget
=
argResults
[
'gn-target'
];
_frontendServerSnapshot
=
fs
.
file
(
argResults
[
'frontend-server'
]);
if
(!
_frontendServerSnapshot
.
existsSync
())
{
throwToolExit
(
'Must provide a frontend-server snapshot'
);
}
if
(
fuchsiaBuildDir
!=
null
)
{
if
(
gnTarget
==
null
)
...
...
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