compile method
Future<File>
compile(
{ - required Directory root,
})
Implementation
Future<File> compile({
required Directory root,
}) async {
final kernel = await root.getInternalRevaliFile(kernelFile);
final toCompile = await root.getInternalRevaliFile(entrypointFile);
final dartTool = await root.getDartTool();
final packageJson = dartTool.childFile('package_config.json');
if (!await packageJson.exists()) {
final progress = logger.progress('Running pub get');
final result = await Process.run(
'dart',
[
'pub',
'get',
'--no-precompile',
],
workingDirectory: root.path,
);
progress.complete('Got dependencies');
if (result.exitCode != 0) {
throw Exception('Failed to get dependencies');
}
}
final result = await Process.run(
'dart',
[
'compile',
'kernel',
toCompile.path,
'-o',
kernel.path,
],
runInShell: true,
);
if (result.exitCode != 0) {
throw Exception('''
Failed to compile entrypoint
Error:
${result.stderr}''');
}
return kernel;
}