From b4d57553c8ef5e6c75ad5d7c597720cd7233270a Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Wed, 11 Apr 2018 16:53:32 -0700 Subject: [PATCH] Simplify script snapshotting code (#16478) Inlines the very small amount of work being done in _build() into buildScriptSnapshot(). Eliminates a duplicate (and un-awaited) call to _writeFingerprint. --- .../flutter_tools/lib/src/base/build.dart | 44 +++++-------------- 1 file changed, 10 insertions(+), 34 deletions(-) diff --git a/packages/flutter_tools/lib/src/base/build.dart b/packages/flutter_tools/lib/src/base/build.dart index 56c83863cb..51ef8ff929 100644 --- a/packages/flutter_tools/lib/src/base/build.dart +++ b/packages/flutter_tools/lib/src/base/build.dart @@ -171,7 +171,7 @@ class Snapshotter { @required String depfilePath, @required String packagesPath }) async { - final SnapshotType type = new SnapshotType(null, BuildMode.debug); + final SnapshotType snapshotType = new SnapshotType(null, BuildMode.debug); final List args = [ '--snapshot_kind=script', '--script_snapshot=$snapshotPath', @@ -180,36 +180,7 @@ class Snapshotter { ]; final String fingerprintPath = '$depfilePath.fingerprint'; - final int exitCode = await _build( - snapshotType: type, - outputSnapshotPath: snapshotPath, - packagesPath: packagesPath, - snapshotArgs: args, - depfilePath: depfilePath, - mainPath: mainPath, - fingerprintPath: fingerprintPath, - ); - if (exitCode != 0) - return exitCode; - await _writeFingerprint(type, snapshotPath, depfilePath, mainPath, fingerprintPath); - return exitCode; - } - - /// Builds an architecture-specific ahead-of-time compiled snapshot of the specified script. - Future buildAotSnapshot() async { - throw new UnimplementedError('AOT snapshotting not yet implemented'); - } - - Future _build({ - @required SnapshotType snapshotType, - @required List snapshotArgs, - @required String outputSnapshotPath, - @required String packagesPath, - @required String depfilePath, - @required String mainPath, - @required String fingerprintPath, - }) async { - if (!await _isBuildRequired(snapshotType, outputSnapshotPath, depfilePath, mainPath, fingerprintPath)) { + if (!await _isBuildRequired(snapshotType, snapshotPath, depfilePath, mainPath, fingerprintPath)) { printTrace('Skipping snapshot build. Fingerprints match.'); return 0; } @@ -219,13 +190,18 @@ class Snapshotter { snapshotType: snapshotType, packagesPath: packagesPath, depfilePath: depfilePath, - additionalArgs: snapshotArgs, + additionalArgs: args, ); + if (exitCode != 0) return exitCode; + await _writeFingerprint(snapshotType, snapshotPath, depfilePath, mainPath, fingerprintPath); + return exitCode; + } - _writeFingerprint(snapshotType, outputSnapshotPath, depfilePath, mainPath, fingerprintPath); - return 0; + /// Builds an architecture-specific ahead-of-time compiled snapshot of the specified script. + Future buildAotSnapshot() async { + throw new UnimplementedError('AOT snapshotting not yet implemented'); } Future _isBuildRequired(SnapshotType type, String outputSnapshotPath, String depfilePath, String mainPath, String fingerprintPath) async {