Unverified Commit a11da238 authored by Alexander Aprelev's avatar Alexander Aprelev Committed by GitHub

Put generated kernel files into <build> folder (#14693)

* Put generated kernel files into <build> directory

* USe default value for kernel file
parent 8754e4f9
...@@ -282,6 +282,7 @@ Future<String> _buildAotSnapshot( ...@@ -282,6 +282,7 @@ Future<String> _buildAotSnapshot(
final String kIsolateSnapshotDataC = fs.path.join(outputDir.path, '$kIsolateSnapshotData.c'); final String kIsolateSnapshotDataC = fs.path.join(outputDir.path, '$kIsolateSnapshotData.c');
final String kVmSnapshotDataO = fs.path.join(outputDir.path, '$kVmSnapshotData.o'); final String kVmSnapshotDataO = fs.path.join(outputDir.path, '$kVmSnapshotData.o');
final String kIsolateSnapshotDataO = fs.path.join(outputDir.path, '$kIsolateSnapshotData.o'); final String kIsolateSnapshotDataO = fs.path.join(outputDir.path, '$kIsolateSnapshotData.o');
final String kApplicationKernelPath = fs.path.join(getBuildDirectory(), 'app.dill');
switch (platform) { switch (platform) {
case TargetPlatform.android_arm: case TargetPlatform.android_arm:
...@@ -338,6 +339,7 @@ Future<String> _buildAotSnapshot( ...@@ -338,6 +339,7 @@ Future<String> _buildAotSnapshot(
mainPath = await compile( mainPath = await compile(
sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath), sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath),
mainPath: mainPath, mainPath: mainPath,
outputFilePath: kApplicationKernelPath,
extraFrontEndOptions: extraFrontEndOptions, extraFrontEndOptions: extraFrontEndOptions,
linkPlatformKernelIn : true, linkPlatformKernelIn : true,
aot : true, aot : true,
......
...@@ -20,6 +20,7 @@ class BuildFlxCommand extends BuildSubCommand { ...@@ -20,6 +20,7 @@ class BuildFlxCommand extends BuildSubCommand {
argParser.addOption('output-file', abbr: 'o', defaultsTo: defaultFlxOutputPath); argParser.addOption('output-file', abbr: 'o', defaultsTo: defaultFlxOutputPath);
argParser.addOption('snapshot', defaultsTo: defaultSnapshotPath); argParser.addOption('snapshot', defaultsTo: defaultSnapshotPath);
argParser.addOption('depfile', defaultsTo: defaultDepfilePath); argParser.addOption('depfile', defaultsTo: defaultDepfilePath);
argParser.addOption('kernel-file', defaultsTo: defaultApplicationKernelPath);
argParser.addFlag('preview-dart-2', negatable: false, hide: !verboseHelp); argParser.addFlag('preview-dart-2', negatable: false, hide: !verboseHelp);
argParser.addFlag( argParser.addFlag(
'track-widget-creation', 'track-widget-creation',
...@@ -51,6 +52,7 @@ class BuildFlxCommand extends BuildSubCommand { ...@@ -51,6 +52,7 @@ class BuildFlxCommand extends BuildSubCommand {
manifestPath: argResults['manifest'], manifestPath: argResults['manifest'],
outputPath: outputPath, outputPath: outputPath,
snapshotPath: argResults['snapshot'], snapshotPath: argResults['snapshot'],
applicationKernelFilePath: argResults['kernel-file'],
depfilePath: argResults['depfile'], depfilePath: argResults['depfile'],
privateKeyPath: argResults['private-key'], privateKeyPath: argResults['private-key'],
workingDirPath: argResults['working-dir'], workingDirPath: argResults['working-dir'],
......
...@@ -58,6 +58,7 @@ class _StdoutHandler { ...@@ -58,6 +58,7 @@ class _StdoutHandler {
Future<String> compile( Future<String> compile(
{String sdkRoot, {String sdkRoot,
String mainPath, String mainPath,
String outputFilePath,
bool linkPlatformKernelIn: false, bool linkPlatformKernelIn: false,
bool aot: false, bool aot: false,
bool trackWidgetCreation: false, bool trackWidgetCreation: false,
...@@ -91,6 +92,9 @@ Future<String> compile( ...@@ -91,6 +92,9 @@ Future<String> compile(
if (packagesPath != null) { if (packagesPath != null) {
command.addAll(<String>['--packages', packagesPath]); command.addAll(<String>['--packages', packagesPath]);
} }
if (outputFilePath != null) {
command.addAll(<String>['--output-dill', outputFilePath]);
}
if (extraFrontEndOptions != null) if (extraFrontEndOptions != null)
command.addAll(extraFrontEndOptions); command.addAll(extraFrontEndOptions);
...@@ -140,13 +144,14 @@ class ResidentCompiler { ...@@ -140,13 +144,14 @@ class ResidentCompiler {
/// into new binary. /// into new binary.
/// Binary file name is returned if compilation was successful, otherwise /// Binary file name is returned if compilation was successful, otherwise
/// null is returned. /// null is returned.
Future<String> recompile(String mainPath, List<String> invalidatedFiles) async { Future<String> recompile(String mainPath, List<String> invalidatedFiles,
{String outputPath}) async {
stdoutHandler.reset(); stdoutHandler.reset();
// First time recompile is called we actually have to compile the app from // First time recompile is called we actually have to compile the app from
// scratch ignoring list of invalidated files. // scratch ignoring list of invalidated files.
if (_server == null) if (_server == null)
return _compile(mainPath); return _compile(mainPath, outputPath);
final String inputKey = new Uuid().generateV4(); final String inputKey = new Uuid().generateV4();
_server.stdin.writeln('recompile $inputKey'); _server.stdin.writeln('recompile $inputKey');
...@@ -156,7 +161,7 @@ class ResidentCompiler { ...@@ -156,7 +161,7 @@ class ResidentCompiler {
return stdoutHandler.outputFilename.future; return stdoutHandler.outputFilename.future;
} }
Future<String> _compile(String scriptFilename) async { Future<String> _compile(String scriptFilename, String outputPath) async {
final String frontendServer = artifacts.getArtifactPath( final String frontendServer = artifacts.getArtifactPath(
Artifact.frontendServerSnapshotForEngineDartSdk Artifact.frontendServerSnapshotForEngineDartSdk
); );
...@@ -168,6 +173,9 @@ class ResidentCompiler { ...@@ -168,6 +173,9 @@ class ResidentCompiler {
'--incremental', '--incremental',
'--strong' '--strong'
]; ];
if (outputPath != null) {
args.addAll(<String>['--output-dill', outputPath]);
}
if (_trackWidgetCreation) { if (_trackWidgetCreation) {
args.add('--track-widget-creation'); args.add('--track-widget-creation');
} }
......
...@@ -499,7 +499,8 @@ class DevFS { ...@@ -499,7 +499,8 @@ class DevFS {
generator.reset(); generator.reset();
} }
final String compiledBinary = final String compiledBinary =
await generator.recompile(mainPath, invalidatedFiles); await generator.recompile(mainPath, invalidatedFiles,
outputPath: fs.path.join(getBuildDirectory(), 'app.dill'));
if (compiledBinary != null && compiledBinary.isNotEmpty) if (compiledBinary != null && compiledBinary.isNotEmpty)
dirtyEntries.putIfAbsent( dirtyEntries.putIfAbsent(
Uri.parse(target + '.dill'), Uri.parse(target + '.dill'),
......
...@@ -22,6 +22,7 @@ const String defaultManifestPath = 'pubspec.yaml'; ...@@ -22,6 +22,7 @@ const String defaultManifestPath = 'pubspec.yaml';
String get defaultFlxOutputPath => fs.path.join(getBuildDirectory(), 'app.flx'); String get defaultFlxOutputPath => fs.path.join(getBuildDirectory(), 'app.flx');
String get defaultSnapshotPath => fs.path.join(getBuildDirectory(), 'snapshot_blob.bin'); String get defaultSnapshotPath => fs.path.join(getBuildDirectory(), 'snapshot_blob.bin');
String get defaultDepfilePath => fs.path.join(getBuildDirectory(), 'snapshot_blob.bin.d'); String get defaultDepfilePath => fs.path.join(getBuildDirectory(), 'snapshot_blob.bin.d');
String get defaultApplicationKernelPath => fs.path.join(getBuildDirectory(), 'app.dill');
const String defaultPrivateKeyPath = 'privatekey.der'; const String defaultPrivateKeyPath = 'privatekey.der';
const String _kKernelKey = 'kernel_blob.bin'; const String _kKernelKey = 'kernel_blob.bin';
...@@ -34,6 +35,7 @@ Future<Null> build({ ...@@ -34,6 +35,7 @@ Future<Null> build({
String manifestPath: defaultManifestPath, String manifestPath: defaultManifestPath,
String outputPath, String outputPath,
String snapshotPath, String snapshotPath,
String applicationKernelFilePath,
String depfilePath, String depfilePath,
String privateKeyPath: defaultPrivateKeyPath, String privateKeyPath: defaultPrivateKeyPath,
String workingDirPath, String workingDirPath,
...@@ -48,6 +50,7 @@ Future<Null> build({ ...@@ -48,6 +50,7 @@ Future<Null> build({
depfilePath ??= defaultDepfilePath; depfilePath ??= defaultDepfilePath;
workingDirPath ??= getAssetBuildDirectory(); workingDirPath ??= getAssetBuildDirectory();
packagesPath ??= fs.path.absolute(PackageMap.globalPackagesPath); packagesPath ??= fs.path.absolute(PackageMap.globalPackagesPath);
applicationKernelFilePath ??= defaultApplicationKernelPath;
File snapshotFile; File snapshotFile;
if (!precompiledSnapshot && !previewDart2) { if (!precompiledSnapshot && !previewDart2) {
...@@ -70,10 +73,13 @@ Future<Null> build({ ...@@ -70,10 +73,13 @@ Future<Null> build({
DevFSContent kernelContent; DevFSContent kernelContent;
if (!precompiledSnapshot && previewDart2) { if (!precompiledSnapshot && previewDart2) {
ensureDirectoryExists(applicationKernelFilePath);
final String kernelBinaryFilename = await compile( final String kernelBinaryFilename = await compile(
sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath), sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath),
incrementalCompilerByteStorePath: fs.path.absolute(getIncrementalCompilerByteStoreDirectory()), incrementalCompilerByteStorePath: fs.path.absolute(getIncrementalCompilerByteStoreDirectory()),
mainPath: fs.file(mainPath).absolute.path, mainPath: fs.file(mainPath).absolute.path,
outputFilePath: applicationKernelFilePath,
trackWidgetCreation: trackWidgetCreation, trackWidgetCreation: trackWidgetCreation,
); );
if (kernelBinaryFilename == null) { if (kernelBinaryFilename == null) {
......
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