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
925a52fa
Unverified
Commit
925a52fa
authored
Sep 12, 2019
by
Jonah Williams
Committed by
GitHub
Sep 12, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add host and port to run configuration for web devices (#40191)
parent
f174c0e2
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
66 additions
and
10 deletions
+66
-10
resident_web_runner.dart
...utter_tools/lib/src/build_runner/resident_web_runner.dart
+4
-2
web_fs.dart
packages/flutter_tools/lib/src/build_runner/web_fs.dart
+11
-7
run.dart
packages/flutter_tools/lib/src/commands/run.dart
+3
-0
device.dart
packages/flutter_tools/lib/src/device.dart
+6
-0
flutter_command.dart
packages/flutter_tools/lib/src/runner/flutter_command.dart
+14
-0
web_device.dart
packages/flutter_tools/lib/src/web/web_device.dart
+1
-1
resident_web_runner_cold_test.dart
...ols/test/general.shard/resident_web_runner_cold_test.dart
+2
-0
resident_web_runner_test.dart
...er_tools/test/general.shard/resident_web_runner_test.dart
+2
-0
web_fs_test.dart
...ges/flutter_tools/test/general.shard/web/web_fs_test.dart
+23
-0
No files found.
packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart
View file @
925a52fa
...
...
@@ -168,9 +168,11 @@ class ResidentWebRunner extends ResidentRunner {
target:
target
,
flutterProject:
flutterProject
,
buildInfo:
debuggingOptions
.
buildInfo
,
skipDwds:
device
is
WebDevices
,
hostname:
debuggingOptions
.
hostname
,
port:
debuggingOptions
.
port
,
skipDwds:
device
is
WebServerDevice
,
);
await
device
.
startApp
(
package
,
mainPath:
target
,
platformArgs:
<
String
,
Object
>{
await
device
.
startApp
(
package
,
mainPath:
target
,
debuggingOptions:
debuggingOptions
,
platformArgs:
<
String
,
Object
>{
'uri'
:
_webFs
.
uri
});
if
(
supportsServiceProtocol
)
{
...
...
packages/flutter_tools/lib/src/build_runner/web_fs.dart
View file @
925a52fa
...
...
@@ -75,6 +75,8 @@ typedef WebFsFactory = Future<WebFs> Function({
@required
FlutterProject
flutterProject
,
@required
BuildInfo
buildInfo
,
@required
bool
skipDwds
,
@required
String
hostname
,
@required
String
port
,
});
/// The dev filesystem responsible for building and serving web applications.
...
...
@@ -104,10 +106,10 @@ class WebFs {
await
_connectedApps
?.
cancel
();
}
/// Retrieve the [DebugConnection] for the current application
.
/// Retrieve the [DebugConnection] for the current application
Future
<
DebugConnection
>
runAndDebug
()
{
final
Completer
<
DebugConnection
>
firstConnection
=
Completer
<
DebugConnection
>();
_connectedApps
=
_dwds
.
connectedApps
.
listen
((
AppConnection
appConnection
)
async
{
_connectedApps
=
_dwds
.
connectedApps
.
listen
((
AppConnection
appConnection
)
async
{
appConnection
.
runMain
();
final
DebugConnection
debugConnection
=
await
_dwds
.
debugConnection
(
appConnection
);
if
(!
firstConnection
.
isCompleted
)
{
...
...
@@ -140,6 +142,8 @@ class WebFs {
@required
FlutterProject
flutterProject
,
@required
BuildInfo
buildInfo
,
@required
bool
skipDwds
,
@required
String
hostname
,
@required
String
port
,
})
async
{
// workaround for https://github.com/flutter/flutter/issues/38290
if
(!
flutterProject
.
dartTool
.
existsSync
())
{
...
...
@@ -165,7 +169,7 @@ class WebFs {
await
writeBundle
(
fs
.
directory
(
getAssetBuildDirectory
()),
assetBundle
.
entries
);
// Initialize the dwds server.
final
int
port
=
await
os
.
findFreePort
(
);
final
int
hostPort
=
port
==
null
?
await
os
.
findFreePort
()
:
int
.
tryParse
(
port
);
// Map the bootstrap files to the correct package directory.
final
String
targetBaseName
=
fs
.
path
.
withoutExtension
(
target
).
replaceFirst
(
'lib
${fs.path.separator}
'
,
''
);
...
...
@@ -203,8 +207,8 @@ class WebFs {
Dwds
dwds
;
if
(!
skipDwds
)
{
dwds
=
await
dwdsFactory
(
hostname:
_kHostName
,
applicationPort:
p
ort
,
hostname:
hostname
??
_kHostName
,
applicationPort:
hostP
ort
,
applicationTarget:
kBuildTargetName
,
assetServerPort:
daemonAssetPort
,
buildResults:
filteredBuildResults
,
...
...
@@ -224,13 +228,13 @@ class WebFs {
Cascade
cascade
=
Cascade
();
cascade
=
cascade
.
add
(
handler
);
cascade
=
cascade
.
add
(
_assetHandler
(
flutterProject
));
final
HttpServer
server
=
await
httpMultiServerFactory
(
_kHostName
,
p
ort
);
final
HttpServer
server
=
await
httpMultiServerFactory
(
hostname
??
_kHostName
,
hostP
ort
);
shelf_io
.
serveRequests
(
server
,
cascade
.
handler
);
return
WebFs
(
client
,
server
,
dwds
,
'http://
$_kHostName
:
$
p
ort
/'
,
'http://
$_kHostName
:
$
hostP
ort
/'
,
);
}
...
...
packages/flutter_tools/lib/src/commands/run.dart
View file @
925a52fa
...
...
@@ -44,6 +44,7 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
..
addOption
(
'route'
,
help:
'Which route to load when running the app.'
,
);
usesWebOptions
(
hide:
!
verboseHelp
);
usesTargetOption
();
usesPortOptions
();
usesIpv6Flag
();
...
...
@@ -288,6 +289,8 @@ class RunCommand extends RunCommandBase {
dumpSkpOnShaderCompilation:
argResults
[
'dump-skp-on-shader-compilation'
],
observatoryPort:
observatoryPort
,
verboseSystemLogs:
argResults
[
'verbose-system-logs'
],
hostname:
featureFlags
.
isWebEnabled
?
argResults
[
'hostname'
]
:
''
,
port:
featureFlags
.
isWebEnabled
?
argResults
[
'port'
]
:
''
,
);
}
}
...
...
packages/flutter_tools/lib/src/device.dart
View file @
925a52fa
...
...
@@ -484,6 +484,8 @@ class DebuggingOptions {
this
.
useTestFonts
=
false
,
this
.
verboseSystemLogs
=
false
,
this
.
observatoryPort
,
this
.
hostname
,
this
.
port
,
})
:
debuggingEnabled
=
true
;
DebuggingOptions
.
disabled
(
this
.
buildInfo
)
...
...
@@ -498,6 +500,8 @@ class DebuggingOptions {
traceSystrace
=
false
,
dumpSkpOnShaderCompilation
=
false
,
verboseSystemLogs
=
false
,
hostname
=
null
,
port
=
null
,
observatoryPort
=
null
;
final
bool
debuggingEnabled
;
...
...
@@ -514,6 +518,8 @@ class DebuggingOptions {
final
bool
useTestFonts
;
final
bool
verboseSystemLogs
;
final
int
observatoryPort
;
final
String
port
;
final
String
hostname
;
bool
get
hasObservatoryPort
=>
observatoryPort
!=
null
;
}
...
...
packages/flutter_tools/lib/src/runner/flutter_command.dart
View file @
925a52fa
...
...
@@ -132,6 +132,20 @@ abstract class FlutterCommand extends Command<void> {
_requiresPubspecYaml
=
true
;
}
void
usesWebOptions
({
bool
hide
=
true
})
{
argParser
.
addOption
(
'hostname'
,
defaultsTo:
'localhost'
,
help:
'The hostname to serve web application on.'
,
hide:
hide
,
);
argParser
.
addOption
(
'port'
,
defaultsTo:
null
,
help:
'The host port to serve the web application from. If not provided, the tool '
'will select a random open port on the host.'
,
hide:
hide
,
);
}
void
usesTargetOption
()
{
argParser
.
addOption
(
'target'
,
abbr:
't'
,
...
...
packages/flutter_tools/lib/src/web/web_device.dart
View file @
925a52fa
...
...
@@ -137,7 +137,7 @@ class ChromeDevice extends Device {
@override
Future
<
bool
>
stopApp
(
ApplicationPackage
app
)
async
{
await
_chrome
.
close
();
await
_chrome
?
.
close
();
return
true
;
}
...
...
packages/flutter_tools/test/general.shard/resident_web_runner_cold_test.dart
View file @
925a52fa
...
...
@@ -43,6 +43,8 @@ void main() {
@required
FlutterProject
flutterProject
,
@required
BuildInfo
buildInfo
,
@required
bool
skipDwds
,
@required
String
hostname
,
@required
String
port
,
})
async
{
return
mockWebFs
;
},
...
...
packages/flutter_tools/test/general.shard/resident_web_runner_test.dart
View file @
925a52fa
...
...
@@ -52,6 +52,8 @@ void main() {
@required
FlutterProject
flutterProject
,
@required
BuildInfo
buildInfo
,
@required
bool
skipDwds
,
@required
String
hostname
,
@required
String
port
,
})
async
{
return
mockWebFs
;
},
...
...
packages/flutter_tools/test/general.shard/web/web_fs_test.dart
View file @
925a52fa
...
...
@@ -26,8 +26,12 @@ void main() {
MockHttpMultiServer
mockHttpMultiServer
;
MockBuildDaemonClient
mockBuildDaemonClient
;
MockOperatingSystemUtils
mockOperatingSystemUtils
;
dynamic
lastAddress
;
int
lastPort
;
setUp
(()
{
lastAddress
=
null
;
lastPort
=
null
;
mockBuildDaemonCreator
=
MockBuildDaemonCreator
();
mockChromeLauncher
=
MockChromeLauncher
();
mockHttpMultiServer
=
MockHttpMultiServer
();
...
...
@@ -56,6 +60,8 @@ void main() {
BuildDaemonCreator:
()
=>
mockBuildDaemonCreator
,
ChromeLauncher:
()
=>
mockChromeLauncher
,
HttpMultiServerFactory:
()
=>
(
dynamic
address
,
int
port
)
async
{
lastAddress
=
address
;
lastPort
=
port
;
return
mockHttpMultiServer
;
},
DwdsFactory:
()
=>
({
...
...
@@ -83,6 +89,8 @@ void main() {
target:
fs
.
path
.
join
(
'lib'
,
'main.dart'
),
buildInfo:
BuildInfo
.
debug
,
flutterProject:
flutterProject
,
hostname:
null
,
port:
null
,
);
// The build daemon is told to build once.
...
...
@@ -91,6 +99,21 @@ void main() {
// .dart_tool directory is created.
expect
(
flutterProject
.
dartTool
.
existsSync
(),
true
);
}));
test
(
'Uses provided port number and hostname.'
,
()
=>
testbed
.
run
(()
async
{
final
FlutterProject
flutterProject
=
FlutterProject
.
current
();
await
WebFs
.
start
(
skipDwds:
false
,
target:
fs
.
path
.
join
(
'lib'
,
'main.dart'
),
buildInfo:
BuildInfo
.
debug
,
flutterProject:
flutterProject
,
hostname:
'foo'
,
port:
'1234'
,
);
expect
(
lastPort
,
1234
);
expect
(
lastAddress
,
contains
(
'foo'
));
}));
}
class
MockBuildDaemonCreator
extends
Mock
implements
BuildDaemonCreator
{}
...
...
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