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); }
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; }