public override LinkResult Link(IConsole console, Project superProject, Project project, CompileResult assemblies, string outputDirectory) { LinkResult result = new LinkResult(); ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = Path.Combine(Settings.ToolChainLocation, "arm-none-eabi-gcc.exe"); if (project.Type == ProjectType.StaticLibrary) { startInfo.FileName = Path.Combine(Settings.ToolChainLocation, "arm-none-eabi-ar.exe"); } startInfo.WorkingDirectory = project.Solution.CurrentDirectory; if (!File.Exists(startInfo.FileName)) { result.ExitCode = -1; console.WriteLine("Unable to find linker executable (" + startInfo.FileName + ") Check project compiler settings."); return result; } // GenerateLinkerScript(project); string objectArguments = string.Empty; foreach (string obj in assemblies.ObjectLocations) { objectArguments += obj + " "; } string libs = string.Empty; foreach (string lib in assemblies.LibraryLocations) { libs += lib + " "; } if (!Directory.Exists(outputDirectory)) { Directory.CreateDirectory(outputDirectory); } string outputName = Path.GetFileNameWithoutExtension(project.Location) + ".elf"; if (project.Type == ProjectType.StaticLibrary) { outputName = "lib" + Path.GetFileNameWithoutExtension(project.Name) + ".a"; } var executable = Path.Combine(outputDirectory, outputName); string linkedLibraries = string.Empty; //foreach (var libraryPath in project.SelectedConfiguration.LinkedLibraries) //{ // string relativePath = Path.GetDirectoryName(libraryPath); // string libName = Path.GetFileNameWithoutExtension(libraryPath).Substring(3); // linkedLibraries += string.Format(" -L\"{0}\" -l{1}", relativePath, libName); //} foreach (var lib in project.BuiltinLibraries) { linkedLibraries += string.Format("-l{0} ", lib); } // Hide console window startInfo.UseShellExecute = false; startInfo.RedirectStandardOutput = true; startInfo.RedirectStandardError = true; startInfo.RedirectStandardInput = true; startInfo.CreateNoWindow = true; startInfo.Arguments = string.Format("{0} -o{1} {2} -Wl,--start-group {3} {4} -Wl,--end-group", GetLinkerArguments(project), executable, objectArguments, linkedLibraries, libs); if (project.Type == ProjectType.StaticLibrary) { startInfo.Arguments = string.Format("rvs {0} {1}", executable, objectArguments); } //console.WriteLine(Path.GetFileNameWithoutExtension(startInfo.FileName) + " " + startInfo.Arguments); //console.WriteLine ("[LL] - " + startInfo.Arguments); using (var process = Process.Start(startInfo)) { process.OutputDataReceived += (sender, e) => { //console.WriteLine(e.Data); }; process.ErrorDataReceived += (sender, e) => { if (e.Data != null && !e.Data.Contains("creating")) { console.WriteLine(e.Data); } }; process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.WaitForExit(); result.ExitCode = process.ExitCode; if (result.ExitCode == 0) { result.Executable = executable; } } return result; }
public override ProcessResult Size(IConsole console, Project project, LinkResult linkResult) { ProcessResult result = new ProcessResult(); ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = Path.Combine(Settings.ToolChainLocation, "arm-none-eabi-size.exe"); if (!File.Exists(startInfo.FileName)) { console.WriteLine("Unable to find tool (" + startInfo.FileName + ") check project compiler settings."); result.ExitCode = -1; return result; } startInfo.Arguments = string.Format("{0}", linkResult.Executable); // Hide console window startInfo.UseShellExecute = false; startInfo.RedirectStandardOutput = true; startInfo.RedirectStandardError = true; startInfo.RedirectStandardInput = true; startInfo.CreateNoWindow = true; using (var process = Process.Start(startInfo)) { process.OutputDataReceived += (sender, e) => { console.WriteLine(e.Data); }; process.ErrorDataReceived += (sender, e) => { console.WriteLine(e.Data); }; process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.WaitForExit(); result.ExitCode = process.ExitCode; } return result; }
public abstract ProcessResult Size(IConsole console, Project project, LinkResult linkResult);