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