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
417c2f25
Commit
417c2f25
authored
Jan 26, 2017
by
Todd Volkert
Committed by
GitHub
Jan 26, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate flutter_tools to use package:platform (#7642)
parent
600c75cb
Changes
29
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
123 additions
and
83 deletions
+123
-83
fuchsia_builder.dart
packages/flutter_tools/bin/fuchsia_builder.dart
+3
-1
executable.dart
packages/flutter_tools/lib/executable.dart
+2
-0
android_sdk.dart
packages/flutter_tools/lib/src/android/android_sdk.dart
+6
-6
android_workflow.dart
packages/flutter_tools/lib/src/android/android_workflow.dart
+5
-4
common.dart
packages/flutter_tools/lib/src/base/common.dart
+4
-4
config.dart
packages/flutter_tools/lib/src/base/config.dart
+3
-3
io.dart
packages/flutter_tools/lib/src/base/io.dart
+19
-10
logger.dart
packages/flutter_tools/lib/src/base/logger.dart
+2
-1
os.dart
packages/flutter_tools/lib/src/base/os.dart
+5
-3
platform.dart
packages/flutter_tools/lib/src/base/platform.dart
+13
-0
utils.dart
packages/flutter_tools/lib/src/base/utils.dart
+4
-4
build_info.dart
packages/flutter_tools/lib/src/build_info.dart
+3
-3
cache.dart
packages/flutter_tools/lib/src/cache.dart
+6
-6
test.dart
packages/flutter_tools/lib/src/commands/test.dart
+2
-1
sdk.dart
packages/flutter_tools/lib/src/dart/sdk.dart
+2
-2
device.dart
packages/flutter_tools/lib/src/device.dart
+2
-0
doctor.dart
packages/flutter_tools/lib/src/doctor.dart
+7
-7
devices.dart
packages/flutter_tools/lib/src/ios/devices.dart
+4
-3
ios_workflow.dart
packages/flutter_tools/lib/src/ios/ios_workflow.dart
+2
-1
mac.dart
packages/flutter_tools/lib/src/ios/mac.dart
+2
-1
simulators.dart
packages/flutter_tools/lib/src/ios/simulators.dart
+4
-3
flutter_command_runner.dart
.../flutter_tools/lib/src/runner/flutter_command_runner.dart
+7
-7
pubspec.yaml
packages/flutter_tools/pubspec.yaml
+1
-0
daemon_test.dart
packages/flutter_tools/test/daemon_test.dart
+3
-2
dart_dependencies_test.dart
packages/flutter_tools/test/dart_dependencies_test.dart
+2
-2
dependency_checker_test.dart
packages/flutter_tools/test/dependency_checker_test.dart
+2
-2
forbid_dart_io_test.dart
packages/flutter_tools/test/forbid_dart_io_test.dart
+2
-2
os_utils_test.dart
packages/flutter_tools/test/os_utils_test.dart
+2
-2
context.dart
packages/flutter_tools/test/src/context.dart
+4
-3
No files found.
packages/flutter_tools/bin/fuchsia_builder.dart
View file @
417c2f25
...
...
@@ -14,6 +14,7 @@ import '../lib/src/base/file_system.dart';
import
'../lib/src/base/io.dart'
;
import
'../lib/src/base/logger.dart'
;
import
'../lib/src/base/os.dart'
;
import
'../lib/src/base/platform.dart'
;
import
'../lib/src/cache.dart'
;
import
'../lib/src/flx.dart'
;
import
'../lib/src/globals.dart'
;
...
...
@@ -38,6 +39,7 @@ Future<Null> main(List<String> args) async {
executableContext
.
setVariable
(
Logger
,
new
StdoutLogger
());
executableContext
.
runInZone
(()
{
// Initialize the context with some defaults.
context
.
putIfAbsent
(
Platform
,
()
=>
new
LocalPlatform
());
context
.
putIfAbsent
(
FileSystem
,
()
=>
new
LocalFileSystem
());
context
.
putIfAbsent
(
ProcessManager
,
()
=>
new
LocalProcessManager
());
context
.
putIfAbsent
(
Logger
,
()
=>
new
StdoutLogger
());
...
...
@@ -63,7 +65,7 @@ Future<Null> run(List<String> args) async {
printError
(
'Missing option! All options must be specified.'
);
exit
(
1
);
}
Cache
.
flutterRoot
=
P
latform
.
environment
[
'FLUTTER_ROOT'
];
Cache
.
flutterRoot
=
p
latform
.
environment
[
'FLUTTER_ROOT'
];
String
outputPath
=
argResults
[
_kOptionOutput
];
try
{
await
assemble
(
...
...
packages/flutter_tools/lib/executable.dart
View file @
417c2f25
...
...
@@ -15,6 +15,7 @@ import 'src/base/file_system.dart';
import
'src/base/io.dart'
;
import
'src/base/logger.dart'
;
import
'src/base/os.dart'
;
import
'src/base/platform.dart'
;
import
'src/base/process.dart'
;
import
'src/base/utils.dart'
;
import
'src/cache.dart'
;
...
...
@@ -100,6 +101,7 @@ Future<Null> main(List<String> args) async {
// in those locations as well to see if you need a similar update there.
// Seed these context entries first since others depend on them
context
.
putIfAbsent
(
Platform
,
()
=>
new
LocalPlatform
());
context
.
putIfAbsent
(
FileSystem
,
()
=>
new
LocalFileSystem
());
context
.
putIfAbsent
(
ProcessManager
,
()
=>
new
LocalProcessManager
());
context
.
putIfAbsent
(
Logger
,
()
=>
new
StdoutLogger
());
...
...
packages/flutter_tools/lib/src/android/android_sdk.dart
View file @
417c2f25
...
...
@@ -8,8 +8,8 @@ import 'package:pub_semver/pub_semver.dart';
import
'../base/common.dart'
;
import
'../base/context.dart'
;
import
'../base/file_system.dart'
;
import
'../base/io.dart'
;
import
'../base/os.dart'
;
import
'../base/platform.dart'
;
import
'../globals.dart'
;
AndroidSdk
get
androidSdk
=>
context
[
AndroidSdk
];
...
...
@@ -64,15 +64,15 @@ class AndroidSdk {
static
AndroidSdk
locateAndroidSdk
()
{
String
androidHomeDir
;
if
(
P
latform
.
environment
.
containsKey
(
kAndroidHome
))
{
androidHomeDir
=
P
latform
.
environment
[
kAndroidHome
];
}
else
if
(
P
latform
.
isLinux
)
{
if
(
p
latform
.
environment
.
containsKey
(
kAndroidHome
))
{
androidHomeDir
=
p
latform
.
environment
[
kAndroidHome
];
}
else
if
(
p
latform
.
isLinux
)
{
if
(
homeDirPath
!=
null
)
androidHomeDir
=
path
.
join
(
homeDirPath
,
'Android'
,
'Sdk'
);
}
else
if
(
P
latform
.
isMacOS
)
{
}
else
if
(
p
latform
.
isMacOS
)
{
if
(
homeDirPath
!=
null
)
androidHomeDir
=
path
.
join
(
homeDirPath
,
'Library'
,
'Android'
,
'sdk'
);
}
else
if
(
P
latform
.
isWindows
)
{
}
else
if
(
p
latform
.
isWindows
)
{
if
(
homeDirPath
!=
null
)
androidHomeDir
=
path
.
join
(
homeDirPath
,
'AppData'
,
'Local'
,
'Android'
,
'sdk'
);
}
...
...
packages/flutter_tools/lib/src/android/android_workflow.dart
View file @
417c2f25
...
...
@@ -6,6 +6,7 @@ import 'dart:async';
import
'../base/io.dart'
;
import
'../base/os.dart'
;
import
'../base/platform.dart'
;
import
'../base/process_manager.dart'
;
import
'../doctor.dart'
;
import
'../globals.dart'
;
...
...
@@ -30,8 +31,8 @@ class AndroidWorkflow extends DoctorValidator implements Workflow {
String
sdkVersionText
;
if
(
androidSdk
==
null
)
{
if
(
P
latform
.
environment
.
containsKey
(
kAndroidHome
))
{
String
androidHomeDir
=
P
latform
.
environment
[
kAndroidHome
];
if
(
p
latform
.
environment
.
containsKey
(
kAndroidHome
))
{
String
androidHomeDir
=
p
latform
.
environment
[
kAndroidHome
];
messages
.
add
(
new
ValidationMessage
.
error
(
'
$kAndroidHome
=
$androidHomeDir
\n
'
'but Android Studio / Android SDK not found at this location.'
...
...
@@ -56,8 +57,8 @@ class AndroidWorkflow extends DoctorValidator implements Workflow {
));
}
if
(
P
latform
.
environment
.
containsKey
(
kAndroidHome
))
{
String
androidHomeDir
=
P
latform
.
environment
[
kAndroidHome
];
if
(
p
latform
.
environment
.
containsKey
(
kAndroidHome
))
{
String
androidHomeDir
=
p
latform
.
environment
[
kAndroidHome
];
messages
.
add
(
new
ValidationMessage
(
'
$kAndroidHome
=
$androidHomeDir
'
));
}
...
...
packages/flutter_tools/lib/src/base/common.dart
View file @
417c2f25
...
...
@@ -4,7 +4,7 @@
import
'package:path/path.dart'
as
path
;
import
'
io
.dart'
;
import
'
platform
.dart'
;
const
int
kDefaultObservatoryPort
=
8100
;
const
int
kDefaultDiagnosticPort
=
8101
;
...
...
@@ -13,9 +13,9 @@ const int kDefaultDrivePort = 8183;
/// Return the absolute path of the user's home directory
String
get
homeDirPath
{
if
(
_homeDirPath
==
null
)
{
_homeDirPath
=
P
latform
.
isWindows
?
P
latform
.
environment
[
'USERPROFILE'
]
:
P
latform
.
environment
[
'HOME'
];
_homeDirPath
=
p
latform
.
isWindows
?
p
latform
.
environment
[
'USERPROFILE'
]
:
p
latform
.
environment
[
'HOME'
];
if
(
_homeDirPath
!=
null
)
_homeDirPath
=
path
.
absolute
(
_homeDirPath
);
}
...
...
packages/flutter_tools/lib/src/base/config.dart
View file @
417c2f25
...
...
@@ -8,7 +8,7 @@ import 'package:path/path.dart' as path;
import
'context.dart'
;
import
'file_system.dart'
;
import
'
io
.dart'
;
import
'
platform
.dart'
;
class
Config
{
Config
([
File
configFile
])
{
...
...
@@ -46,7 +46,7 @@ class Config {
}
String
_userHomeDir
(
)
{
String
envKey
=
P
latform
.
operatingSystem
==
'windows'
?
'APPDATA'
:
'HOME'
;
String
value
=
P
latform
.
environment
[
envKey
];
String
envKey
=
p
latform
.
operatingSystem
==
'windows'
?
'APPDATA'
:
'HOME'
;
String
value
=
p
latform
.
environment
[
envKey
];
return
value
==
null
?
'.'
:
value
;
}
packages/flutter_tools/lib/src/base/io.dart
View file @
417c2f25
...
...
@@ -11,16 +11,20 @@
/// access with mockable (or in-memory) file systems, making our tests hermetic
/// vis-a-vis file system access.
///
/// To ensure that all file system access within Flutter tools goes through the
/// proper APIs, we forbid direct imports of `dart:io` (via a test), forcing
/// all callers to instead import this file, which exports the blessed subset
/// of `dart:io` that is legal to use in Flutter tools.
/// We also use `package:platform` to provide an abstraction away from the
/// static methods in the `dart:io` `Platform` class (see `platform.dart`). As
/// such, do not export Platform from this file!
///
/// Because of the nature of this file, it is important that **no file APIs
/// be exported from `dart:io` in this file**! Moreover, be careful about any
/// additional exports that you add to this file, as doing so will increase the
/// API surface that we have to test in Flutter tools, and the APIs in `dart:io`
/// can sometimes be hard to use in tests.
/// To ensure that all file system and platform API access within Flutter tools
/// goes through the proper APIs, we forbid direct imports of `dart:io` (via a
/// test), forcing all callers to instead import this file, which exports the
/// blessed subset of `dart:io` that is legal to use in Flutter tools.
///
/// Because of the nature of this file, it is important that **platform and file
/// APIs not be exported from `dart:io` in this file**! Moreover, be careful
/// about any additional exports that you add to this file, as doing so will
/// increase the API surface that we have to test in Flutter tools, and the APIs
/// in `dart:io` can sometimes be hard to use in tests.
import
'dart:io'
as
io
show
exit
,
exitCode
;
import
'package:meta/meta.dart'
;
...
...
@@ -28,7 +32,10 @@ import 'package:meta/meta.dart';
export
'dart:io'
show
BytesBuilder
,
// Directory NO! Use `file_system.dart`
exitCode
,
// File NO! Use `file_system.dart`
// FileSystemEntity NO! Use `file_system.dart`
GZIP
,
InternetAddress
,
IOException
,
...
...
@@ -40,13 +47,15 @@ export 'dart:io'
HttpRequest
,
HttpServer
,
HttpStatus
,
// Link NO! Use `file_system.dart`
pid
,
Platform
,
// Platform NO! use `platform.dart`
Process
,
ProcessException
,
ProcessResult
,
ProcessSignal
,
ProcessStartMode
,
// RandomAccessFile NO! Use `file_system.dart`
ServerSocket
,
stderr
,
stdin
,
...
...
packages/flutter_tools/lib/src/base/logger.dart
View file @
417c2f25
...
...
@@ -8,6 +8,7 @@ import 'dart:convert' show ASCII;
import
'package:stack_trace/stack_trace.dart'
;
import
'io.dart'
;
import
'platform.dart'
;
final
AnsiTerminal
terminal
=
new
AnsiTerminal
();
...
...
@@ -202,7 +203,7 @@ enum _LogType {
class
AnsiTerminal
{
AnsiTerminal
()
{
// TODO(devoncarew): This detection does not work for Windows.
String
term
=
P
latform
.
environment
[
'TERM'
];
String
term
=
p
latform
.
environment
[
'TERM'
];
supportsColor
=
term
!=
null
&&
term
!=
'dumb'
;
}
...
...
packages/flutter_tools/lib/src/base/os.dart
View file @
417c2f25
...
...
@@ -10,6 +10,7 @@ import 'package:path/path.dart' as path;
import
'context.dart'
;
import
'file_system.dart'
;
import
'io.dart'
;
import
'platform.dart'
;
import
'process.dart'
;
import
'process_manager.dart'
;
...
...
@@ -18,7 +19,7 @@ OperatingSystemUtils get os => context[OperatingSystemUtils];
abstract
class
OperatingSystemUtils
{
factory
OperatingSystemUtils
()
{
if
(
P
latform
.
isWindows
)
{
if
(
p
latform
.
isWindows
)
{
return
new
_WindowsUtils
();
}
else
{
return
new
_PosixUtils
();
...
...
@@ -27,8 +28,9 @@ abstract class OperatingSystemUtils {
OperatingSystemUtils
.
_private
();
String
get
operatingSystem
=>
Platform
.
operatingSystem
;
// TODO(tvolkert): Remove these and migrate callers to Platform
String
get
operatingSystem
=>
platform
.
operatingSystem
;
bool
get
isMacOS
=>
operatingSystem
==
'macos'
;
bool
get
isWindows
=>
operatingSystem
==
'windows'
;
bool
get
isLinux
=>
operatingSystem
==
'linux'
;
...
...
@@ -46,7 +48,7 @@ abstract class OperatingSystemUtils {
void
unzip
(
File
file
,
Directory
targetDirectory
);
/// Returns the name of the [binaryName] executable.
///
///
/// No-op on most OS.
/// On Windows it returns [binaryName].[winExtension], if [winExtension] is
/// specified, or [binaryName].exe otherwise.
...
...
packages/flutter_tools/lib/src/base/platform.dart
0 → 100644
View file @
417c2f25
// 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.
import
'package:platform/platform.dart'
;
import
'context.dart'
;
export
'package:platform/platform.dart'
;
const
Platform
_kLocalPlatform
=
const
LocalPlatform
();
Platform
get
platform
=>
context
==
null
?
_kLocalPlatform
:
context
[
Platform
];
packages/flutter_tools/lib/src/base/utils.dart
View file @
417c2f25
...
...
@@ -10,15 +10,15 @@ import 'package:crypto/crypto.dart';
import
'package:path/path.dart'
as
path
;
import
'file_system.dart'
;
import
'
io
.dart'
;
import
'
platform
.dart'
;
bool
get
isRunningOnBot
{
// https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables
// CHROME_HEADLESS is one property set on Flutter's Chrome Infra bots.
return
P
latform
.
environment
[
'TRAVIS'
]
==
'true'
||
P
latform
.
environment
[
'CONTINUOUS_INTEGRATION'
]
==
'true'
||
P
latform
.
environment
[
'CHROME_HEADLESS'
]
==
'1'
;
p
latform
.
environment
[
'TRAVIS'
]
==
'true'
||
p
latform
.
environment
[
'CONTINUOUS_INTEGRATION'
]
==
'true'
||
p
latform
.
environment
[
'CHROME_HEADLESS'
]
==
'1'
;
}
String
hex
(
List
<
int
>
bytes
)
{
...
...
packages/flutter_tools/lib/src/build_info.dart
View file @
417c2f25
...
...
@@ -5,7 +5,7 @@
import
'package:path/path.dart'
as
path
;
import
'base/context.dart'
;
import
'base/
io
.dart'
;
import
'base/
platform
.dart'
;
import
'base/utils.dart'
;
import
'globals.dart'
;
...
...
@@ -106,9 +106,9 @@ TargetPlatform getTargetPlatformForName(String platform) {
}
HostPlatform
getCurrentHostPlatform
(
)
{
if
(
P
latform
.
isMacOS
)
if
(
p
latform
.
isMacOS
)
return
HostPlatform
.
darwin_x64
;
if
(
P
latform
.
isLinux
)
if
(
p
latform
.
isLinux
)
return
HostPlatform
.
linux_x64
;
printError
(
'Unsupported host platform, defaulting to Linux'
);
...
...
packages/flutter_tools/lib/src/cache.dart
View file @
417c2f25
...
...
@@ -10,10 +10,10 @@ import 'package:path/path.dart' as path;
import
'base/context.dart'
;
import
'base/file_system.dart'
;
import
'base/io.dart'
;
import
'base/logger.dart'
;
import
'base/net.dart'
;
import
'base/os.dart'
;
import
'base/platform.dart'
;
import
'globals.dart'
;
/// A wrapper around the `bin/cache/` directory.
...
...
@@ -84,7 +84,7 @@ class Cache {
static
String
get
dartSdkVersion
{
if
(
_dartSdkVersion
==
null
)
{
_dartSdkVersion
=
P
latform
.
version
;
_dartSdkVersion
=
p
latform
.
version
;
}
return
_dartSdkVersion
;
}
...
...
@@ -265,9 +265,9 @@ class FlutterEngine {
if
(
cache
.
includeAllPlatforms
)
dirs
.
addAll
(<
String
>[
'ios'
,
'ios-profile'
,
'ios-release'
,
'linux-x64'
]);
else
if
(
P
latform
.
isMacOS
)
else
if
(
p
latform
.
isMacOS
)
dirs
.
addAll
(<
String
>[
'ios'
,
'ios-profile'
,
'ios-release'
]);
else
if
(
P
latform
.
isLinux
)
else
if
(
p
latform
.
isLinux
)
dirs
.
add
(
'linux-x64'
);
return
dirs
;
...
...
@@ -279,9 +279,9 @@ class FlutterEngine {
return
<
List
<
String
>>[]
..
addAll
(
_osxToolsDirs
)
..
addAll
(
_linuxToolsDirs
);
else
if
(
P
latform
.
isMacOS
)
else
if
(
p
latform
.
isMacOS
)
return
_osxToolsDirs
;
else
if
(
P
latform
.
isLinux
)
else
if
(
p
latform
.
isLinux
)
return
_linuxToolsDirs
;
else
return
<
List
<
String
>>[];
...
...
packages/flutter_tools/lib/src/commands/test.dart
View file @
417c2f25
...
...
@@ -11,6 +11,7 @@ import '../base/common.dart';
import
'../base/file_system.dart'
;
import
'../base/io.dart'
;
import
'../base/logger.dart'
;
import
'../base/platform.dart'
;
import
'../base/process_manager.dart'
;
import
'../base/os.dart'
;
import
'../cache.dart'
;
...
...
@@ -190,7 +191,7 @@ class TestCommand extends FlutterCommand {
}
testArgs
.
addAll
(
files
);
final
String
shellPath
=
tools
.
getHostToolPath
(
HostTool
.
SkyShell
)
??
P
latform
.
environment
[
'SKY_SHELL'
];
final
String
shellPath
=
tools
.
getHostToolPath
(
HostTool
.
SkyShell
)
??
p
latform
.
environment
[
'SKY_SHELL'
];
if
(!
fs
.
isFileSync
(
shellPath
))
throwToolExit
(
'Cannot find Flutter shell at
$shellPath
'
);
loader
.
installHook
(
shellPath:
shellPath
,
collector:
collector
,
debuggerMode:
argResults
[
'start-paused'
]);
...
...
packages/flutter_tools/lib/src/dart/sdk.dart
View file @
417c2f25
...
...
@@ -4,7 +4,7 @@
import
'package:path/path.dart'
as
path
;
import
'../base/
io
.dart'
;
import
'../base/
platform
.dart'
;
import
'../cache.dart'
;
/// Locate the Dart SDK.
...
...
@@ -16,5 +16,5 @@ String get dartSdkPath {
/// ==> `pub.bat`. The default SDK location can be overridden with a specified
/// [sdkLocation].
String
sdkBinaryName
(
String
name
,
{
String
sdkLocation
})
{
return
path
.
absolute
(
path
.
join
(
sdkLocation
??
dartSdkPath
,
'bin'
,
P
latform
.
isWindows
?
'
$name
.bat'
:
name
));
return
path
.
absolute
(
path
.
join
(
sdkLocation
??
dartSdkPath
,
'bin'
,
p
latform
.
isWindows
?
'
$name
.bat'
:
name
));
}
packages/flutter_tools/lib/src/device.dart
View file @
417c2f25
...
...
@@ -163,6 +163,8 @@ abstract class Device {
// supported by Flutter, and, if not, why.
String
supportMessage
()
=>
isSupported
()
?
"Supported"
:
"Unsupported"
;
// TODO(tvolkert): Rename to `targetPlatform`, and remove the "as p"
// aliases on the `platform.dart` imports where applicable.
TargetPlatform
get
platform
;
String
get
sdkNameAndVersion
;
...
...
packages/flutter_tools/lib/src/doctor.dart
View file @
417c2f25
...
...
@@ -3,16 +3,16 @@
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:convert'
show
UTF8
;
import
'package:archive/archive.dart'
;
import
'dart:convert'
show
UTF8
;
import
'package:path/path.dart'
as
path
;
import
'android/android_workflow.dart'
;
import
'base/common.dart'
;
import
'base/context.dart'
;
import
'base/file_system.dart'
;
import
'base/
io
.dart'
;
import
'base/
platform
.dart'
;
import
'device.dart'
;
import
'globals.dart'
;
import
'ios/ios_workflow.dart'
;
...
...
@@ -27,7 +27,7 @@ const Map<String, String> _osNames = const <String, String>{
};
String
osName
(
)
{
String
os
=
P
latform
.
operatingSystem
;
String
os
=
p
latform
.
operatingSystem
;
return
_osNames
.
containsKey
(
os
)
?
_osNames
[
os
]
:
os
;
}
...
...
@@ -182,7 +182,7 @@ class ValidationResult {
if
(
type
==
ValidationType
.
missing
)
return
'[x]'
;
else
if
(
type
==
ValidationType
.
installed
)
return
P
latform
.
isWindows
?
'[√]'
:
'[✓]'
;
return
p
latform
.
isWindows
?
'[√]'
:
'[✓]'
;
else
return
'[-]'
;
}
...
...
@@ -217,7 +217,7 @@ class _FlutterValidator extends DoctorValidator {
messages
.
add
(
new
ValidationMessage
(
'Engine revision
${version.engineRevisionShort}
'
));
messages
.
add
(
new
ValidationMessage
(
'Tools Dart version
${version.dartSdkVersion}
'
));
if
(
P
latform
.
isWindows
)
{
if
(
p
latform
.
isWindows
)
{
valid
=
ValidationType
.
missing
;
messages
.
add
(
new
ValidationMessage
.
error
(
...
...
@@ -254,9 +254,9 @@ abstract class IntelliJValidator extends DoctorValidator {
};
static
Iterable
<
DoctorValidator
>
get
installedValidators
{
if
(
Platform
.
isLinux
||
P
latform
.
isWindows
)
if
(
platform
.
isLinux
||
p
latform
.
isWindows
)
return
IntelliJValidatorOnLinuxAndWindows
.
installed
;
if
(
P
latform
.
isMacOS
)
if
(
p
latform
.
isMacOS
)
return
IntelliJValidatorOnMac
.
installed
;
return
<
DoctorValidator
>[];
}
...
...
packages/flutter_tools/lib/src/ios/devices.dart
View file @
417c2f25
...
...
@@ -9,6 +9,7 @@ import '../application_package.dart';
import
'../base/file_system.dart'
;
import
'../base/io.dart'
;
import
'../base/os.dart'
;
import
'../base/platform.dart'
as
p
;
import
'../base/process.dart'
;
import
'../base/process_manager.dart'
;
import
'../build_info.dart'
;
...
...
@@ -28,7 +29,7 @@ class IOSDevices extends PollingDeviceDiscovery {
IOSDevices
()
:
super
(
'IOSDevices'
);
@override
bool
get
supportsPlatform
=>
P
latform
.
isMacOS
;
bool
get
supportsPlatform
=>
p
.
p
latform
.
isMacOS
;
@override
List
<
Device
>
pollingGetDevices
()
=>
IOSDevice
.
getAttachedDevices
();
...
...
@@ -125,7 +126,7 @@ class IOSDevice extends Device {
try
{
command
=
runCheckedSync
(<
String
>[
'which'
,
command
]).
trim
();
}
catch
(
e
)
{
if
(
P
latform
.
isMacOS
)
{
if
(
p
.
p
latform
.
isMacOS
)
{
printError
(
'
$command
not found.
$macInstructions
'
);
}
else
{
printError
(
'Cannot control iOS devices or simulators.
$command
is not available on your platform.'
);
...
...
@@ -314,7 +315,7 @@ class IOSDevice extends Device {
}
Future
<
bool
>
pushFile
(
ApplicationPackage
app
,
String
localFile
,
String
targetFile
)
async
{
if
(
P
latform
.
isMacOS
)
{
if
(
p
.
p
latform
.
isMacOS
)
{
runSync
(<
String
>[
pusherPath
,
'-t'
,
...
...
packages/flutter_tools/lib/src/ios/ios_workflow.dart
View file @
417c2f25
...
...
@@ -6,6 +6,7 @@ import 'dart:async';
import
'../base/io.dart'
;
import
'../base/os.dart'
;
import
'../base/platform.dart'
;
import
'../base/process.dart'
;
import
'../doctor.dart'
;
import
'mac.dart'
;
...
...
@@ -16,7 +17,7 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
IOSWorkflow
()
:
super
(
'iOS toolchain - develop for iOS devices'
);
@override
bool
get
appliesToHostPlatform
=>
P
latform
.
isMacOS
;
bool
get
appliesToHostPlatform
=>
p
latform
.
isMacOS
;
// We need xcode (+simctl) to list simulator devices, and idevice_id to list real devices.
@override
...
...
packages/flutter_tools/lib/src/ios/mac.dart
View file @
417c2f25
...
...
@@ -11,6 +11,7 @@ import '../application_package.dart';
import
'../base/context.dart'
;
import
'../base/file_system.dart'
;
import
'../base/io.dart'
;
import
'../base/platform.dart'
;
import
'../base/process.dart'
;
import
'../base/process_manager.dart'
;
import
'../build_info.dart'
;
...
...
@@ -220,7 +221,7 @@ final RegExp _xcodeVersionRegExp = new RegExp(r'Xcode (\d+)\..*');
final
String
_xcodeRequirement
=
'Xcode 7.0 or greater is required to develop for iOS.'
;
bool
_checkXcodeVersion
(
)
{
if
(!
P
latform
.
isMacOS
)
if
(!
p
latform
.
isMacOS
)
return
false
;
try
{
String
version
=
runCheckedSync
(<
String
>[
'xcodebuild'
,
'-version'
]);
...
...
packages/flutter_tools/lib/src/ios/simulators.dart
View file @
417c2f25
...
...
@@ -13,6 +13,7 @@ import '../base/common.dart';
import
'../base/context.dart'
;
import
'../base/file_system.dart'
;
import
'../base/io.dart'
;
import
'../base/platform.dart'
as
p
;
import
'../base/process.dart'
;
import
'../base/process_manager.dart'
;
import
'../build_info.dart'
;
...
...
@@ -31,7 +32,7 @@ class IOSSimulators extends PollingDeviceDiscovery {
IOSSimulators
()
:
super
(
'IOSSimulators'
);
@override
bool
get
supportsPlatform
=>
P
latform
.
isMacOS
;
bool
get
supportsPlatform
=>
p
.
p
latform
.
isMacOS
;
@override
List
<
Device
>
pollingGetDevices
()
=>
IOSSimulatorUtils
.
instance
.
getAttachedDevices
();
...
...
@@ -359,7 +360,7 @@ class IOSSimulator extends Device {
@override
bool
isSupported
()
{
if
(!
P
latform
.
isMacOS
)
{
if
(!
p
.
p
latform
.
isMacOS
)
{
_supportMessage
=
"Not supported on a non Mac host"
;
return
false
;
}
...
...
@@ -532,7 +533,7 @@ class IOSSimulator extends Device {
Future
<
bool
>
pushFile
(
ApplicationPackage
app
,
String
localFile
,
String
targetFile
)
async
{
if
(
P
latform
.
isMacOS
)
{
if
(
p
.
p
latform
.
isMacOS
)
{
String
simulatorHomeDirectory
=
_getSimulatorAppHomeDirectory
(
app
);
runCheckedSync
(<
String
>[
'cp'
,
localFile
,
path
.
join
(
simulatorHomeDirectory
,
targetFile
)]);
return
true
;
...
...
packages/flutter_tools/lib/src/runner/flutter_command_runner.dart
View file @
417c2f25
...
...
@@ -12,8 +12,8 @@ import '../android/android_sdk.dart';
import
'../base/common.dart'
;
import
'../base/context.dart'
;
import
'../base/file_system.dart'
;
import
'../base/io.dart'
;
import
'../base/logger.dart'
;
import
'../base/platform.dart'
;
import
'../base/process.dart'
;
import
'../base/process_manager.dart'
;
import
'../cache.dart'
;
...
...
@@ -117,12 +117,12 @@ class FlutterCommandRunner extends CommandRunner<Null> {
}
static
String
get
_defaultFlutterRoot
{
if
(
P
latform
.
environment
.
containsKey
(
kFlutterRootEnvironmentVariableName
))
return
P
latform
.
environment
[
kFlutterRootEnvironmentVariableName
];
if
(
p
latform
.
environment
.
containsKey
(
kFlutterRootEnvironmentVariableName
))
return
p
latform
.
environment
[
kFlutterRootEnvironmentVariableName
];
try
{
if
(
P
latform
.
script
.
scheme
==
'data'
)
if
(
p
latform
.
script
.
scheme
==
'data'
)
return
'../..'
;
// we're running as a test
String
script
=
P
latform
.
script
.
toFilePath
();
String
script
=
p
latform
.
script
.
toFilePath
();
if
(
path
.
basename
(
script
)
==
kSnapshotFileName
)
return
path
.
dirname
(
path
.
dirname
(
path
.
dirname
(
script
)));
if
(
path
.
basename
(
script
)
==
kFlutterToolsScriptFileName
)
...
...
@@ -179,7 +179,7 @@ class FlutterCommandRunner extends CommandRunner<Null> {
// enginePath's initialiser uses it).
Cache
.
flutterRoot
=
path
.
normalize
(
path
.
absolute
(
globalResults
[
'flutter-root'
]));
if
(
P
latform
.
environment
[
'FLUTTER_ALREADY_LOCKED'
]
!=
'true'
)
if
(
p
latform
.
environment
[
'FLUTTER_ALREADY_LOCKED'
]
!=
'true'
)
await
Cache
.
lock
();
if
(
globalResults
[
'suppress-analytics'
])
...
...
@@ -219,7 +219,7 @@ class FlutterCommandRunner extends CommandRunner<Null> {
}
String
_findEnginePath
(
ArgResults
globalResults
)
{
String
engineSourcePath
=
globalResults
[
'local-engine-src-path'
]
??
P
latform
.
environment
[
kFlutterEngineEnvironmentVariableName
];
String
engineSourcePath
=
globalResults
[
'local-engine-src-path'
]
??
p
latform
.
environment
[
kFlutterEngineEnvironmentVariableName
];
if
(
engineSourcePath
==
null
&&
globalResults
[
'local-engine'
]
!=
null
)
{
try
{
...
...
packages/flutter_tools/pubspec.yaml
View file @
417c2f25
...
...
@@ -22,6 +22,7 @@ dependencies:
mustache
:
^0.2.5
package_config
:
'
>=0.1.5
<2.0.0'
path
:
^1.4.0
platform
:
1.0.1
process
:
1.0.1
pub_semver
:
^1.0.0
stack_trace
:
^1.4.0
...
...
packages/flutter_tools/test/daemon_test.dart
View file @
417c2f25
...
...
@@ -5,8 +5,8 @@
import
'dart:async'
;
import
'package:flutter_tools/src/base/context.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/commands/daemon.dart'
;
import
'package:flutter_tools/src/device.dart'
;
import
'package:flutter_tools/src/doctor.dart'
;
...
...
@@ -32,9 +32,10 @@ void main() {
setUp
(()
{
appContext
=
new
AppContext
();
notifyingLogger
=
new
NotifyingLogger
();
appContext
.
setVariable
(
Platform
,
new
LocalPlatform
());
appContext
.
setVariable
(
Logger
,
notifyingLogger
);
appContext
.
setVariable
(
Doctor
,
new
Doctor
());
if
(
P
latform
.
isMacOS
)
if
(
p
latform
.
isMacOS
)
appContext
.
setVariable
(
XCode
,
new
XCode
());
appContext
.
setVariable
(
DeviceManager
,
new
MockDeviceManager
());
});
...
...
packages/flutter_tools/test/dart_dependencies_test.dart
View file @
417c2f25
...
...
@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/dart/dependencies.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:path/path.dart'
as
path
;
import
'package:test/test.dart'
;
import
'src/context.dart'
;
void
main
(
)
{
group
(
'DartDependencySetBuilder'
,
()
{
final
String
basePath
=
path
.
dirname
(
P
latform
.
script
.
path
);
final
String
basePath
=
path
.
dirname
(
p
latform
.
script
.
path
);
final
String
dataPath
=
path
.
join
(
basePath
,
'data'
,
'dart_dependencies_test'
);
testUsingContext
(
'good'
,
()
{
final
String
testPath
=
path
.
join
(
dataPath
,
'good'
);
...
...
packages/flutter_tools/test/dependency_checker_test.dart
View file @
417c2f25
...
...
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter_tools/src/base/
io
.dart'
;
import
'package:flutter_tools/src/base/
platform
.dart'
;
import
'package:flutter_tools/src/dart/dependencies.dart'
;
import
'package:flutter_tools/src/dependency_checker.dart'
;
import
'package:path/path.dart'
as
path
;
...
...
@@ -12,7 +12,7 @@ import 'src/context.dart';
void
main
(
)
{
group
(
'DependencyChecker'
,
()
{
final
String
basePath
=
path
.
dirname
(
P
latform
.
script
.
path
);
final
String
basePath
=
path
.
dirname
(
p
latform
.
script
.
path
);
final
String
dataPath
=
path
.
join
(
basePath
,
'data'
,
'dart_dependencies_test'
);
testUsingContext
(
'good'
,
()
{
final
String
testPath
=
path
.
join
(
dataPath
,
'good'
);
...
...
packages/flutter_tools/test/forbid_dart_io_test.dart
View file @
417c2f25
...
...
@@ -3,12 +3,12 @@
// found in the LICENSE file.
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/
io
.dart'
;
import
'package:flutter_tools/src/base/
platform
.dart'
;
import
'package:test/test.dart'
;
void
main
(
)
{
setUp
(()
{
String
flutterRoot
=
P
latform
.
environment
[
'FLUTTER_ROOT'
];
String
flutterRoot
=
p
latform
.
environment
[
'FLUTTER_ROOT'
];
assert
(
fs
.
currentDirectory
.
path
==
'
$flutterRoot
/packages/flutter_tools'
);
});
...
...
packages/flutter_tools/test/os_utils_test.dart
View file @
417c2f25
...
...
@@ -3,8 +3,8 @@
// found in the LICENSE file.
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/os.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:path/path.dart'
as
path
;
import
'package:test/test.dart'
;
...
...
@@ -28,7 +28,7 @@ void main() {
os
.
makeExecutable
(
file
);
// Skip this test on windows.
if
(!
P
latform
.
isWindows
)
{
if
(!
p
latform
.
isWindows
)
{
String
mode
=
file
.
statSync
().
modeString
();
// rwxr--r--
expect
(
mode
.
substring
(
0
,
3
),
endsWith
(
'x'
));
...
...
packages/flutter_tools/test/src/context.dart
View file @
417c2f25
...
...
@@ -7,9 +7,9 @@ import 'dart:async';
import
'package:flutter_tools/src/base/config.dart'
;
import
'package:flutter_tools/src/base/context.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/os.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/device.dart'
;
import
'package:flutter_tools/src/devfs.dart'
;
...
...
@@ -42,6 +42,7 @@ void testUsingContext(String description, dynamic testMethod(), {
// Initialize the test context with some default mocks.
// Seed these context entries first since others depend on them
testContext
.
putIfAbsent
(
Platform
,
()
=>
new
LocalPlatform
());
testContext
.
putIfAbsent
(
FileSystem
,
()
=>
new
LocalFileSystem
());
testContext
.
putIfAbsent
(
ProcessManager
,
()
=>
new
LocalProcessManager
());
testContext
.
putIfAbsent
(
Logger
,
()
=>
new
BufferLogger
());
...
...
@@ -68,7 +69,7 @@ void testUsingContext(String description, dynamic testMethod(), {
testContext
.
putIfAbsent
(
SimControl
,
()
=>
new
MockSimControl
());
testContext
.
putIfAbsent
(
Usage
,
()
=>
new
MockUsage
());
final
String
basePath
=
path
.
dirname
(
P
latform
.
script
.
path
);
final
String
basePath
=
path
.
dirname
(
p
latform
.
script
.
path
);
final
String
flutterRoot
=
path
.
normalize
(
path
.
join
(
basePath
,
'..'
,
'..'
,
'..'
));
try
{
...
...
@@ -148,7 +149,7 @@ class MockOperatingSystemUtils extends Mock implements OperatingSystemUtils {
// That way it wouldn't really matter what the mock returns here.
@override
String
getExecutableName
(
String
binaryName
,
{
String
winExtension
})
{
if
(!
P
latform
.
isWindows
)
if
(!
p
latform
.
isWindows
)
return
binaryName
;
winExtension
??=
'exe'
;
if
(
path
.
extension
(
binaryName
).
isEmpty
&&
winExtension
.
isNotEmpty
)
...
...
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