diff --git a/packages/flutter_tools/lib/src/bundle.dart b/packages/flutter_tools/lib/src/bundle.dart index 5363361d58..be98136a3a 100644 --- a/packages/flutter_tools/lib/src/bundle.dart +++ b/packages/flutter_tools/lib/src/bundle.dart @@ -9,7 +9,6 @@ import 'asset.dart'; import 'base/build.dart'; import 'base/common.dart'; import 'base/file_system.dart'; -import 'base/fingerprint.dart'; import 'build_info.dart'; import 'compile.dart'; import 'dart/package_map.dart'; @@ -71,46 +70,22 @@ Future build({ DevFSContent kernelContent; if (!precompiledSnapshot && previewDart2) { - bool needBuild = true; - final Fingerprinter fingerprinter = new Fingerprinter( - fingerprintPath: '$depfilePath.fingerprint', - paths: [mainPath], - properties: { - 'entryPoint': mainPath, - 'trackWidgetCreation': trackWidgetCreation.toString(), - }, - depfilePaths: [depfilePath], + ensureDirectoryExists(applicationKernelFilePath); + final CompilerOutput compilerOutput = await kernelCompiler.compile( + sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath), + incrementalCompilerByteStorePath: fs.path.absolute(getIncrementalCompilerByteStoreDirectory()), + mainPath: fs.file(mainPath).absolute.path, + outputFilePath: applicationKernelFilePath, + depFilePath: depfilePath, + trackWidgetCreation: trackWidgetCreation, + fileSystemRoots: fileSystemRoots, + fileSystemScheme: fileSystemScheme, + packagesPath: packagesPath, ); - - if (await fingerprinter.doesFingerprintMatch()) { - needBuild = false; - printTrace('Skipping kernel compilation. Fingerprint match.'); + if (compilerOutput?.outputFilename == null) { + throwToolExit('Compiler failed on $mainPath'); } - - String kernelBinaryFilename; - if (needBuild) { - ensureDirectoryExists(applicationKernelFilePath); - final CompilerOutput compilerOutput = await kernelCompiler.compile( - sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath), - incrementalCompilerByteStorePath: fs.path.absolute(getIncrementalCompilerByteStoreDirectory()), - mainPath: fs.file(mainPath).absolute.path, - outputFilePath: applicationKernelFilePath, - depFilePath: depfilePath, - trackWidgetCreation: trackWidgetCreation, - fileSystemRoots: fileSystemRoots, - fileSystemScheme: fileSystemScheme, - packagesPath: packagesPath, - ); - kernelBinaryFilename = compilerOutput?.outputFilename; - if (kernelBinaryFilename == null) { - throwToolExit('Compiler failed on $mainPath'); - } - // Compute and record build fingerprint. - await fingerprinter.writeFingerprint(); - } else { - kernelBinaryFilename = applicationKernelFilePath; - } - kernelContent = new DevFSFileContent(fs.file(kernelBinaryFilename)); + kernelContent = new DevFSFileContent(fs.file(compilerOutput.outputFilename)); await fs.directory(getBuildDirectory()).childFile('frontend_server.d') .writeAsString('frontend_server.d: ${artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk)}\n'); diff --git a/packages/flutter_tools/lib/src/compile.dart b/packages/flutter_tools/lib/src/compile.dart index 218134a35c..dc065d6d0c 100644 --- a/packages/flutter_tools/lib/src/compile.dart +++ b/packages/flutter_tools/lib/src/compile.dart @@ -10,6 +10,7 @@ import 'package:usage/uuid/uuid.dart'; import 'artifacts.dart'; import 'base/common.dart'; import 'base/context.dart'; +import 'base/fingerprint.dart'; import 'base/io.dart'; import 'base/process_manager.dart'; import 'globals.dart'; @@ -84,6 +85,28 @@ class KernelCompiler { Artifact.frontendServerSnapshotForEngineDartSdk ); + // TODO(cbracken) eliminate pathFilter. + // Currently the compiler emits buildbot paths for the core libs in the + // depfile. None of these are available on the local host. + Fingerprinter fingerprinter; + if (depFilePath != null) { + fingerprinter = new Fingerprinter( + fingerprintPath: '$depFilePath.fingerprint', + paths: [mainPath], + properties: { + 'entryPoint': mainPath, + 'trackWidgetCreation': trackWidgetCreation.toString(), + }, + depfilePaths: [depFilePath], + pathFilter: (String path) => !path.startsWith('/b/build/slave/'), + ); + + if (await fingerprinter.doesFingerprintMatch()) { + printTrace('Skipping kernel compilation. Fingerprint match.'); + return new CompilerOutput(outputFilePath, 0); + } + } + // This is a URI, not a file path, so the forward slash is correct even on Windows. if (!sdkRoot.endsWith('/')) sdkRoot = '$sdkRoot/'; @@ -153,7 +176,13 @@ class KernelCompiler { .transform(const LineSplitter()) .listen(stdoutHandler.handler); final int exitCode = await server.exitCode; - return exitCode == 0 ? stdoutHandler.compilerOutput.future : null; + if (exitCode == 0) { + if (fingerprinter != null) { + await fingerprinter.writeFingerprint(); + } + return stdoutHandler.compilerOutput.future; + } + return null; } }