Unverified Commit 2ab4ed74 authored by Chris Bracken's avatar Chris Bracken Committed by GitHub

Eliminate Dart 1 support from DevFS (#21404)

Dart 1 is no longer supported in Flutter. Hot reload now always occurs
via kernel file updates (plus any asset bundle changes).
parent 2ef7cd64
...@@ -426,10 +426,9 @@ class DevFS { ...@@ -426,10 +426,9 @@ class DevFS {
await _scanDirectory(rootDirectory, await _scanDirectory(rootDirectory,
recursive: true, recursive: true,
fileFilter: fileFilter); fileFilter: fileFilter);
final bool previewDart2 = generator != null;
if (fs.isFileSync(_packagesFilePath)) { if (fs.isFileSync(_packagesFilePath)) {
printTrace('Scanning package files'); printTrace('Scanning package files');
await _scanPackages(fileFilter, previewDart2); await _scanPackages(fileFilter);
} }
if (bundle != null) { if (bundle != null) {
printTrace('Scanning asset files'); printTrace('Scanning asset files');
...@@ -480,12 +479,11 @@ class DevFS { ...@@ -480,12 +479,11 @@ class DevFS {
assetPathsToEvict.add(archivePath); assetPathsToEvict.add(archivePath);
} }
}); });
if (previewDart2) { // We run generator even if [dirtyEntries] was empty because we want to
// We run generator even if [dirtyEntries] was empty because we want // keep logic of accepting/rejecting generator's output simple: we must
// to keep logic of accepting/rejecting generator's output simple: // accept/reject generator's output after every [update] call. Incremental
// we must accept/reject generator's output after every [update] call. // run with no changes is supposed to be fast (considering that it is
// Incremental run with no changes is supposed to be fast (considering // initiated by user key press).
// that it is initiated by user key press).
final List<String> invalidatedFiles = <String>[]; final List<String> invalidatedFiles = <String>[];
final Set<Uri> filesUris = new Set<Uri>(); final Set<Uri> filesUris = new Set<Uri>();
for (Uri uri in dirtyEntries.keys.toList()) { for (Uri uri in dirtyEntries.keys.toList()) {
...@@ -505,22 +503,24 @@ class DevFS { ...@@ -505,22 +503,24 @@ class DevFS {
if (fullRestart) { if (fullRestart) {
generator.reset(); generator.reset();
} }
final CompilerOutput compilerOutput = final CompilerOutput compilerOutput = await generator.recompile(
await generator.recompile(mainPath, invalidatedFiles, mainPath,
invalidatedFiles,
outputPath: dillOutputPath ?? fs.path.join(getBuildDirectory(), 'app.dill'), outputPath: dillOutputPath ?? fs.path.join(getBuildDirectory(), 'app.dill'),
packagesFilePath : _packagesFilePath); packagesFilePath : _packagesFilePath,
);
final String compiledBinary = compilerOutput?.outputFilename; final String compiledBinary = compilerOutput?.outputFilename;
if (compiledBinary != null && compiledBinary.isNotEmpty) { if (compiledBinary != null && compiledBinary.isNotEmpty) {
final Uri entryUri = fs.path.toUri(projectRootPath != null ? final Uri entryUri = fs.path.toUri(projectRootPath != null
fs.path.relative(pathToReload, from: projectRootPath): ? fs.path.relative(pathToReload, from: projectRootPath)
pathToReload); : pathToReload,
);
if (!dirtyEntries.containsKey(entryUri)) { if (!dirtyEntries.containsKey(entryUri)) {
final DevFSFileContent content = new DevFSFileContent(fs.file(compiledBinary)); final DevFSFileContent content = new DevFSFileContent(fs.file(compiledBinary));
dirtyEntries[entryUri] = content; dirtyEntries[entryUri] = content;
numBytes += content.size; numBytes += content.size;
} }
} }
}
if (dirtyEntries.isNotEmpty) { if (dirtyEntries.isNotEmpty) {
printTrace('Updating files'); printTrace('Updating files');
if (_httpWriter != null) { if (_httpWriter != null) {
...@@ -697,7 +697,7 @@ class DevFS { ...@@ -697,7 +697,7 @@ class DevFS {
); );
} }
Future<Null> _scanPackages(Set<String> fileFilter, bool previewDart2) async { Future<Null> _scanPackages(Set<String> fileFilter) async {
StringBuffer sb; StringBuffer sb;
final PackageMap packageMap = new PackageMap(_packagesFilePath); final PackageMap packageMap = new PackageMap(_packagesFilePath);
...@@ -730,22 +730,6 @@ class DevFS { ...@@ -730,22 +730,6 @@ class DevFS {
sb.writeln('$packageName:$directoryUriOnDevice'); sb.writeln('$packageName:$directoryUriOnDevice');
} }
} }
if (previewDart2) {
// When in previewDart2 mode we don't update .packages-file entry
// so actual file will get invalidated in frontend.
// We don't need to synthesize device-correct .packages file because
// it is not going to be used on the device anyway - compilation
// is done on the host.
return;
}
if (sb != null) {
final DevFSContent content = _entries[fs.path.toUri('.packages')];
if (content is DevFSStringContent && content.string == sb.toString()) {
content._exists = true;
return;
}
_entries[fs.path.toUri('.packages')] = new DevFSStringContent(sb.toString());
}
} }
} }
/// Converts a platform-specific file path to a platform-independent Uri path. /// Converts a platform-specific file path to a platform-independent Uri path.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment