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
2981fc40
Commit
2981fc40
authored
Feb 02, 2016
by
Devon Carew
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1526 from devoncarew/start_paused
add --start-paused,--debug-port flags
parents
6d9f4308
b780c076
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
101 additions
and
34 deletions
+101
-34
device_android.dart
packages/flutter_tools/lib/src/android/device_android.dart
+53
-32
common.dart
packages/flutter_tools/lib/src/base/common.dart
+5
-0
os.dart
packages/flutter_tools/lib/src/base/os.dart
+8
-0
start.dart
packages/flutter_tools/lib/src/commands/start.dart
+25
-2
device.dart
packages/flutter_tools/lib/src/device.dart
+3
-0
device_ios.dart
packages/flutter_tools/lib/src/ios/device_ios.dart
+7
-0
No files found.
packages/flutter_tools/lib/src/android/device_android.dart
View file @
2981fc40
...
...
@@ -9,7 +9,9 @@ import 'package:crypto/crypto.dart';
import
'package:path/path.dart'
as
path
;
import
'../application_package.dart'
;
import
'../base/common.dart'
;
import
'../base/context.dart'
;
import
'../base/os.dart'
;
import
'../base/process.dart'
;
import
'../build_configuration.dart'
;
import
'../device.dart'
;
...
...
@@ -33,8 +35,6 @@ class AndroidDeviceDiscovery extends DeviceDiscovery {
}
class
AndroidDevice
extends
Device
{
static
const
int
_observatoryPort
=
8181
;
static
final
String
defaultDeviceID
=
'default_android_device'
;
String
productID
;
...
...
@@ -240,22 +240,37 @@ class AndroidDevice extends Device {
return
true
;
}
void
_forwardObservatoryPort
()
{
// Set up port forwarding for observatory.
String
portString
=
'tcp:
$_observatoryPort
'
;
Future
_forwardObservatoryPort
(
int
port
)
async
{
bool
portWasZero
=
port
==
0
;
if
(
port
==
0
)
{
// Auto-bind to a port. Set up forwarding for that port. Emit a stdout
// message similar to the command-line VM, so that tools can parse the output.
// "Observatory listening on http://127.0.0.1:52111"
port
=
await
findAvailablePort
();
}
try
{
runCheckedSync
(
adbCommandForDevice
(<
String
>[
'forward'
,
portString
,
portString
]));
// Set up port forwarding for observatory.
runCheckedSync
(
adbCommandForDevice
(<
String
>[
'forward'
,
'tcp:
$port
'
,
'tcp:
$observatoryDefaultPort
'
]));
if
(
portWasZero
)
printStatus
(
'Observatory listening on http://127.0.0.1:
$port
'
);
}
catch
(
e
)
{
printError
(
'Unable to forward
observatory port (
$_observatoryPort
):
\n
$e
'
);
printError
(
'Unable to forward
Observatory port
$port
:
$e
'
);
}
}
bool
startBundle
(
AndroidApk
apk
,
String
bundlePath
,
{
Future
<
bool
>
startBundle
(
AndroidApk
apk
,
String
bundlePath
,
{
bool
checked:
true
,
bool
traceStartup:
false
,
String
route
,
bool
clearLogs:
false
})
{
bool
clearLogs:
false
,
bool
startPaused:
false
,
int
debugPort:
observatoryDefaultPort
})
async
{
printTrace
(
'
$this
startBundle'
);
if
(!
FileSystemEntity
.
isFileSync
(
bundlePath
))
{
...
...
@@ -263,7 +278,7 @@ class AndroidDevice extends Device {
return
false
;
}
_forwardObservatoryPort
(
);
await
_forwardObservatoryPort
(
debugPort
);
if
(
clearLogs
)
this
.
clearLogs
();
...
...
@@ -280,6 +295,8 @@ class AndroidDevice extends Device {
cmd
.
addAll
([
'--ez'
,
'enable-checked-mode'
,
'true'
]);
if
(
traceStartup
)
cmd
.
addAll
([
'--ez'
,
'trace-startup'
,
'true'
]);
if
(
startPaused
)
cmd
.
addAll
([
'--ez'
,
'start-paused'
,
'true'
]);
if
(
route
!=
null
)
cmd
.
addAll
([
'--es'
,
'route'
,
route
]);
cmd
.
add
(
apk
.
launchActivity
);
...
...
@@ -295,22 +312,27 @@ class AndroidDevice extends Device {
String
route
,
bool
checked:
true
,
bool
clearLogs:
false
,
bool
startPaused:
false
,
int
debugPort:
observatoryDefaultPort
,
Map
<
String
,
dynamic
>
platformArgs
})
{
return
flx
.
buildInTempDir
(
})
async
{
flx
.
DirectoryResult
buildResult
=
await
flx
.
buildInTempDir
(
toolchain
,
mainPath:
mainPath
).
then
((
flx
.
DirectoryResult
buildResult
)
{
);
printTrace
(
'Starting bundle for
$this
.'
);
try
{
if
(
startBundle
(
if
(
await
startBundle
(
package
,
buildResult
.
localBundlePath
,
checked:
checked
,
traceStartup:
platformArgs
[
'trace-startup'
],
route:
route
,
clearLogs:
clearLogs
clearLogs:
clearLogs
,
startPaused:
startPaused
,
debugPort:
debugPort
))
{
return
true
;
}
else
{
...
...
@@ -319,7 +341,6 @@ class AndroidDevice extends Device {
}
finally
{
buildResult
.
dispose
();
}
});
}
Future
<
bool
>
stopApp
(
ApplicationPackage
app
)
async
{
...
...
packages/flutter_tools/lib/src/base/common.dart
0 → 100644
View file @
2981fc40
// Copyright 2016 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.
const
int
observatoryDefaultPort
=
8181
;
packages/flutter_tools/lib/src/base/os.dart
View file @
2981fc40
...
...
@@ -2,6 +2,7 @@
// 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:io'
;
final
OperatingSystemUtils
os
=
new
OperatingSystemUtils
.
_
();
...
...
@@ -31,3 +32,10 @@ class _WindowsUtils implements OperatingSystemUtils {
return
new
ProcessResult
(
0
,
0
,
null
,
null
);
}
}
Future
<
int
>
findAvailablePort
()
async
{
ServerSocket
socket
=
await
ServerSocket
.
bind
(
InternetAddress
.
LOOPBACK_IP_V4
,
0
);
int
port
=
socket
.
port
;
await
socket
.
close
();
return
port
;
}
packages/flutter_tools/lib/src/commands/start.dart
View file @
2981fc40
...
...
@@ -8,6 +8,7 @@ import 'dart:io';
import
'package:path/path.dart'
as
path
;
import
'../application_package.dart'
;
import
'../base/common.dart'
;
import
'../base/context.dart'
;
import
'../device.dart'
;
import
'../runner/flutter_command.dart'
;
...
...
@@ -58,6 +59,13 @@ class StartCommand extends StartCommandBase {
argParser
.
addFlag
(
'clear-logs'
,
defaultsTo:
true
,
help:
'Clear log history before starting the app.'
);
argParser
.
addFlag
(
'start-paused'
,
defaultsTo:
false
,
negatable:
false
,
help:
'Start in a paused mode and wait for a debugger to connect.'
);
argParser
.
addOption
(
'debug-port'
,
defaultsTo:
observatoryDefaultPort
.
toString
(),
help:
'Listen to the given port for a debug connection.'
);
}
@override
...
...
@@ -71,6 +79,15 @@ class StartCommand extends StartCommandBase {
bool
clearLogs
=
argResults
[
'clear-logs'
];
int
debugPort
;
try
{
debugPort
=
int
.
parse
(
argResults
[
'debug-port'
]);
}
catch
(
error
)
{
printError
(
'Invalid port for `--debug-port`:
$error
'
);
return
1
;
}
int
result
=
await
startApp
(
devices
,
applicationPackages
,
...
...
@@ -81,7 +98,9 @@ class StartCommand extends StartCommandBase {
checked:
argResults
[
'checked'
],
traceStartup:
argResults
[
'trace-startup'
],
route:
argResults
[
'route'
],
clearLogs:
clearLogs
clearLogs:
clearLogs
,
startPaused:
argResults
[
'start-paused'
],
debugPort:
debugPort
);
printTrace
(
'Finished start command.'
);
...
...
@@ -99,7 +118,9 @@ Future<int> startApp(
bool
checked:
true
,
bool
traceStartup:
false
,
String
route
,
bool
clearLogs:
false
bool
clearLogs:
false
,
bool
startPaused:
false
,
int
debugPort:
observatoryDefaultPort
})
async
{
String
mainPath
=
findMainDartFile
(
target
);
...
...
@@ -144,6 +165,8 @@ Future<int> startApp(
route:
route
,
checked:
checked
,
clearLogs:
clearLogs
,
startPaused:
startPaused
,
debugPort:
debugPort
,
platformArgs:
platformArgs
);
...
...
packages/flutter_tools/lib/src/device.dart
View file @
2981fc40
...
...
@@ -6,6 +6,7 @@ import 'dart:async';
import
'android/device_android.dart'
;
import
'application_package.dart'
;
import
'base/common.dart'
;
import
'base/context.dart'
;
import
'build_configuration.dart'
;
import
'ios/device_ios.dart'
;
...
...
@@ -104,6 +105,8 @@ abstract class Device {
String
route
,
bool
checked:
true
,
bool
clearLogs:
false
,
bool
startPaused:
false
,
int
debugPort:
observatoryDefaultPort
,
Map
<
String
,
dynamic
>
platformArgs
});
...
...
packages/flutter_tools/lib/src/ios/device_ios.dart
View file @
2981fc40
...
...
@@ -8,6 +8,7 @@ import 'dart:io';
import
'package:path/path.dart'
as
path
;
import
'../application_package.dart'
;
import
'../base/common.dart'
;
import
'../base/context.dart'
;
import
'../base/process.dart'
;
import
'../build_configuration.dart'
;
...
...
@@ -185,9 +186,12 @@ class IOSDevice extends Device {
String
route
,
bool
checked:
true
,
bool
clearLogs:
false
,
bool
startPaused:
false
,
int
debugPort:
observatoryDefaultPort
,
Map
<
String
,
dynamic
>
platformArgs
})
async
{
// TODO(chinmaygarde): Use checked, mainPath, route, clearLogs.
// TODO(devoncarew): Handle startPaused, debugPort.
printTrace
(
'Building
${app.name}
for
$id
'
);
// Step 1: Install the precompiled application if necessary
...
...
@@ -431,9 +435,12 @@ class IOSSimulator extends Device {
String
route
,
bool
checked:
true
,
bool
clearLogs:
false
,
bool
startPaused:
false
,
int
debugPort:
observatoryDefaultPort
,
Map
<
String
,
dynamic
>
platformArgs
})
async
{
// TODO(chinmaygarde): Use checked, mainPath, route.
// TODO(devoncarew): Handle startPaused, debugPort.
printTrace
(
'Building
${app.name}
for
$id
'
);
if
(
clearLogs
)
...
...
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