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
398ac1f6
Unverified
Commit
398ac1f6
authored
Aug 20, 2019
by
Zachary Anderson
Committed by
GitHub
Aug 20, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tool] Remove some async file io (#38654)
parent
28bedb10
Changes
23
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
204 additions
and
198 deletions
+204
-198
runner.dart
packages/flutter_tools/lib/runner.dart
+2
-2
asset.dart
packages/flutter_tools/lib/src/asset.dart
+27
-25
build.dart
packages/flutter_tools/lib/src/base/build.dart
+3
-3
fingerprint.dart
packages/flutter_tools/lib/src/base/fingerprint.dart
+12
-14
platform.dart
packages/flutter_tools/lib/src/base/platform.dart
+4
-6
process.dart
packages/flutter_tools/lib/src/base/process.dart
+7
-3
build_runner.dart
...ages/flutter_tools/lib/src/build_runner/build_runner.dart
+1
-1
build_script.dart
...ages/flutter_tools/lib/src/build_runner/build_script.dart
+3
-4
build_script_generator.dart
...er_tools/lib/src/build_runner/build_script_generator.dart
+2
-2
bundle.dart
packages/flutter_tools/lib/src/bundle.dart
+2
-2
create.dart
packages/flutter_tools/lib/src/commands/create.dart
+5
-5
packages.dart
packages/flutter_tools/lib/src/commands/packages.dart
+2
-2
screenshot.dart
packages/flutter_tools/lib/src/commands/screenshot.dart
+16
-14
mac.dart
packages/flutter_tools/lib/src/ios/mac.dart
+5
-5
cocoapod_utils.dart
packages/flutter_tools/lib/src/macos/cocoapod_utils.dart
+2
-2
cocoapods.dart
packages/flutter_tools/lib/src/macos/cocoapods.dart
+1
-1
resident_runner.dart
packages/flutter_tools/lib/src/resident_runner.dart
+1
-1
flutter_command_runner.dart
.../flutter_tools/lib/src/runner/flutter_command_runner.dart
+5
-5
tracing.dart
packages/flutter_tools/lib/src/tracing.dart
+6
-4
version.dart
packages/flutter_tools/lib/src/version.dart
+2
-1
vmservice_record_replay.dart
packages/flutter_tools/lib/src/vmservice_record_replay.dart
+2
-2
fingerprint_test.dart
...utter_tools/test/general.shard/base/fingerprint_test.dart
+83
-83
mac_test.dart
packages/flutter_tools/test/general.shard/ios/mac_test.dart
+11
-11
No files found.
packages/flutter_tools/lib/runner.dart
View file @
398ac1f6
...
...
@@ -179,12 +179,12 @@ Future<File> _createLocalCrashReport(List<String> args, dynamic error, StackTrac
buffer
.
writeln
(
'```
\n
${await _doctorText()}
```'
);
try
{
await
crashFile
.
writeAsString
(
buffer
.
toString
());
crashFile
.
writeAsStringSync
(
buffer
.
toString
());
}
on
FileSystemException
catch
(
_
)
{
// Fallback to the system temporary directory.
crashFile
=
getUniqueFile
(
crashFileSystem
.
systemTempDirectory
,
'flutter'
,
'log'
);
try
{
await
crashFile
.
writeAsString
(
buffer
.
toString
());
crashFile
.
writeAsStringSync
(
buffer
.
toString
());
}
on
FileSystemException
catch
(
e
)
{
printError
(
'Could not write crash report to disk:
$e
'
);
printError
(
buffer
.
toString
());
...
...
packages/flutter_tools/lib/src/asset.dart
View file @
398ac1f6
...
...
@@ -235,7 +235,7 @@ class _ManifestAssetBundle implements AssetBundle {
entries
[
_fontManifestJson
]
=
DevFSStringContent
(
json
.
encode
(
fonts
));
// TODO(ianh): Only do the following line if we've changed packages or if our LICENSE file changed
entries
[
_license
]
=
await
_obtainLicenses
(
packageMap
,
assetBasePath
,
reportPackages:
reportLicensedPackages
);
entries
[
_license
]
=
_obtainLicenses
(
packageMap
,
assetBasePath
,
reportPackages:
reportLicensedPackages
);
return
0
;
}
...
...
@@ -325,11 +325,11 @@ List<_Asset> _getMaterialAssets(String fontSet) {
final
String
_licenseSeparator
=
'
\n
'
+
(
'-'
*
80
)
+
'
\n
'
;
/// Returns a DevFSContent representing the license file.
Future
<
DevFSContent
>
_obtainLicenses
(
DevFSContent
_obtainLicenses
(
PackageMap
packageMap
,
String
assetBase
,
{
bool
reportPackages
,
})
async
{
})
{
// Read the LICENSE file from each package in the .packages file, splitting
// each one into each component license (so that we can de-dupe if possible).
//
...
...
@@ -347,30 +347,32 @@ Future<DevFSContent> _obtainLicenses(
final
Set
<
String
>
allPackages
=
<
String
>{};
for
(
String
packageName
in
packageMap
.
map
.
keys
)
{
final
Uri
package
=
packageMap
.
map
[
packageName
];
if
(
package
!=
null
&&
package
.
scheme
==
'file'
)
{
final
File
file
=
fs
.
file
(
package
.
resolve
(
'../LICENSE'
));
if
(
file
.
existsSync
())
{
final
List
<
String
>
rawLicenses
=
(
await
file
.
readAsString
()).
split
(
_licenseSeparator
);
for
(
String
rawLicense
in
rawLicenses
)
{
List
<
String
>
packageNames
;
String
licenseText
;
if
(
rawLicenses
.
length
>
1
)
{
final
int
split
=
rawLicense
.
indexOf
(
'
\n\n
'
);
if
(
split
>=
0
)
{
packageNames
=
rawLicense
.
substring
(
0
,
split
).
split
(
'
\n
'
);
licenseText
=
rawLicense
.
substring
(
split
+
2
);
}
}
if
(
licenseText
==
null
)
{
packageNames
=
<
String
>[
packageName
];
licenseText
=
rawLicense
;
}
packageLicenses
.
putIfAbsent
(
licenseText
,
()
=>
<
String
>{})
..
addAll
(
packageNames
);
allPackages
.
addAll
(
packageNames
);
if
(
package
==
null
||
package
.
scheme
!=
'file'
)
{
continue
;
}
final
File
file
=
fs
.
file
(
package
.
resolve
(
'../LICENSE'
));
if
(!
file
.
existsSync
())
{
continue
;
}
final
List
<
String
>
rawLicenses
=
file
.
readAsStringSync
().
split
(
_licenseSeparator
);
for
(
String
rawLicense
in
rawLicenses
)
{
List
<
String
>
packageNames
;
String
licenseText
;
if
(
rawLicenses
.
length
>
1
)
{
final
int
split
=
rawLicense
.
indexOf
(
'
\n\n
'
);
if
(
split
>=
0
)
{
packageNames
=
rawLicense
.
substring
(
0
,
split
).
split
(
'
\n
'
);
licenseText
=
rawLicense
.
substring
(
split
+
2
);
}
}
if
(
licenseText
==
null
)
{
packageNames
=
<
String
>[
packageName
];
licenseText
=
rawLicense
;
}
packageLicenses
.
putIfAbsent
(
licenseText
,
()
=>
<
String
>{})
..
addAll
(
packageNames
);
allPackages
.
addAll
(
packageNames
);
}
}
...
...
packages/flutter_tools/lib/src/base/build.dart
View file @
398ac1f6
...
...
@@ -180,7 +180,7 @@ class AOTSnapshotter {
// gen_snapshot would provide an argument to do this automatically.
if
(
platform
==
TargetPlatform
.
ios
&&
bitcode
)
{
final
IOSink
sink
=
fs
.
file
(
'
$assembly
.bitcode'
).
openWrite
();
for
(
String
line
in
await
fs
.
file
(
assembly
).
readAsLines
())
{
for
(
String
line
in
fs
.
file
(
assembly
).
readAsLinesSync
())
{
if
(
line
.
startsWith
(
'.section __DWARF'
))
{
break
;
}
...
...
@@ -192,7 +192,7 @@ class AOTSnapshotter {
// Write path to gen_snapshot, since snapshots have to be re-generated when we roll
// the Dart SDK.
final
String
genSnapshotPath
=
GenSnapshot
.
getSnapshotterPath
(
snapshotType
);
await
outputDir
.
childFile
(
'gen_snapshot.d'
).
writeAsString
(
'gen_snapshot.d:
$genSnapshotPath
\n
'
);
outputDir
.
childFile
(
'gen_snapshot.d'
).
writeAsStringSync
(
'gen_snapshot.d:
$genSnapshotPath
\n
'
);
// On iOS, we use Xcode to compile the snapshot into a dynamic library that the
// end-developer can link into their app.
...
...
@@ -313,7 +313,7 @@ class AOTSnapshotter {
// Write path to frontend_server, since things need to be re-generated when that changes.
final
String
frontendPath
=
artifacts
.
getArtifactPath
(
Artifact
.
frontendServerSnapshotForEngineDartSdk
);
await
fs
.
directory
(
outputPath
).
childFile
(
'frontend_server.d'
).
writeAsString
(
'frontend_server.d:
$frontendPath
\n
'
);
fs
.
directory
(
outputPath
).
childFile
(
'frontend_server.d'
).
writeAsStringSync
(
'frontend_server.d:
$frontendPath
\n
'
);
return
compilerOutput
?.
outputFilename
;
}
...
...
packages/flutter_tools/lib/src/base/fingerprint.dart
View file @
398ac1f6
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'package:crypto/crypto.dart'
show
md5
;
import
'package:meta/meta.dart'
;
import
'package:quiver/core.dart'
show
hash2
;
...
...
@@ -52,12 +50,12 @@ class Fingerprinter {
final
List
<
String
>
_depfilePaths
;
final
FingerprintPathFilter
_pathFilter
;
F
uture
<
Fingerprint
>
buildFingerprint
()
async
{
final
List
<
String
>
paths
=
await
_getPaths
();
F
ingerprint
buildFingerprint
()
{
final
List
<
String
>
paths
=
_getPaths
();
return
Fingerprint
.
fromBuildInputs
(
_properties
,
paths
);
}
Future
<
bool
>
doesFingerprintMatch
()
async
{
bool
doesFingerprintMatch
()
{
if
(
_disableBuildCache
)
{
return
false
;
}
...
...
@@ -69,12 +67,12 @@ class Fingerprinter {
if
(!
_depfilePaths
.
every
(
fs
.
isFileSync
))
return
false
;
final
List
<
String
>
paths
=
await
_getPaths
();
final
List
<
String
>
paths
=
_getPaths
();
if
(!
paths
.
every
(
fs
.
isFileSync
))
return
false
;
final
Fingerprint
oldFingerprint
=
Fingerprint
.
fromJson
(
await
fingerprintFile
.
readAsString
());
final
Fingerprint
newFingerprint
=
await
buildFingerprint
();
final
Fingerprint
oldFingerprint
=
Fingerprint
.
fromJson
(
fingerprintFile
.
readAsStringSync
());
final
Fingerprint
newFingerprint
=
buildFingerprint
();
return
oldFingerprint
==
newFingerprint
;
}
catch
(
e
)
{
// Log exception and continue, fingerprinting is only a performance improvement.
...
...
@@ -83,9 +81,9 @@ class Fingerprinter {
return
false
;
}
Future
<
void
>
writeFingerprint
()
async
{
void
writeFingerprint
()
{
try
{
final
Fingerprint
fingerprint
=
await
buildFingerprint
();
final
Fingerprint
fingerprint
=
buildFingerprint
();
fs
.
file
(
fingerprintPath
).
writeAsStringSync
(
fingerprint
.
toJson
());
}
catch
(
e
)
{
// Log exception and continue, fingerprinting is only a performance improvement.
...
...
@@ -93,11 +91,11 @@ class Fingerprinter {
}
}
Future
<
List
<
String
>>
_getPaths
()
async
{
List
<
String
>
_getPaths
()
{
final
Set
<
String
>
paths
=
<
String
>{
...
_paths
,
for
(
String
depfilePath
in
_depfilePaths
)
...
await
readDepfile
(
depfilePath
),
...
readDepfile
(
depfilePath
),
};
final
FingerprintPathFilter
filter
=
_pathFilter
??
(
String
path
)
=>
true
;
return
paths
.
where
(
filter
).
toList
()..
sort
();
...
...
@@ -183,10 +181,10 @@ final RegExp _escapeExpr = RegExp(r'\\(.)');
/// outfile : file1.dart fil\\e2.dart fil\ e3.dart
///
/// will return a set containing: 'file1.dart', 'fil\e2.dart', 'fil e3.dart'.
Future
<
Set
<
String
>>
readDepfile
(
String
depfilePath
)
async
{
Set
<
String
>
readDepfile
(
String
depfilePath
)
{
// Depfile format:
// outfile1 outfile2 : file1.dart file2.dart file3.dart
final
String
contents
=
await
fs
.
file
(
depfilePath
).
readAsString
();
final
String
contents
=
fs
.
file
(
depfilePath
).
readAsStringSync
();
final
String
dependencies
=
contents
.
split
(
': '
)[
1
];
return
dependencies
...
...
packages/flutter_tools/lib/src/base/platform.dart
View file @
398ac1f6
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'package:platform/platform.dart'
;
import
'context.dart'
;
...
...
@@ -25,17 +23,17 @@ Platform get platform => context.get<Platform>() ?? _kLocalPlatform;
/// subdirectory.
///
/// Returns the existing platform.
Future
<
Platform
>
getRecordingPlatform
(
String
location
)
async
{
Platform
getRecordingPlatform
(
String
location
)
{
final
Directory
dir
=
getRecordingSink
(
location
,
_kRecordingType
);
final
File
file
=
_getPlatformManifest
(
dir
);
await
file
.
writeAsString
(
platform
.
toJson
(),
flush:
true
);
file
.
writeAsStringSync
(
platform
.
toJson
(),
flush:
true
);
return
platform
;
}
F
uture
<
FakePlatform
>
getReplayPlatform
(
String
location
)
async
{
F
akePlatform
getReplayPlatform
(
String
location
)
{
final
Directory
dir
=
getReplaySource
(
location
,
_kRecordingType
);
final
File
file
=
_getPlatformManifest
(
dir
);
final
String
json
=
await
file
.
readAsString
();
final
String
json
=
file
.
readAsStringSync
();
return
FakePlatform
.
fromJson
(
json
);
}
...
...
packages/flutter_tools/lib/src/base/process.dart
View file @
398ac1f6
...
...
@@ -15,7 +15,7 @@ import 'utils.dart';
typedef
StringConverter
=
String
Function
(
String
string
);
/// A function that will be run before the VM exits.
typedef
ShutdownHook
=
Future
<
dynamic
>
Function
();
typedef
ShutdownHook
=
Future
Or
<
dynamic
>
Function
();
// TODO(ianh): We have way too many ways to run subprocesses in this project.
// Convert most of these into one or more lightweight wrappers around the
...
...
@@ -83,8 +83,12 @@ Future<void> runShutdownHooks() async {
printTrace
(
'Shutdown hook priority
${stage.priority}
'
);
final
List
<
ShutdownHook
>
hooks
=
_shutdownHooks
.
remove
(
stage
);
final
List
<
Future
<
dynamic
>>
futures
=
<
Future
<
dynamic
>>[];
for
(
ShutdownHook
shutdownHook
in
hooks
)
futures
.
add
(
shutdownHook
());
for
(
ShutdownHook
shutdownHook
in
hooks
)
{
final
FutureOr
<
dynamic
>
result
=
shutdownHook
();
if
(
result
is
Future
<
dynamic
>)
{
futures
.
add
(
result
);
}
}
await
Future
.
wait
<
dynamic
>(
futures
);
}
}
finally
{
...
...
packages/flutter_tools/lib/src/build_runner/build_runner.dart
View file @
398ac1f6
...
...
@@ -102,7 +102,7 @@ class BuildRunner extends CodeGenerator {
}
stringBuffer
.
writeln
(
' build_runner: ^
$kMinimumBuildRunnerVersion
'
);
stringBuffer
.
writeln
(
' build_daemon:
$kSupportedBuildDaemonVersion
'
);
await
syntheticPubspec
.
writeAsString
(
stringBuffer
.
toString
());
syntheticPubspec
.
writeAsStringSync
(
stringBuffer
.
toString
());
await
pubGet
(
context:
PubContext
.
pubGet
,
...
...
packages/flutter_tools/lib/src/build_runner/build_script.dart
View file @
398ac1f6
...
...
@@ -376,7 +376,7 @@ Future<void> bootstrapDart2Js(BuildStep buildStep, String flutterWebSdk) async {
final Iterable<AssetId> allSrcs = allDeps.expand((Module module) => module.sources);
await scratchSpace.ensureAssets(allSrcs, buildStep);
final String packageFile =
await
_createPackageFile(allSrcs, buildStep, scratchSpace);
final String packageFile = _createPackageFile(allSrcs, buildStep, scratchSpace);
final String dartPath = dartEntrypointId.path.startsWith('
lib
/
')
? '
package:
$
{
dartEntrypointId
.
package
}/
'
'
$
{
dartEntrypointId
.
path
.
substring
(
'lib/'
.
length
)}
'
...
...
@@ -430,7 +430,7 @@ Future<void> _copyIfExists(
/// The filename is based off the MD5 hash of the asset path so that files are
/// unique regarless of situations like `web/foo/bar.dart` vs
/// `web/foo-bar.dart`.
Future
<
String
>
_createPackageFile
(
Iterable
<
AssetId
>
inputSources
,
BuildStep
buildStep
,
ScratchSpace
scratchSpace
)
async
{
String
_createPackageFile
(
Iterable
<
AssetId
>
inputSources
,
BuildStep
buildStep
,
ScratchSpace
scratchSpace
)
{
final
Uri
inputUri
=
buildStep
.
inputId
.
uri
;
final
String
packageFileName
=
'.package-
${md5.convert(inputUri.toString().codeUnits)}
'
;
...
...
@@ -439,8 +439,7 @@ Future<String> _createPackageFile(Iterable<AssetId> inputSources, BuildStep buil
final
Set
<
String
>
packageNames
=
inputSources
.
map
((
AssetId
s
)
=>
s
.
package
).
toSet
();
final
String
packagesFileContent
=
packageNames
.
map
((
String
name
)
=>
'
$name
:packages/
$name
/'
).
join
(
'
\n
'
);
await
packagesFile
.
writeAsString
(
'# Generated for
$inputUri
\n
$packagesFileContent
'
);
packagesFile
.
writeAsStringSync
(
'# Generated for
$inputUri
\n
$packagesFileContent
'
);
return
packageFileName
;
}
...
...
packages/flutter_tools/lib/src/build_runner/build_script_generator.dart
View file @
398ac1f6
...
...
@@ -49,8 +49,8 @@ class BuildScriptGenerator {
// ignore_for_file: directives_ordering
${library.accept(emitter)}
'''
);
final
File
output
=
fs
.
file
(
location
);
await
output
.
create
(
recursive:
true
);
await
fs
.
file
(
location
).
writeAsString
(
result
);
output
.
createSync
(
recursive:
true
);
fs
.
file
(
location
).
writeAsStringSync
(
result
);
}
on
FormatterException
{
throwToolExit
(
'Generated build script could not be parsed. '
'This is likely caused by a misconfigured builder definition.'
);
...
...
packages/flutter_tools/lib/src/bundle.dart
View file @
398ac1f6
...
...
@@ -99,8 +99,8 @@ class BundleBuilder {
}
kernelContent
=
DevFSFileContent
(
fs
.
file
(
compilerOutput
.
outputFilename
));
await
fs
.
directory
(
getBuildDirectory
()).
childFile
(
'frontend_server.d'
)
.
writeAsString
(
'frontend_server.d:
${artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk)}
\n
'
);
fs
.
directory
(
getBuildDirectory
()).
childFile
(
'frontend_server.d'
)
.
writeAsString
Sync
(
'frontend_server.d:
${artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk)}
\n
'
);
}
final
AssetBundle
assets
=
await
buildAssets
(
...
...
packages/flutter_tools/lib/src/commands/create.dart
View file @
398ac1f6
...
...
@@ -407,7 +407,7 @@ class CreateCommand extends FlutterCommand {
break
;
}
if
(
sampleCode
!=
null
)
{
generatedFileCount
+=
await
_applySample
(
relativeDir
,
sampleCode
);
generatedFileCount
+=
_applySample
(
relativeDir
,
sampleCode
);
}
printStatus
(
'Wrote
$generatedFileCount
files.'
);
printStatus
(
'
\n
All done!'
);
...
...
@@ -566,13 +566,13 @@ To edit platform code in an IDE see https://flutter.dev/developing-packages/#edi
// documentation website in sampleCode. Returns the difference in the number
// of files after applying the sample, since it also deletes the application's
// test directory (since the template's test doesn't apply to the sample).
Future
<
int
>
_applySample
(
Directory
directory
,
String
sampleCode
)
async
{
int
_applySample
(
Directory
directory
,
String
sampleCode
)
{
final
File
mainDartFile
=
directory
.
childDirectory
(
'lib'
).
childFile
(
'main.dart'
);
await
mainDartFile
.
create
(
recursive:
true
);
await
mainDartFile
.
writeAsString
(
sampleCode
);
mainDartFile
.
createSync
(
recursive:
true
);
mainDartFile
.
writeAsStringSync
(
sampleCode
);
final
Directory
testDir
=
directory
.
childDirectory
(
'test'
);
final
List
<
FileSystemEntity
>
files
=
testDir
.
listSync
(
recursive:
true
);
await
testDir
.
delete
(
recursive:
true
);
testDir
.
deleteSync
(
recursive:
true
);
return
-
files
.
length
;
}
...
...
packages/flutter_tools/lib/src/commands/packages.dart
View file @
398ac1f6
...
...
@@ -79,9 +79,9 @@ class PackagesGetCommand extends FlutterCommand {
return
usageValues
;
}
final
FlutterProject
rootProject
=
FlutterProject
.
fromPath
(
target
);
final
bool
hasPlugins
=
await
rootProject
.
flutterPluginsFile
.
exists
();
final
bool
hasPlugins
=
rootProject
.
flutterPluginsFile
.
existsSync
();
if
(
hasPlugins
)
{
final
int
numberOfPlugins
=
(
await
rootProject
.
flutterPluginsFile
.
readAsLines
()).
length
;
final
int
numberOfPlugins
=
(
rootProject
.
flutterPluginsFile
.
readAsLinesSync
()).
length
;
usageValues
[
CustomDimensions
.
commandPackagesNumberPlugins
]
=
'
$numberOfPlugins
'
;
}
else
{
usageValues
[
CustomDimensions
.
commandPackagesNumberPlugins
]
=
'0'
;
...
...
packages/flutter_tools/lib/src/commands/screenshot.dart
View file @
398ac1f6
...
...
@@ -106,7 +106,7 @@ class ScreenshotCommand extends FlutterCommand {
}
catch
(
error
)
{
throwToolExit
(
'Error taking screenshot:
$error
'
);
}
await
showOutputFileInfo
(
outputFile
);
_
showOutputFileInfo
(
outputFile
);
}
Future
<
void
>
runSkia
(
File
outputFile
)
async
{
...
...
@@ -115,8 +115,8 @@ class ScreenshotCommand extends FlutterCommand {
final
IOSink
sink
=
outputFile
.
openWrite
();
sink
.
add
(
base64
.
decode
(
skp
[
'skp'
]));
await
sink
.
close
();
await
showOutputFileInfo
(
outputFile
);
await
_ensureOutputIsNotJsonRpcError
(
outputFile
);
_
showOutputFileInfo
(
outputFile
);
_ensureOutputIsNotJsonRpcError
(
outputFile
);
}
Future
<
void
>
runRasterizer
(
File
outputFile
)
async
{
...
...
@@ -125,8 +125,8 @@ class ScreenshotCommand extends FlutterCommand {
final
IOSink
sink
=
outputFile
.
openWrite
();
sink
.
add
(
base64
.
decode
(
response
[
'screenshot'
]));
await
sink
.
close
();
await
showOutputFileInfo
(
outputFile
);
await
_ensureOutputIsNotJsonRpcError
(
outputFile
);
_
showOutputFileInfo
(
outputFile
);
_ensureOutputIsNotJsonRpcError
(
outputFile
);
}
Future
<
Map
<
String
,
dynamic
>>
_invokeVmServiceRpc
(
String
method
)
async
{
...
...
@@ -135,18 +135,20 @@ class ScreenshotCommand extends FlutterCommand {
return
await
vmService
.
vm
.
invokeRpcRaw
(
method
);
}
Future
<
void
>
_ensureOutputIsNotJsonRpcError
(
File
outputFile
)
async
{
if
(
await
outputFile
.
length
()
<
1000
)
{
final
String
content
=
await
outputFile
.
readAsString
(
encoding:
const
AsciiCodec
(
allowInvalid:
true
),
);
if
(
content
.
startsWith
(
'{"jsonrpc":"2.0", "error"'
))
throwToolExit
(
'
\n
It appears the output file contains an error message, not valid skia output.'
);
void
_ensureOutputIsNotJsonRpcError
(
File
outputFile
)
{
if
(
outputFile
.
lengthSync
()
>=
1000
)
{
return
;
}
final
String
content
=
outputFile
.
readAsStringSync
(
encoding:
const
AsciiCodec
(
allowInvalid:
true
),
);
if
(
content
.
startsWith
(
'{"jsonrpc":"2.0", "error"'
))
{
throwToolExit
(
'It appears the output file contains an error message, not valid skia output.'
);
}
}
Future
<
void
>
showOutputFileInfo
(
File
outputFile
)
async
{
final
int
sizeKB
=
(
await
outputFile
.
length
())
~/
1024
;
void
_showOutputFileInfo
(
File
outputFile
)
{
final
int
sizeKB
=
(
outputFile
.
lengthSync
())
~/
1024
;
printStatus
(
'Screenshot written to
${fs.path.relative(outputFile.path)}
(
${sizeKB}
kB).'
);
}
}
packages/flutter_tools/lib/src/ios/mac.dart
View file @
398ac1f6
...
...
@@ -269,7 +269,7 @@ Future<XcodeBuildResult> buildXcodeProject({
bool
codesign
=
true
,
bool
usesTerminalUi
=
true
,
})
async
{
if
(!
await
upgradePbxProjWithFlutterAssets
(
app
.
project
))
if
(!
upgradePbxProjWithFlutterAssets
(
app
.
project
))
return
XcodeBuildResult
(
success:
false
);
if
(!
_checkXcodeVersion
())
...
...
@@ -679,10 +679,10 @@ void _copyServiceDefinitionsManifest(List<Map<String, String>> services, File ma
manifest
.
writeAsStringSync
(
json
.
encode
(
jsonObject
),
mode:
FileMode
.
write
,
flush:
true
);
}
Future
<
bool
>
upgradePbxProjWithFlutterAssets
(
IosProject
project
)
async
{
bool
upgradePbxProjWithFlutterAssets
(
IosProject
project
)
{
final
File
xcodeProjectFile
=
project
.
xcodeProjectInfoFile
;
assert
(
await
xcodeProjectFile
.
exists
());
final
List
<
String
>
lines
=
await
xcodeProjectFile
.
readAsLines
();
assert
(
xcodeProjectFile
.
existsSync
());
final
List
<
String
>
lines
=
xcodeProjectFile
.
readAsLinesSync
();
final
RegExp
oldAssets
=
RegExp
(
r'\/\* (flutter_assets|app\.flx)'
);
final
StringBuffer
buffer
=
StringBuffer
();
...
...
@@ -697,6 +697,6 @@ Future<bool> upgradePbxProjWithFlutterAssets(IosProject project) async {
buffer
.
writeln
(
line
);
}
}
await
xcodeProjectFile
.
writeAsString
(
buffer
.
toString
());
xcodeProjectFile
.
writeAsStringSync
(
buffer
.
toString
());
return
true
;
}
packages/flutter_tools/lib/src/macos/cocoapod_utils.dart
View file @
398ac1f6
...
...
@@ -38,9 +38,9 @@ Future<void> processPodsIfNeeded(XcodeBasedProject xcodeProject,
xcodeProject:
xcodeProject
,
engineDir:
flutterFrameworkDir
(
buildMode
),
isSwift:
xcodeProject
.
isSwift
,
dependenciesChanged:
!
await
fingerprinter
.
doesFingerprintMatch
(),
dependenciesChanged:
!
fingerprinter
.
doesFingerprintMatch
(),
);
if
(
didPodInstall
)
{
await
fingerprinter
.
writeFingerprint
();
fingerprinter
.
writeFingerprint
();
}
}
packages/flutter_tools/lib/src/macos/cocoapods.dart
View file @
398ac1f6
...
...
@@ -106,7 +106,7 @@ class CocoaPods {
bool
isSwift
=
false
,
bool
dependenciesChanged
=
true
,
})
async
{
if
(!
(
await
xcodeProject
.
podfile
.
exists
()
))
{
if
(!
xcodeProject
.
podfile
.
existsSync
(
))
{
throwToolExit
(
'Podfile missing'
);
}
if
(
await
_checkPodCondition
())
{
...
...
packages/flutter_tools/lib/src/resident_runner.dart
View file @
398ac1f6
...
...
@@ -747,7 +747,7 @@ abstract class ResidentRunner {
}
}
}
final
int
sizeKB
=
(
await
outputFile
.
length
()
)
~/
1024
;
final
int
sizeKB
=
outputFile
.
lengthSync
(
)
~/
1024
;
status
.
stop
();
printStatus
(
'Screenshot written to
${fs.path.relative(outputFile.path)}
(
${sizeKB}
kB).'
);
}
catch
(
error
)
{
...
...
packages/flutter_tools/lib/src/runner/flutter_command_runner.dart
View file @
398ac1f6
...
...
@@ -303,15 +303,15 @@ class FlutterCommandRunner extends CommandRunner<void> {
..
writeln
()
..
writeln
(
'# rest'
)
..
writeln
(
topLevelResults
.
rest
);
await
manifest
.
writeAsString
(
buffer
.
toString
(),
flush:
true
);
manifest
.
writeAsStringSync
(
buffer
.
toString
(),
flush:
true
);
// ZIP the recording up once the recording has been serialized.
addShutdownHook
(()
async
{
addShutdownHook
(()
{
final
File
zipFile
=
getUniqueFile
(
fs
.
currentDirectory
,
'bugreport'
,
'zip'
);
os
.
zip
(
tempDir
,
zipFile
);
printStatus
(
userMessages
.
runnerBugReportFinished
(
zipFile
.
basename
));
},
ShutdownStage
.
POST_PROCESS_RECORDING
);
addShutdownHook
(()
=>
tempDir
.
delete
(
recursive:
true
),
ShutdownStage
.
CLEANUP
);
addShutdownHook
(()
=>
tempDir
.
delete
Sync
(
recursive:
true
),
ShutdownStage
.
CLEANUP
);
}
assert
(
recordTo
==
null
||
replayFrom
==
null
);
...
...
@@ -323,7 +323,7 @@ class FlutterCommandRunner extends CommandRunner<void> {
contextOverrides
.
addAll
(<
Type
,
dynamic
>{
ProcessManager:
getRecordingProcessManager
(
recordTo
),
FileSystem:
getRecordingFileSystem
(
recordTo
),
Platform:
await
getRecordingPlatform
(
recordTo
),
Platform:
getRecordingPlatform
(
recordTo
),
});
VMService
.
enableRecordingConnection
(
recordTo
);
}
...
...
@@ -335,7 +335,7 @@ class FlutterCommandRunner extends CommandRunner<void> {
contextOverrides
.
addAll
(<
Type
,
dynamic
>{
ProcessManager:
await
getReplayProcessManager
(
replayFrom
),
FileSystem:
getReplayFileSystem
(
replayFrom
),
Platform:
await
getReplayPlatform
(
replayFrom
),
Platform:
getReplayPlatform
(
replayFrom
),
});
VMService
.
enableReplayConnection
(
replayFrom
);
}
...
...
packages/flutter_tools/lib/src/tracing.dart
View file @
398ac1f6
...
...
@@ -78,12 +78,14 @@ Future<void> downloadStartupTrace(VMService observatory, { bool awaitFirstFrame
final
File
traceInfoFile
=
fs
.
file
(
traceInfoFilePath
);
// Delete old startup data, if any.
if
(
await
traceInfoFile
.
exists
())
await
traceInfoFile
.
delete
();
if
(
traceInfoFile
.
existsSync
())
{
traceInfoFile
.
deleteSync
();
}
// Create "build" directory, if missing.
if
(!(
await
traceInfoFile
.
parent
.
exists
()))
await
traceInfoFile
.
parent
.
create
();
if
(!
traceInfoFile
.
parent
.
existsSync
())
{
traceInfoFile
.
parent
.
createSync
();
}
final
Tracing
tracing
=
Tracing
(
observatory
);
...
...
packages/flutter_tools/lib/src/version.dart
View file @
398ac1f6
...
...
@@ -99,8 +99,9 @@ class FlutterVersion {
String
get
engineRevision
=>
Cache
.
instance
.
engineRevision
;
String
get
engineRevisionShort
=>
_shortGitRevision
(
engineRevision
);
Future
<
void
>
ensureVersionFile
()
async
{
Future
<
void
>
ensureVersionFile
()
{
fs
.
file
(
fs
.
path
.
join
(
Cache
.
flutterRoot
,
'version'
)).
writeAsStringSync
(
_frameworkVersion
);
return
Future
<
void
>.
value
();
}
@override
...
...
packages/flutter_tools/lib/src/vmservice_record_replay.dart
View file @
398ac1f6
...
...
@@ -24,7 +24,7 @@ const String _kData = 'data';
class
RecordingVMServiceChannel
extends
DelegatingStreamChannel
<
String
>
{
RecordingVMServiceChannel
(
StreamChannel
<
String
>
delegate
,
Directory
location
)
:
super
(
delegate
)
{
addShutdownHook
(()
async
{
addShutdownHook
(()
{
// Sort the messages such that they are ordered
// `[request1, response1, request2, response2, ...]`. This serves no
// purpose other than to make the serialized format more human-readable.
...
...
@@ -32,7 +32,7 @@ class RecordingVMServiceChannel extends DelegatingStreamChannel<String> {
final
File
file
=
_getManifest
(
location
);
final
String
json
=
const
JsonEncoder
.
withIndent
(
' '
).
convert
(
_messages
);
await
file
.
writeAsString
(
json
,
flush:
true
);
file
.
writeAsStringSync
(
json
,
flush:
true
);
},
ShutdownStage
.
SERIALIZE_RECORDING
);
}
...
...
packages/flutter_tools/test/general.shard/base/fingerprint_test.dart
View file @
398ac1f6
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/general.shard/ios/mac_test.dart
View file @
398ac1f6
...
...
@@ -434,12 +434,12 @@ Could not build the precompiled application for the device.''',
when(project.xcodeProjectInfoFile).thenReturn(pbxprojFile);
when(project.hostAppBundleName).thenReturn('
UnitTestRunner
.
app
');
when(pbxprojFile.readAsLines())
.thenAnswer((_) =>
Future<List<String>>.value(flutterAssetPbxProjLines)
);
when(pbxprojFile.exists())
.thenAnswer((_) =>
Future<bool>.value(true)
);
when(pbxprojFile.readAsLines
Sync
())
.thenAnswer((_) =>
flutterAssetPbxProjLines
);
when(pbxprojFile.exists
Sync
())
.thenAnswer((_) =>
true
);
bool result =
await
upgradePbxProjWithFlutterAssets(project);
bool result = upgradePbxProjWithFlutterAssets(project);
expect(result, true);
expect(
testLogger.statusText,
...
...
@@ -447,9 +447,9 @@ Could not build the precompiled application for the device.''',
);
testLogger.clear();
when(pbxprojFile.readAsLines())
.thenAnswer((_) =>
Future<List<String>>.value(appFlxPbxProjLines)
);
result =
await
upgradePbxProjWithFlutterAssets(project);
when(pbxprojFile.readAsLines
Sync
())
.thenAnswer((_) =>
appFlxPbxProjLines
);
result = upgradePbxProjWithFlutterAssets(project);
expect(result, true);
expect(
testLogger.statusText,
...
...
@@ -457,9 +457,9 @@ Could not build the precompiled application for the device.''',
);
testLogger.clear();
when(pbxprojFile.readAsLines())
.thenAnswer((_) =>
Future<List<String>>.value(cleanPbxProjLines)
);
result =
await
upgradePbxProjWithFlutterAssets(project);
when(pbxprojFile.readAsLines
Sync
())
.thenAnswer((_) =>
cleanPbxProjLines
);
result = upgradePbxProjWithFlutterAssets(project);
expect(result, true);
expect(
testLogger.statusText,
...
...
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