public abstract Task <bool> PostBuild(IConsole console, IProject project, LinkResult linkResult);
public abstract ProcessResult Size(IConsole console, IStandardProject project, LinkResult linkResult);
private LinkResult Link(IConsole console, IStandardProject superProject, CompileResult compileResult, CompileResult linkResults, string label = "") { var binDirectory = compileResult.Project.GetBinDirectory(superProject); if (!Directory.Exists(binDirectory)) { Directory.CreateDirectory(binDirectory); } var outputLocation = binDirectory; var executable = Path.Combine(outputLocation, compileResult.Project.Name); if (!string.IsNullOrEmpty(label)) { executable += string.Format("-{0}", label); } if (compileResult.Project.Type == ProjectType.StaticLibrary) { executable = Path.Combine(outputLocation, "lib" + compileResult.Project.Name); executable += StaticLibraryExtension; } else { executable += ExecutableExtension; } if (!Directory.Exists(outputLocation)) { Directory.CreateDirectory(outputLocation); } var link = false; foreach (var objectFile in compileResult.ObjectLocations) { if (System.IO.File.GetLastWriteTime(objectFile) > System.IO.File.GetLastWriteTime(executable)) { link = true; break; } } if (!link) { foreach (var library in compileResult.LibraryLocations) { if (System.IO.File.GetLastWriteTime(library) > System.IO.File.GetLastWriteTime(executable)) { link = true; break; } } } var linkResult = new LinkResult { Executable = executable }; if (link) { console.OverWrite(string.Format("[LL] [{0}]", compileResult.Project.Name)); linkResult = Link(console, superProject, compileResult.Project, compileResult, executable); } if (linkResult.ExitCode == 0) { if (compileResult.Project.Type == ProjectType.StaticLibrary) { if (compileResult.ObjectLocations.Count > 0) // This is where we have a libray with just headers. { linkResults.LibraryLocations.Add(executable); } } else { superProject.Executable = superProject.Location.MakeRelativePath(linkResult.Executable).ToAvalonPath(); superProject.Save(); console.WriteLine(); Size(console, compileResult.Project, linkResult); linkResults.ExecutableLocations.Add(executable); } } else if (linkResults.ExitCode == 0) { linkResults.ExitCode = linkResult.ExitCode; } return(linkResult); }
public abstract Task<bool> PostBuild(IConsole console, IProject project, LinkResult linkResult);
public override async Task<bool> PostBuild(IConsole console, IProject project, LinkResult linkResult) { return true; }
private LinkResult Link(IConsole console, IStandardProject superProject, CompileResult compileResult, CompileResult linkResults, string label = "") { var binDirectory = compileResult.Project.GetBinDirectory(superProject); if (!Directory.Exists(binDirectory)) { Directory.CreateDirectory(binDirectory); } var outputLocation = binDirectory; var executable = Path.Combine(outputLocation, compileResult.Project.Name); if (!string.IsNullOrEmpty(label)) { executable += string.Format("-{0}", label); } if (compileResult.Project.Type == ProjectType.StaticLibrary) { executable = Path.Combine(outputLocation, "lib" + compileResult.Project.Name); executable += StaticLibraryExtension; } else { executable += ExecutableExtension; } if (!Directory.Exists(outputLocation)) { Directory.CreateDirectory(outputLocation); } var link = false; foreach (var objectFile in compileResult.ObjectLocations) { if (System.IO.File.GetLastWriteTime(objectFile) > System.IO.File.GetLastWriteTime(executable)) { link = true; break; } } if (!link) { foreach (var library in compileResult.LibraryLocations) { if (System.IO.File.GetLastWriteTime(library) > System.IO.File.GetLastWriteTime(executable)) { link = true; break; } } } var linkResult = new LinkResult {Executable = executable}; if (link) { console.OverWrite(string.Format("[LL] [{0}]", compileResult.Project.Name)); linkResult = Link(console, superProject, compileResult.Project, compileResult, executable); } if (linkResult.ExitCode == 0) { if (compileResult.Project.Type == ProjectType.StaticLibrary) { if (compileResult.ObjectLocations.Count > 0) // This is where we have a libray with just headers. { linkResults.LibraryLocations.Add(executable); } } else { superProject.Executable = superProject.Location.MakeRelativePath(linkResult.Executable).ToAvalonPath(); superProject.Save(); console.WriteLine(); Size(console, compileResult.Project, linkResult); linkResults.ExecutableLocations.Add(executable); } } else if (linkResults.ExitCode == 0) { linkResults.ExitCode = linkResult.ExitCode; } return linkResult; }
public override ProcessResult Size(IConsole console, IStandardProject project, LinkResult linkResult) { var result = new ProcessResult(); var startInfo = new ProcessStartInfo(); startInfo.FileName = Path.Combine(BaseDirectory, "GCC\\bin", "arm-none-eabi-size.exe"); if (Path.IsPathRooted(startInfo.FileName) && !System.IO.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 override LinkResult Link(IConsole console, IStandardProject superProject, IStandardProject project, CompileResult assemblies, string outputDirectory) { var result = new LinkResult(); var startInfo = new ProcessStartInfo(); startInfo.FileName = Path.Combine(BaseDirectory, "GCC\\bin", "arm-none-eabi-gcc.exe"); if (project.Type == ProjectType.StaticLibrary) { startInfo.FileName = Path.Combine(BaseDirectory, "GCC\\bin", "arm-none-eabi-ar.exe"); } startInfo.WorkingDirectory = project.Solution.CurrentDirectory; if (Path.IsPathRooted(startInfo.FileName) && !System.IO.File.Exists(startInfo.FileName)) { result.ExitCode = -1; console.WriteLine("Unable to find linker executable (" + startInfo.FileName + ") Check project compiler settings."); return result; } // GenerateLinkerScript(project); var objectArguments = string.Empty; foreach (var obj in assemblies.ObjectLocations) { objectArguments += obj + " "; } var libs = string.Empty; foreach (var lib in assemblies.LibraryLocations) { libs += lib + " "; } if (!Directory.Exists(outputDirectory)) { Directory.CreateDirectory(outputDirectory); } var outputName = Path.GetFileNameWithoutExtension(project.Location) + ".elf"; if (project.Type == ProjectType.StaticLibrary) { outputName = "lib" + Path.GetFileNameWithoutExtension(project.Name) + ".a"; } var executable = Path.Combine(outputDirectory, outputName); var linkedLibraries = string.Empty; foreach (var libraryPath in project.StaticLibraries) { var relativePath = project.CurrentDirectory; var 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(superProject, 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 LinkResult Link(IConsole console, IStandardProject superProject, IStandardProject project, CompileResult assemblies, string outputPath) { var settings = GetSettings(superProject); var result = new LinkResult(); var startInfo = new ProcessStartInfo(); startInfo.FileName = Path.Combine(BaseDirectory, "arm-none-eabi-gcc" + Platform.ExecutableExtension); if (project.Type == ProjectType.StaticLibrary) { startInfo.FileName = Path.Combine(BaseDirectory, "arm-none-eabi-ar" + Platform.ExecutableExtension); } 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; } var objectArguments = string.Empty; foreach (var obj in assemblies.ObjectLocations) { objectArguments += obj + " "; } var libs = string.Empty; foreach (var lib in assemblies.LibraryLocations) { libs += lib + " "; } var outputDir = Path.GetDirectoryName(outputPath); if (!Directory.Exists(outputDir)) { Directory.CreateDirectory(outputDir); } var outputName = Path.GetFileNameWithoutExtension(outputPath) + ExecutableExtension; if (project.Type == ProjectType.StaticLibrary) { outputName = Path.GetFileNameWithoutExtension(outputPath) + StaticLibraryExtension; } else { GenerateLinkerScript(superProject); } var executable = Path.Combine(outputDir, outputName); var linkedLibraries = string.Empty; foreach (var libraryPath in project.StaticLibraries) { var relativePath = Path.GetDirectoryName(libraryPath); var 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); } // TODO linked libraries won't make it in on nano... Please fix -L directory placement in compile string. switch (settings.LinkSettings.Library) { case LibraryType.NanoCLib: linkedLibraries += "-lm -lc_nano -lsupc++_nano -lstdc++_nano "; break; case LibraryType.BaseCLib: linkedLibraries += "-lm -lc -lstdc++ -lsupc++ "; break; case LibraryType.SemiHosting: linkedLibraries += "-lm -lgcc -lc -lrdimon "; break; case LibraryType.Retarget: linkedLibraries += "-lm -lc -lnosys -lstdc++ -lsupc++ "; break; } // Hide console window startInfo.UseShellExecute = false; startInfo.RedirectStandardOutput = true; startInfo.RedirectStandardError = true; startInfo.RedirectStandardInput = true; startInfo.CreateNoWindow = true; if (project.Type == ProjectType.StaticLibrary) { startInfo.Arguments = string.Format("rvs {0} {1}", executable, objectArguments); } else { startInfo.Arguments = string.Format("{0} -o{1} {2} -Wl,--start-group {3} {4} -Wl,--end-group", GetLinkerArguments(project), executable, objectArguments, linkedLibraries, libs); } //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; }