runDartCompiler method
Run the 'dart compiler' command.
script
is the path to the dcli script we are compiling.
pathToExe
is the path (including the filename) to write the
compiled ex to .
Implementation
void runDartCompiler(Script script,
{required String pathToExe, Progress? progress}) {
final runArgs = <String>[];
RunnableProcess process;
if (useDartCommand) {
/// use dart compile exe
runArgs
..add('compile')
..add('exe')
..add(script.pathToScript)
..add('--output=$pathToExe');
process = RunnableProcess.fromCommandArgs(dartExeName, runArgs,
workingDirectory: script.pathToScriptDirectory);
} else {
if (pathToDartToNativeExe == null) {
throw DCliException('Unable to compile as the dart2native executable '
'not found on your path.');
}
/// use old dart2native
runArgs..add(script.pathToScript)..add('--output=$pathToExe');
process = RunnableProcess.fromCommandArgs(pathToDartToNativeExe!, runArgs,
workingDirectory: script.pathToScriptDirectory);
}
process
..start()
..processUntilExit(progress, nothrow: false);
}