forked from firka/flutter
[flutter_tools] don't compute hashes of well known artifacts (#53848)
This commit is contained in:
@@ -81,6 +81,9 @@ class AotBuilder {
|
||||
buildDir: FlutterProject.current().dartTool.childDirectory('flutter_build'),
|
||||
cacheDir: null,
|
||||
flutterRootDir: globals.fs.directory(Cache.flutterRoot),
|
||||
engineVersion: globals.artifacts.isLocalEngine
|
||||
? null
|
||||
: globals.flutterVersion.engineRevision,
|
||||
defines: <String, String>{
|
||||
kTargetFile: mainDartFile ?? globals.fs.path.join('lib', 'main.dart'),
|
||||
kBuildMode: getNameForBuildMode(buildInfo.mode),
|
||||
|
||||
@@ -169,6 +169,9 @@ abstract class Artifacts {
|
||||
// Returns which set of engine artifacts is currently used for the [platform]
|
||||
// and [mode] combination.
|
||||
String getEngineType(TargetPlatform platform, [ BuildMode mode ]);
|
||||
|
||||
/// Whether these artifacts correspond to a non-versioned local engine.
|
||||
bool get isLocalEngine;
|
||||
}
|
||||
|
||||
|
||||
@@ -405,6 +408,9 @@ class CachedArtifacts extends Artifacts {
|
||||
assert(false, 'Invalid platform $platform.');
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
bool get isLocalEngine => false;
|
||||
}
|
||||
|
||||
TargetPlatform _currentHostPlatform(Platform platform) {
|
||||
@@ -576,6 +582,9 @@ class LocalEngineArtifacts extends Artifacts {
|
||||
}
|
||||
throw Exception('Unsupported platform $platform.');
|
||||
}
|
||||
|
||||
@override
|
||||
bool get isLocalEngine => true;
|
||||
}
|
||||
|
||||
/// An implementation of [Artifacts] that provides individual overrides.
|
||||
@@ -618,4 +627,7 @@ class OverrideArtifacts implements Artifacts {
|
||||
|
||||
@override
|
||||
String getEngineType(TargetPlatform platform, [ BuildMode mode ]) => parent.getEngineType(platform, mode);
|
||||
|
||||
@override
|
||||
bool get isLocalEngine => parent.isLocalEngine;
|
||||
}
|
||||
|
||||
@@ -284,6 +284,8 @@ abstract class Target {
|
||||
/// }
|
||||
class Environment {
|
||||
/// Create a new [Environment] object.
|
||||
///
|
||||
/// [engineVersion] should be set to null for local engine builds.
|
||||
factory Environment({
|
||||
@required Directory projectDir,
|
||||
@required Directory outputDir,
|
||||
@@ -293,6 +295,7 @@ class Environment {
|
||||
@required Logger logger,
|
||||
@required Artifacts artifacts,
|
||||
@required ProcessManager processManager,
|
||||
@required String engineVersion,
|
||||
Directory buildDir,
|
||||
Map<String, String> defines = const <String, String>{},
|
||||
Map<String, String> inputs = const <String, String>{},
|
||||
@@ -303,6 +306,10 @@ class Environment {
|
||||
String buildPrefix;
|
||||
final List<String> keys = defines.keys.toList()..sort();
|
||||
final StringBuffer buffer = StringBuffer();
|
||||
// The engine revision is `null` for local or custom engines.
|
||||
if (engineVersion != null) {
|
||||
buffer.write(engineVersion);
|
||||
}
|
||||
for (final String key in keys) {
|
||||
buffer.write(key);
|
||||
buffer.write(defines[key]);
|
||||
@@ -326,6 +333,7 @@ class Environment {
|
||||
logger: logger,
|
||||
artifacts: artifacts,
|
||||
processManager: processManager,
|
||||
engineVersion: engineVersion,
|
||||
inputs: inputs,
|
||||
);
|
||||
}
|
||||
@@ -333,6 +341,7 @@ class Environment {
|
||||
/// Create a new [Environment] object for unit testing.
|
||||
///
|
||||
/// Any directories not provided will fallback to a [testDirectory]
|
||||
@visibleForTesting
|
||||
factory Environment.test(Directory testDirectory, {
|
||||
Directory projectDir,
|
||||
Directory outputDir,
|
||||
@@ -341,6 +350,7 @@ class Environment {
|
||||
Directory buildDir,
|
||||
Map<String, String> defines = const <String, String>{},
|
||||
Map<String, String> inputs = const <String, String>{},
|
||||
String engineVersion,
|
||||
@required FileSystem fileSystem,
|
||||
@required Logger logger,
|
||||
@required Artifacts artifacts,
|
||||
@@ -358,6 +368,7 @@ class Environment {
|
||||
logger: logger,
|
||||
artifacts: artifacts,
|
||||
processManager: processManager,
|
||||
engineVersion: engineVersion,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -373,6 +384,7 @@ class Environment {
|
||||
@required this.logger,
|
||||
@required this.fileSystem,
|
||||
@required this.artifacts,
|
||||
@required this.engineVersion,
|
||||
@required this.inputs,
|
||||
});
|
||||
|
||||
@@ -448,6 +460,9 @@ class Environment {
|
||||
final Artifacts artifacts;
|
||||
|
||||
final FileSystem fileSystem;
|
||||
|
||||
/// The version of the current engine, or `null` if built with a local engine.
|
||||
final String engineVersion;
|
||||
}
|
||||
|
||||
/// The result information from the build system.
|
||||
|
||||
@@ -166,7 +166,19 @@ class SourceVisitor implements ResolvedFiles {
|
||||
/// Visit a [Source] which is defined by an [Artifact] from the flutter cache.
|
||||
///
|
||||
/// If the [Artifact] points to a directory then all child files are included.
|
||||
/// To increase the performance of builds that use a known revision of Flutter,
|
||||
/// these are updated to point towards the engine.version file instead of
|
||||
/// the artifact itself.
|
||||
void visitArtifact(Artifact artifact, TargetPlatform platform, BuildMode mode) {
|
||||
// This is not a local engine.
|
||||
if (environment.engineVersion != null) {
|
||||
sources.add(environment.flutterRootDir
|
||||
.childDirectory('bin')
|
||||
.childDirectory('internal')
|
||||
.childFile('engine.version'),
|
||||
);
|
||||
return;
|
||||
}
|
||||
final String path = environment.artifacts
|
||||
.getArtifactPath(artifact, platform: platform, mode: mode);
|
||||
if (environment.fileSystem.isDirectorySync(path)) {
|
||||
@@ -175,9 +187,9 @@ class SourceVisitor implements ResolvedFiles {
|
||||
if (entity is File)
|
||||
entity,
|
||||
]);
|
||||
} else {
|
||||
sources.add(environment.fileSystem.file(path));
|
||||
return;
|
||||
}
|
||||
sources.add(environment.fileSystem.file(path));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -122,6 +122,9 @@ Future<void> buildWithAssemble({
|
||||
buildDir: flutterProject.dartTool.childDirectory('flutter_build'),
|
||||
cacheDir: globals.cache.getRoot(),
|
||||
flutterRootDir: globals.fs.directory(Cache.flutterRoot),
|
||||
engineVersion: globals.artifacts.isLocalEngine
|
||||
? null
|
||||
: globals.flutterVersion.engineRevision,
|
||||
defines: <String, String>{
|
||||
kTargetFile: mainPath,
|
||||
kBuildMode: getNameForBuildMode(buildMode),
|
||||
|
||||
@@ -164,6 +164,9 @@ class AssembleCommand extends FlutterCommand {
|
||||
fileSystem: globals.fs,
|
||||
logger: globals.logger,
|
||||
processManager: globals.processManager,
|
||||
engineVersion: globals.artifacts.isLocalEngine
|
||||
? null
|
||||
: globals.flutterVersion.engineRevision
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -462,6 +462,9 @@ end
|
||||
fileSystem: globals.fs,
|
||||
logger: globals.logger,
|
||||
processManager: globals.processManager,
|
||||
engineVersion: globals.artifacts.isLocalEngine
|
||||
? null
|
||||
: globals.flutterVersion.engineRevision,
|
||||
);
|
||||
final BuildResult result = await buildSystem.build(target, environment);
|
||||
if (!result.success) {
|
||||
|
||||
@@ -13,6 +13,7 @@ import '../build_system/build_system.dart';
|
||||
import '../build_system/targets/dart.dart';
|
||||
import '../build_system/targets/icon_tree_shaker.dart';
|
||||
import '../build_system/targets/web.dart';
|
||||
import '../cache.dart';
|
||||
import '../globals.dart' as globals;
|
||||
import '../platform_plugins.dart';
|
||||
import '../plugins.dart';
|
||||
@@ -37,8 +38,8 @@ Future<void> buildWeb(
|
||||
final Status status = globals.logger.startProgress('Compiling $target for the Web...', timeout: null);
|
||||
final Stopwatch sw = Stopwatch()..start();
|
||||
try {
|
||||
final BuildResult result = await globals.buildSystem.build(const WebServiceWorker(), Environment.test(
|
||||
globals.fs.currentDirectory,
|
||||
final BuildResult result = await globals.buildSystem.build(const WebServiceWorker(), Environment(
|
||||
projectDir: globals.fs.currentDirectory,
|
||||
outputDir: globals.fs.directory(getWebBuildDirectory()),
|
||||
buildDir: flutterProject.directory
|
||||
.childDirectory('.dart_tool')
|
||||
@@ -56,6 +57,11 @@ Future<void> buildWeb(
|
||||
fileSystem: globals.fs,
|
||||
logger: globals.logger,
|
||||
processManager: globals.processManager,
|
||||
cacheDir: globals.cache.getRoot(),
|
||||
engineVersion: globals.artifacts.isLocalEngine
|
||||
? null
|
||||
: globals.flutterVersion.engineRevision,
|
||||
flutterRootDir: globals.fs.directory(Cache.flutterRoot),
|
||||
));
|
||||
if (!result.success) {
|
||||
for (final ExceptionMeasurement measurement in result.exceptions.values) {
|
||||
|
||||
Reference in New Issue
Block a user