Commit 0774a674 authored by Konstantin Scheglov's avatar Konstantin Scheglov Committed by GitHub

Build unlinked summaries for packages on upgrade. (#5816)

* Build unlinked summaries for packages on upgrade.

* Iterate through the packages in folders.

* Rollback the debug change.
parent 678da3ac
......@@ -7,6 +7,7 @@ import 'dart:async';
import '../base/os.dart';
import '../base/process.dart';
import '../dart/pub.dart';
import '../dart/summary.dart';
import '../cache.dart';
import '../globals.dart';
import '../runner/flutter_command.dart';
......@@ -49,6 +50,8 @@ class UpgradeCommand extends FlutterCommand {
mapFunction: (String line) => matchesGitLine(line) ? null : line
);
await buildUnlinkedForPackages(Cache.flutterRoot);
if (code != 0)
return code;
......
import 'dart:async';
import 'dart:io' as io;
import 'package:analyzer/file_system/file_system.dart';
......@@ -8,6 +9,9 @@ import 'package:analyzer/src/dart/sdk/sdk.dart'; // ignore: implementation_impor
import 'package:analyzer/src/generated/engine.dart'; // ignore: implementation_imports
import 'package:analyzer/src/generated/source.dart'; // ignore: implementation_imports
import 'package:analyzer/src/summary/summary_file_builder.dart'; // ignore: implementation_imports
import 'package:analyzer/src/summary/pub_summary.dart'; // ignore: implementation_imports
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/dart/pub.dart';
import 'package:flutter_tools/src/globals.dart';
import 'package:package_config/packages.dart';
import 'package:path/path.dart' as pathos;
......@@ -74,3 +78,54 @@ void buildSkyEngineSdkSummary(
String outputPath = pathos.join(skyEnginePath, outBundleName);
new io.File(outputPath).writeAsBytesSync(output.sum);
}
Future<Null> buildUnlinkedForPackages(String flutterPath) async {
PhysicalResourceProvider provider = PhysicalResourceProvider.INSTANCE;
PubSummaryManager manager =
new PubSummaryManager(provider, '__unlinked_${io.pid}.ds');
Folder flutterFolder = provider.getFolder(flutterPath);
//
// Build in packages/.
//
Folder packagesFolder = flutterFolder.getChildAssumingFolder('packages');
await _buildUnlinkedForDirectChildren(manager, packagesFolder);
//
// Build in bin/cache/pkg/.
//
Folder pkgFolder = flutterFolder
.getChildAssumingFolder('bin')
.getChildAssumingFolder('cache')
.getChildAssumingFolder('pkg');
await _buildUnlinkedForDirectChildren(manager, pkgFolder);
}
Future<Null> _buildUnlinkedForDirectChildren(
PubSummaryManager manager, Folder packagesFolder) async {
for (Resource child in packagesFolder.getChildren()) {
if (child is Folder) {
await _buildUnlinkedForPackage(manager, child);
}
}
}
Future<Null> _buildUnlinkedForPackage(
PubSummaryManager manager, Folder packageFolder) async {
if (packageFolder.exists) {
String name = packageFolder.shortName;
File pubspecFile = packageFolder.getChildAssumingFile('pubspec.yaml');
Folder libFolder = packageFolder.getChildAssumingFolder('lib');
if (pubspecFile.exists && libFolder.exists) {
await pubGet(directory: packageFolder.path);
Status status =
logger.startProgress('Building unlinked bundles for $name...');
try {
await manager.computeUnlinkedForFolder(name, libFolder);
} finally {
status.stop(showElapsedTime: true);
}
}
}
}
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