public override CompileResult Compile(IConsole console, IStandardProject superProject, IStandardProject project,
ISourceFile file, string outputFile)
{
var result = new CompileResult();
var startInfo = new ProcessStartInfo();
if (file.Language == Language.Cpp)
{
startInfo.FileName = Path.Combine(BaseDirectory, "arm-none-eabi-g++" + Platform.ExecutableExtension);
}
else
{
startInfo.FileName = Path.Combine(BaseDirectory, "arm-none-eabi-gcc" + Platform.ExecutableExtension);
}
startInfo.WorkingDirectory = file.CurrentDirectory;
if (!File.Exists(startInfo.FileName))
{
result.ExitCode = -1;
console.WriteLine("Unable to find compiler (" + startInfo.FileName + ") Please check project compiler settings.");
}
else
{
var fileArguments = string.Empty;
if (file.Language == Language.Cpp)
{
fileArguments = "-x c++ -fno-use-cxa-atexit";
}
startInfo.Arguments = string.Format("{0} {1} {2} -o{3} -MMD -MP", fileArguments,
GetCompilerArguments(superProject, project, file), file.Location, outputFile);
// Hide console window
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
startInfo.CreateNoWindow = true;
//console.WriteLine (Path.GetFileNameWithoutExtension(startInfo.FileName) + " " + startInfo.Arguments);
using (var process = Process.Start(startInfo))
{
process.OutputDataReceived += (sender, e) => { console.WriteLine(e.Data); };
process.ErrorDataReceived += (sender, e) =>
{
if (e.Data != null)
{
console.WriteLine();
console.WriteLine(e.Data);
}
};
process.BeginOutputReadLine();
process.BeginErrorReadLine();
process.WaitForExit();
result.ExitCode = process.ExitCode;
}
}
return result;
}