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
f1cdf6df
Commit
f1cdf6df
authored
Mar 21, 2016
by
Devon Carew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor; fix apk warning
parent
a7bdf9f5
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
88 additions
and
108 deletions
+88
-108
analyze.dart
packages/flutter_tools/lib/src/commands/analyze.dart
+6
-10
build_apk.dart
packages/flutter_tools/lib/src/commands/build_apk.dart
+19
-17
build_flx.dart
packages/flutter_tools/lib/src/commands/build_flx.dart
+1
-1
daemon.dart
packages/flutter_tools/lib/src/commands/daemon.dart
+4
-13
logs.dart
packages/flutter_tools/lib/src/commands/logs.dart
+6
-6
refresh.dart
packages/flutter_tools/lib/src/commands/refresh.dart
+1
-1
run.dart
packages/flutter_tools/lib/src/commands/run.dart
+8
-10
run_mojo.dart
packages/flutter_tools/lib/src/commands/run_mojo.dart
+9
-9
trace.dart
packages/flutter_tools/lib/src/commands/trace.dart
+8
-8
flx.dart
packages/flutter_tools/lib/src/flx.dart
+5
-1
simulators.dart
packages/flutter_tools/lib/src/ios/simulators.dart
+8
-15
service_protocol.dart
packages/flutter_tools/lib/src/service_protocol.dart
+3
-5
toolchain.dart
packages/flutter_tools/lib/src/toolchain.dart
+8
-10
mocks.dart
packages/flutter_tools/test/src/mocks.dart
+2
-2
No files found.
packages/flutter_tools/lib/src/commands/analyze.dart
View file @
f1cdf6df
...
...
@@ -18,11 +18,6 @@ import '../dart/sdk.dart';
import
'../globals.dart'
;
import
'../runner/flutter_command.dart'
;
// TODO(devoncarew): Possible improvements to flutter analyze --watch:
// - Auto-detect new issues introduced by changes and highlight then in the output.
// - Use ANSI codes to improve the display when the terminal supports it (screen
// clearing, cursor position manipulation, bold and faint codes, ...)
bool
isDartFile
(
FileSystemEntity
entry
)
=>
entry
is
File
&&
entry
.
path
.
endsWith
(
'.dart'
);
bool
isDartTestFile
(
FileSystemEntity
entry
)
=>
entry
is
File
&&
entry
.
path
.
endsWith
(
'_test.dart'
);
bool
isDartBenchmarkFile
(
FileSystemEntity
entry
)
=>
entry
is
File
&&
entry
.
path
.
endsWith
(
'_bench.dart'
);
...
...
@@ -449,10 +444,13 @@ class AnalyzeCommand extends FlutterCommand {
Future
<
int
>
_analyzeWatch
()
async
{
List
<
String
>
directories
;
if
(
isFlutterRepo
)
{
if
(
argResults
[
'flutter-repo'
])
{
String
root
=
path
.
absolute
(
ArtifactStore
.
flutterRoot
);
directories
=
<
String
>[];
directories
.
addAll
(
_gatherProjectPaths
(
path
.
absolute
(
'examples'
)));
directories
.
addAll
(
_gatherProjectPaths
(
path
.
absolute
(
'packages'
)));
directories
.
addAll
(
_gatherProjectPaths
(
path
.
join
(
root
,
'examples'
)));
directories
.
addAll
(
_gatherProjectPaths
(
path
.
join
(
root
,
'packages'
)));
directories
.
addAll
(
_gatherProjectPaths
(
path
.
join
(
root
,
'dev'
)));
printStatus
(
'Analyzing Flutter repository (
${directories.length}
projects).'
);
for
(
String
projectPath
in
directories
)
printTrace
(
'
${path.relative(projectPath)}
'
);
...
...
@@ -511,8 +509,6 @@ class AnalyzeCommand extends FlutterCommand {
int
issueDiff
=
issueCount
-
lastErrorCount
;
lastErrorCount
=
issueCount
;
// TODO(devoncarew): If there were no issues found, and no change in the
// issue count, do we want to print anything?
if
(
firstAnalysis
)
errorsMessage
=
'
$issueCount
${pluralize('issue', issueCount)}
found'
;
else
if
(
issueDiff
>
0
)
...
...
packages/flutter_tools/lib/src/commands/build_apk.dart
View file @
f1cdf6df
...
...
@@ -94,9 +94,8 @@ class _ApkBuilder {
'-I'
,
_androidJar
.
path
,
'-F'
,
outputApk
.
path
,
];
if
(
resources
!=
null
)
{
if
(
resources
!=
null
)
packageArgs
.
addAll
([
'-S'
,
resources
.
absolute
.
path
]);
}
packageArgs
.
add
(
artifacts
.
path
);
runCheckedSync
(
packageArgs
);
}
...
...
@@ -146,7 +145,6 @@ class BuildApkCommand extends FlutterCommand {
help:
'Android manifest XML file.'
);
argParser
.
addOption
(
'resources'
,
abbr:
'r'
,
defaultsTo:
_kDefaultResourcesPath
,
help:
'Resources directory path.'
);
argParser
.
addOption
(
'output-file'
,
abbr:
'o'
,
...
...
@@ -237,21 +235,15 @@ Future<_ApkComponents> _findApkComponents(
components
.
jars
=
[
new
File
(
artifactPaths
[
1
])];
components
.
libSkyShell
=
new
File
(
artifactPaths
[
2
]);
components
.
debugKeystore
=
new
File
(
artifactPaths
[
3
]);
components
.
resources
=
new
Directory
(
resources
);
components
.
resources
=
resources
==
null
?
null
:
new
Directory
(
resources
);
await
parseServiceConfigs
(
components
.
services
,
jars:
components
.
jars
);
if
(!
components
.
resources
.
existsSync
())
{
// TODO(eseidel): This level should be higher when path is manually set.
printStatus
(
'Cannot locate Resources:
${components.resources}
, ignoring.'
);
components
.
resources
=
null
;
}
for
(
File
f
in
[
for
(
File
file
in
[
components
.
manifest
,
components
.
icuData
,
components
.
libSkyShell
,
components
.
debugKeystore
]..
addAll
(
components
.
jars
))
{
if
(!
f
.
existsSync
())
{
printError
(
'Cannot locate file:
${f.path}
'
);
if
(!
f
ile
.
existsSync
())
{
printError
(
'Cannot locate file:
${f
ile
.path}
'
);
return
null
;
}
}
...
...
@@ -295,6 +287,7 @@ int _buildApk(
ensureDirectoryExists
(
finalApk
.
path
);
builder
.
align
(
unalignedApk
,
finalApk
);
printTrace
(
'calculateSha:
$outputFile
'
);
File
apkShaFile
=
new
File
(
'
$outputFile
.sha1'
);
apkShaFile
.
writeAsStringSync
(
calculateSha
(
finalApk
));
...
...
@@ -370,7 +363,7 @@ Future<int> buildAndroid({
String
enginePath
,
bool
force:
false
,
String
manifest:
_kDefaultAndroidManifestPath
,
String
resources
:
_kDefaultResourcesPath
,
String
resources
,
String
outputFile:
_kDefaultOutputPath
,
String
target:
''
,
String
flxPath
,
...
...
@@ -392,6 +385,16 @@ Future<int> buildAndroid({
return
0
;
}
if
(
resources
!=
null
)
{
if
(!
FileSystemEntity
.
isDirectorySync
(
resources
))
{
printError
(
'Resources directory "
$resources
" not found.'
);
return
1
;
}
}
else
{
if
(
FileSystemEntity
.
isDirectorySync
(
_kDefaultResourcesPath
))
resources
=
_kDefaultResourcesPath
;
}
BuildConfiguration
config
=
configs
.
firstWhere
(
(
BuildConfiguration
bc
)
=>
bc
.
targetPlatform
==
TargetPlatform
.
android_arm
);
...
...
@@ -411,11 +414,10 @@ Future<int> buildAndroid({
}
return
_buildApk
(
components
,
flxPath
,
keystore
,
outputFile
);
}
else
{
// Find the path to the main Dart file.
// Find the path to the main Dart file
; build the FLX
.
String
mainPath
=
findMainDartFile
(
target
);
// Build the FLX.
String
localBundlePath
=
await
flx
.
buildFlx
(
toolchain
,
mainPath:
mainPath
);
return
_buildApk
(
components
,
localBundlePath
,
keystore
,
outputFile
);
}
}
...
...
packages/flutter_tools/lib/src/commands/build_flx.dart
View file @
f1cdf6df
...
...
@@ -43,7 +43,7 @@ class BuildFlxCommand extends FlutterCommand {
if
(
compilerPath
==
null
)
await
downloadToolchain
();
else
toolchain
=
new
Toolchain
(
compiler:
new
Compiler
(
compilerPath
));
toolchain
=
new
Toolchain
(
compiler:
new
Snapshot
Compiler
(
compilerPath
));
String
outputPath
=
argResults
[
'output-file'
];
...
...
packages/flutter_tools/lib/src/commands/daemon.dart
View file @
f1cdf6df
...
...
@@ -8,6 +8,7 @@ import 'dart:io';
import
'../android/android_device.dart'
;
import
'../application_package.dart'
;
import
'../artifacts.dart'
;
import
'../base/context.dart'
;
import
'../base/logger.dart'
;
import
'../device.dart'
;
...
...
@@ -386,24 +387,14 @@ class DeviceDomain extends Domain {
}
}
Map
<
String
,
dynamic
>
_deviceToMap
(
Device
device
)
{
return
<
String
,
dynamic
>{
Map
<
String
,
String
>
_deviceToMap
(
Device
device
)
{
return
<
String
,
String
>{
'id'
:
device
.
id
,
'name'
:
device
.
name
,
'platform'
:
_enumToString
(
device
.
platform
)
'platform'
:
getNameForTargetPlatform
(
device
.
platform
)
};
}
/// Take an enum value and get the best string representation of that.
///
/// toString() on enums returns 'EnumType.enumName'.
String
_enumToString
(
dynamic
enumValue
)
{
String
str
=
'
$enumValue
'
;
if
(
str
.
contains
(
'.'
))
return
str
.
substring
(
str
.
indexOf
(
'.'
)
+
1
);
return
str
;
}
dynamic
_toJsonable
(
dynamic
obj
)
{
if
(
obj
is
String
||
obj
is
int
||
obj
is
bool
||
obj
is
Map
<
dynamic
,
dynamic
>
||
obj
is
List
<
dynamic
>
||
obj
==
null
)
return
obj
;
...
...
packages/flutter_tools/lib/src/commands/logs.dart
View file @
f1cdf6df
...
...
@@ -9,12 +9,6 @@ import '../globals.dart';
import
'../runner/flutter_command.dart'
;
class
LogsCommand
extends
FlutterCommand
{
@override
final
String
name
=
'logs'
;
@override
final
String
description
=
'Show log output for running Flutter apps.'
;
LogsCommand
()
{
argParser
.
addFlag
(
'clear'
,
negatable:
false
,
...
...
@@ -23,6 +17,12 @@ class LogsCommand extends FlutterCommand {
);
}
@override
final
String
name
=
'logs'
;
@override
final
String
description
=
'Show log output for running Flutter apps.'
;
@override
bool
get
requiresProjectRoot
=>
false
;
...
...
packages/flutter_tools/lib/src/commands/refresh.dart
View file @
f1cdf6df
...
...
@@ -41,7 +41,7 @@ class RefreshCommand extends FlutterCommand {
try
{
String
snapshotPath
=
path
.
join
(
tempDir
.
path
,
'snapshot_blob.bin'
);
int
result
=
await
toolchain
.
compiler
.
c
ompile
(
int
result
=
await
toolchain
.
compiler
.
c
reateSnapshot
(
mainPath:
argResults
[
'target'
],
snapshotPath:
snapshotPath
);
if
(
result
!=
0
)
{
...
...
packages/flutter_tools/lib/src/commands/run.dart
View file @
f1cdf6df
...
...
@@ -42,7 +42,7 @@ abstract class RunCommandBase extends FlutterCommand {
defaultsTo:
false
,
help:
'Start tracing during startup.'
);
argParser
.
addOption
(
'route'
,
help:
'Which route to load when
start
ing the app.'
);
help:
'Which route to load when
runn
ing the app.'
);
usesTargetOption
();
}
...
...
@@ -65,10 +65,10 @@ class RunCommand extends RunCommandBase {
RunCommand
()
{
argParser
.
addFlag
(
'full-restart'
,
defaultsTo:
true
,
help:
'Stop any currently running application process before
start
ing the app.'
);
help:
'Stop any currently running application process before
runn
ing the app.'
);
argParser
.
addFlag
(
'clear-logs'
,
defaultsTo:
true
,
help:
'Clear log history before
start
ing the app.'
);
help:
'Clear log history before
runn
ing the app.'
);
argParser
.
addFlag
(
'start-paused'
,
defaultsTo:
false
,
negatable:
false
,
...
...
@@ -214,14 +214,12 @@ Future<int> startApp(
await
installApp
(
device
,
package
);
}
bool
startedSomething
=
false
;
Map
<
String
,
dynamic
>
platformArgs
=
<
String
,
dynamic
>{};
if
(
traceStartup
!=
null
)
platformArgs
[
'trace-startup'
]
=
traceStartup
;
printStatus
(
'
Start
ing
${_getDisplayPath(mainPath)}
on
${device.name}
...'
);
printStatus
(
'
Runn
ing
${_getDisplayPath(mainPath)}
on
${device.name}
...'
);
bool
result
=
await
device
.
startApp
(
package
,
...
...
@@ -236,10 +234,8 @@ Future<int> startApp(
);
if
(!
result
)
{
printError
(
'Error
start
ing application on
${device.name}
.'
);
printError
(
'Error
runn
ing application on
${device.name}
.'
);
}
else
{
startedSomething
=
true
;
// If the user specified --start-paused (and the device supports it) then
// wait for the observatory port to become available before returning from
// `startApp()`.
...
...
@@ -247,7 +243,7 @@ Future<int> startApp(
await
delayUntilObservatoryAvailable
(
'localhost'
,
debugPort
);
}
return
startedSomething
?
0
:
2
;
return
result
?
0
:
2
;
}
/// Delay until the Observatory / service protocol is available.
...
...
@@ -257,6 +253,8 @@ Future<int> startApp(
Future
<
Null
>
delayUntilObservatoryAvailable
(
String
host
,
int
port
,
{
Duration
timeout:
const
Duration
(
seconds:
10
)
})
async
{
printTrace
(
'Waiting until Observatory is available (port
$port
).'
);
Stopwatch
stopwatch
=
new
Stopwatch
()..
start
();
final
String
url
=
'ws://
$host
:
$port
/ws'
;
...
...
packages/flutter_tools/lib/src/commands/run_mojo.dart
View file @
f1cdf6df
...
...
@@ -18,15 +18,6 @@ import 'run.dart';
const
String
_kDefaultBundlePath
=
'build/app.flx'
;
class
RunMojoCommand
extends
FlutterCommand
{
@override
final
String
name
=
'run_mojo'
;
@override
final
String
description
=
'Run a Flutter app in mojo (from github.com/domokit/mojo).'
;
@override
final
bool
hidden
;
RunMojoCommand
({
this
.
hidden
:
false
})
{
argParser
.
addFlag
(
'android'
,
negatable:
false
,
help:
'Run on an Android device'
);
argParser
.
addFlag
(
'checked'
,
negatable:
false
,
help:
'Run Flutter in checked mode'
);
...
...
@@ -42,6 +33,15 @@ class RunMojoCommand extends FlutterCommand {
argParser
.
addOption
(
'devtools-path'
,
help:
'Path to mojo devtools
\'
mojo_run command.'
);
}
@override
final
String
name
=
'run_mojo'
;
@override
final
String
description
=
'Run a Flutter app in mojo (from github.com/domokit/mojo).'
;
@override
final
bool
hidden
;
@override
bool
get
requiresProjectRoot
=>
false
;
...
...
packages/flutter_tools/lib/src/commands/trace.dart
View file @
f1cdf6df
...
...
@@ -10,6 +10,14 @@ import '../globals.dart';
import
'../runner/flutter_command.dart'
;
class
TraceCommand
extends
FlutterCommand
{
TraceCommand
()
{
argParser
.
addFlag
(
'start'
,
negatable:
false
,
help:
'Start tracing.'
);
argParser
.
addFlag
(
'stop'
,
negatable:
false
,
help:
'Stop tracing.'
);
argParser
.
addOption
(
'out'
,
help:
'Specify the path of the saved trace file.'
);
argParser
.
addOption
(
'duration'
,
defaultsTo:
'10'
,
abbr:
'd'
,
help:
'Duration in seconds to trace.'
);
}
@override
final
String
name
=
'trace'
;
...
...
@@ -22,14 +30,6 @@ class TraceCommand extends FlutterCommand {
'time (controlled by --duration), and stop tracing. To explicitly control tracing, call trace
\n
'
'with --start and later with --stop.'
;
TraceCommand
()
{
argParser
.
addFlag
(
'start'
,
negatable:
false
,
help:
'Start tracing.'
);
argParser
.
addFlag
(
'stop'
,
negatable:
false
,
help:
'Stop tracing.'
);
argParser
.
addOption
(
'out'
,
help:
'Specify the path of the saved trace file.'
);
argParser
.
addOption
(
'duration'
,
defaultsTo:
'10'
,
abbr:
'd'
,
help:
'Duration in seconds to trace.'
);
}
@override
bool
get
androidOnly
=>
true
;
...
...
packages/flutter_tools/lib/src/flx.dart
View file @
f1cdf6df
...
...
@@ -177,7 +177,11 @@ Future<int> build(
// In a precompiled snapshot, the instruction buffer contains script
// content equivalents
int
result
=
await
toolchain
.
compiler
.
compile
(
mainPath:
mainPath
,
snapshotPath:
snapshotPath
,
depfilePath:
depfilePath
,
buildOutputPath:
outputPath
);
int
result
=
await
toolchain
.
compiler
.
createSnapshot
(
mainPath:
mainPath
,
snapshotPath:
snapshotPath
,
depfilePath:
depfilePath
);
if
(
result
!=
0
)
{
printError
(
'Failed to run the Flutter compiler. Exit code:
$result
'
);
return
result
;
...
...
packages/flutter_tools/lib/src/ios/simulators.dart
View file @
f1cdf6df
...
...
@@ -99,14 +99,12 @@ class SimControl {
SimDevice
_createTestDevice
()
{
SimDeviceType
deviceType
=
_findSuitableDeviceType
();
if
(
deviceType
==
null
)
{
if
(
deviceType
==
null
)
return
null
;
}
String
runtime
=
_findSuitableRuntime
();
if
(
runtime
==
null
)
{
if
(
runtime
==
null
)
return
null
;
}
// Delete any old test devices
getDevices
()
...
...
@@ -131,10 +129,8 @@ class SimControl {
if
(
usableTypes
.
isEmpty
)
{
printError
(
'No suitable device type found.'
'
\n
'
'You may launch an iOS Simulator manually and Flutter will attempt to '
'use it.'
'No suitable device type found.
\n
'
'You may launch an iOS Simulator manually and Flutter will attempt to use it.'
);
}
...
...
@@ -153,10 +149,8 @@ class SimControl {
if
(
usableRuntimes
.
isEmpty
)
{
printError
(
'No suitable iOS runtime found.'
'
\n
'
'You may launch an iOS Simulator manually and Flutter will attempt to '
'use it.'
'No suitable iOS runtime found.
\n
'
'You may launch an iOS Simulator manually and Flutter will attempt to use it.'
);
}
...
...
@@ -165,7 +159,7 @@ class SimControl {
void
_deleteDevice
(
SimDevice
device
)
{
try
{
List
<
String
>
args
=
[
_xcrunPath
,
'simctl'
,
'delete'
,
device
.
name
];
List
<
String
>
args
=
<
String
>
[
_xcrunPath
,
'simctl'
,
'delete'
,
device
.
name
];
printTrace
(
args
.
join
(
' '
));
runCheckedSync
(
args
);
}
catch
(
e
)
{
...
...
@@ -426,9 +420,8 @@ class IOSSimulator extends Device {
@override
String
supportMessage
()
{
if
(
isSupported
())
{
if
(
isSupported
())
return
"Supported"
;
}
return
_supportMessage
!=
null
?
_supportMessage
:
"Unknown"
;
}
...
...
packages/flutter_tools/lib/src/service_protocol.dart
View file @
f1cdf6df
...
...
@@ -21,11 +21,9 @@ class ServiceProtocolDiscovery {
final
DeviceLogReader
_logReader
;
Completer
<
int
>
_completer
=
new
Completer
<
int
>();
/// The [Future] returned by this function will complete when the next
/// service protocol port is found.
Future
<
int
>
nextPort
()
{
return
_completer
.
future
;
}
/// The [Future] returned by this function will complete when the next service
/// protocol port is found.
Future
<
int
>
nextPort
()
=>
_completer
.
future
;
void
_onLine
(
String
line
)
{
int
portNumber
=
0
;
...
...
packages/flutter_tools/lib/src/toolchain.dart
View file @
f1cdf6df
...
...
@@ -11,12 +11,12 @@ import 'artifacts.dart';
import
'base/process.dart'
;
import
'build_configuration.dart'
;
class
Compiler
{
Compiler
(
this
.
_path
);
class
Snapshot
Compiler
{
Snapshot
Compiler
(
this
.
_path
);
String
_path
;
final
String
_path
;
Future
<
int
>
c
ompile
({
Future
<
int
>
c
reateSnapshot
({
String
mainPath
,
String
snapshotPath
,
String
depfilePath
,
...
...
@@ -28,12 +28,10 @@ class Compiler {
'--package-root=
${ArtifactStore.packageRoot}
'
,
'--snapshot=
$snapshotPath
'
];
if
(
depfilePath
!=
null
)
{
if
(
depfilePath
!=
null
)
args
.
add
(
'--depfile=
$depfilePath
'
);
}
if
(
buildOutputPath
!=
null
)
{
if
(
buildOutputPath
!=
null
)
args
.
add
(
'--build-output=
$buildOutputPath
'
);
}
return
runCommandAndStreamOutput
(
args
);
}
}
...
...
@@ -56,13 +54,13 @@ Future<String> _getCompilerPath(BuildConfiguration config) async {
class
Toolchain
{
Toolchain
({
this
.
compiler
});
final
Compiler
compiler
;
final
Snapshot
Compiler
compiler
;
static
Future
<
Toolchain
>
forConfigs
(
List
<
BuildConfiguration
>
configs
)
async
{
for
(
BuildConfiguration
config
in
configs
)
{
String
compilerPath
=
await
_getCompilerPath
(
config
);
if
(
compilerPath
!=
null
)
return
new
Toolchain
(
compiler:
new
Compiler
(
compilerPath
));
return
new
Toolchain
(
compiler:
new
Snapshot
Compiler
(
compilerPath
));
}
return
null
;
}
...
...
packages/flutter_tools/test/src/mocks.dart
View file @
f1cdf6df
...
...
@@ -28,11 +28,11 @@ class MockApplicationPackageStore extends ApplicationPackageStore {
);
}
class
Mock
Compiler
extends
Mock
implements
Compiler
{
class
Mock
SnapshotCompiler
extends
Mock
implements
Snapshot
Compiler
{
}
class
MockToolchain
extends
Toolchain
{
MockToolchain
()
:
super
(
compiler:
new
MockCompiler
());
MockToolchain
()
:
super
(
compiler:
new
Mock
Snapshot
Compiler
());
}
class
MockAndroidDevice
extends
Mock
implements
AndroidDevice
{
...
...
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