mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

* Update project.pbxproj files to say Flutter rather than Chromium Also, the templates now have an empty organization so that we don't cause people to give their apps a Flutter copyright. * Update the copyright notice checker to require a standard notice on all files * Update copyrights on Dart files. (This was a mechanical commit.) * Fix weird license headers on Dart files that deviate from our conventions; relicense Shrine. Some were already marked "The Flutter Authors", not clear why. Their dates have been normalized. Some were missing the blank line after the license. Some were randomly different in trivial ways for no apparent reason (e.g. missing the trailing period). * Clean up the copyrights in non-Dart files. (Manual edits.) Also, make sure templates don't have copyrights. * Fix some more ORGANIZATIONNAMEs
169 lines
6.9 KiB
Dart
169 lines
6.9 KiB
Dart
// Copyright 2014 The Flutter 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 'dart:async';
|
|
import 'dart:convert';
|
|
import 'dart:io';
|
|
|
|
import 'package:path/path.dart' as path;
|
|
|
|
import '../framework/adb.dart';
|
|
import '../framework/framework.dart';
|
|
import '../framework/utils.dart';
|
|
|
|
final Directory _editedFlutterGalleryDir = dir(path.join(Directory.systemTemp.path, 'edited_flutter_gallery'));
|
|
final Directory flutterGalleryDir = dir(path.join(flutterDirectory.path, 'examples/flutter_gallery'));
|
|
|
|
TaskFunction createHotModeTest({String deviceIdOverride, Map<String, String> environment}) {
|
|
return () async {
|
|
if (deviceIdOverride == null) {
|
|
final Device device = await devices.workingDevice;
|
|
await device.unlock();
|
|
deviceIdOverride = device.deviceId;
|
|
}
|
|
final File benchmarkFile = file(path.join(_editedFlutterGalleryDir.path, 'hot_benchmark.json'));
|
|
rm(benchmarkFile);
|
|
final List<String> options = <String>[
|
|
'--hot', '-d', deviceIdOverride, '--benchmark', '--verbose', '--resident', '--output-dill', path.join('build', 'app.dill')
|
|
];
|
|
int hotReloadCount = 0;
|
|
Map<String, dynamic> twoReloadsData;
|
|
Map<String, dynamic> freshRestartReloadsData;
|
|
await inDirectory<void>(flutterDirectory, () async {
|
|
rmTree(_editedFlutterGalleryDir);
|
|
mkdirs(_editedFlutterGalleryDir);
|
|
recursiveCopy(flutterGalleryDir, _editedFlutterGalleryDir);
|
|
await inDirectory<void>(_editedFlutterGalleryDir, () async {
|
|
{
|
|
final Process clearProcess = await startProcess(
|
|
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
|
flutterCommandArgs('clean', <String>[]),
|
|
environment: environment,
|
|
);
|
|
await clearProcess.exitCode;
|
|
|
|
final Process process = await startProcess(
|
|
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
|
flutterCommandArgs('run', options),
|
|
environment: environment,
|
|
);
|
|
|
|
final Completer<void> stdoutDone = Completer<void>();
|
|
final Completer<void> stderrDone = Completer<void>();
|
|
process.stdout
|
|
.transform<String>(utf8.decoder)
|
|
.transform<String>(const LineSplitter())
|
|
.listen((String line) {
|
|
if (line.contains('\] Reloaded ')) {
|
|
if (hotReloadCount == 0) {
|
|
// Update the file and reload again.
|
|
final File appDartSource = file(path.join(
|
|
_editedFlutterGalleryDir.path, 'lib/gallery/app.dart',
|
|
));
|
|
appDartSource.writeAsStringSync(
|
|
appDartSource.readAsStringSync().replaceFirst(
|
|
"'Flutter Gallery'", "'Updated Flutter Gallery'",
|
|
)
|
|
);
|
|
process.stdin.writeln('r');
|
|
++hotReloadCount;
|
|
} else {
|
|
// Quit after second hot reload.
|
|
process.stdin.writeln('q');
|
|
}
|
|
}
|
|
print('stdout: $line');
|
|
}, onDone: () {
|
|
stdoutDone.complete();
|
|
});
|
|
process.stderr
|
|
.transform<String>(utf8.decoder)
|
|
.transform<String>(const LineSplitter())
|
|
.listen((String line) {
|
|
print('stderr: $line');
|
|
}, onDone: () {
|
|
stderrDone.complete();
|
|
});
|
|
|
|
await Future.wait<void>(
|
|
<Future<void>>[stdoutDone.future, stderrDone.future]);
|
|
await process.exitCode;
|
|
|
|
twoReloadsData = json.decode(benchmarkFile.readAsStringSync());
|
|
}
|
|
benchmarkFile.deleteSync();
|
|
|
|
// Start `flutter run` again to make sure it loads from the previous
|
|
// state. Frontend loads up from previously generated kernel files.
|
|
{
|
|
final Process process = await startProcess(
|
|
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
|
flutterCommandArgs('run', options),
|
|
environment: environment,
|
|
);
|
|
final Completer<void> stdoutDone = Completer<void>();
|
|
final Completer<void> stderrDone = Completer<void>();
|
|
process.stdout
|
|
.transform<String>(utf8.decoder)
|
|
.transform<String>(const LineSplitter())
|
|
.listen((String line) {
|
|
if (line.contains('\] Reloaded ')) {
|
|
process.stdin.writeln('q');
|
|
}
|
|
print('stdout: $line');
|
|
}, onDone: () {
|
|
stdoutDone.complete();
|
|
});
|
|
process.stderr
|
|
.transform<String>(utf8.decoder)
|
|
.transform<String>(const LineSplitter())
|
|
.listen((String line) {
|
|
print('stderr: $line');
|
|
}, onDone: () {
|
|
stderrDone.complete();
|
|
});
|
|
|
|
await Future.wait<void>(
|
|
<Future<void>>[stdoutDone.future, stderrDone.future]);
|
|
await process.exitCode;
|
|
|
|
freshRestartReloadsData =
|
|
json.decode(benchmarkFile.readAsStringSync());
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
|
|
return TaskResult.success(
|
|
<String, dynamic> {
|
|
'hotReloadInitialDevFSSyncMilliseconds': twoReloadsData['hotReloadInitialDevFSSyncMilliseconds'][0],
|
|
'hotRestartMillisecondsToFrame': twoReloadsData['hotRestartMillisecondsToFrame'][0],
|
|
'hotReloadMillisecondsToFrame' : twoReloadsData['hotReloadMillisecondsToFrame'][0],
|
|
'hotReloadDevFSSyncMilliseconds': twoReloadsData['hotReloadDevFSSyncMilliseconds'][0],
|
|
'hotReloadFlutterReassembleMilliseconds': twoReloadsData['hotReloadFlutterReassembleMilliseconds'][0],
|
|
'hotReloadVMReloadMilliseconds': twoReloadsData['hotReloadVMReloadMilliseconds'][0],
|
|
'hotReloadMillisecondsToFrameAfterChange' : twoReloadsData['hotReloadMillisecondsToFrame'][1],
|
|
'hotReloadDevFSSyncMillisecondsAfterChange': twoReloadsData['hotReloadDevFSSyncMilliseconds'][1],
|
|
'hotReloadFlutterReassembleMillisecondsAfterChange': twoReloadsData['hotReloadFlutterReassembleMilliseconds'][1],
|
|
'hotReloadVMReloadMillisecondsAfterChange': twoReloadsData['hotReloadVMReloadMilliseconds'][1],
|
|
'hotReloadInitialDevFSSyncAfterRelaunchMilliseconds' : freshRestartReloadsData['hotReloadInitialDevFSSyncMilliseconds'][0],
|
|
},
|
|
benchmarkScoreKeys: <String>[
|
|
'hotReloadInitialDevFSSyncMilliseconds',
|
|
'hotRestartMillisecondsToFrame',
|
|
'hotReloadMillisecondsToFrame',
|
|
'hotReloadDevFSSyncMilliseconds',
|
|
'hotReloadFlutterReassembleMilliseconds',
|
|
'hotReloadVMReloadMilliseconds',
|
|
'hotReloadMillisecondsToFrameAfterChange',
|
|
'hotReloadDevFSSyncMillisecondsAfterChange',
|
|
'hotReloadFlutterReassembleMillisecondsAfterChange',
|
|
'hotReloadVMReloadMillisecondsAfterChange',
|
|
'hotReloadInitialDevFSSyncAfterRelaunchMilliseconds',
|
|
],
|
|
);
|
|
};
|
|
}
|