public void AppendedTest() { AbsoluteCrosspath xLocalIncludeDirectory = AbsoluteCrosspath.GetCurrentDirectory(); RelativeCrosspath xRelPath = RelativeCrosspath.FromString("lzcintrin.h"); AbsoluteCrosspath xPath = xLocalIncludeDirectory.Appended(xRelPath); Assert.AreEqual(xPath.ToString(), xLocalIncludeDirectory + @"\" + xRelPath); }
public void DownloadStandardIncludeDirectories(RemoteHost remote) { if (Skip) { return; } // use sftp, or, when not possible, ssh cat AbsoluteCrosspath xpwd = AbsoluteCrosspath.GetCurrentDirectory(); AbsoluteCrosspath xCompilerDir = xpwd.Appended(RelativeCrosspath.FromString($@"compilers\{ShortName}")); Directory.CreateDirectory(xCompilerDir.ToString()); foreach (IncludeDirectory includeDirectory in IncludeDirectories) { includeDirectory.RebaseToLocal(remote, xCompilerDir); } }
private static void Main(String[] args) { #if !DEBUG try { #endif ProcessArgs(args); if (config.InputFile == null) { ShowHelp(); } Stopwatch sw = new Stopwatch(); sw.Start(); Solution sln = new Solution(config); sln.ParseCompileDB(config.InputFile); sw.Stop(); Int64 parseAndGroup = sw.ElapsedMilliseconds; sw.Reset(); sw.Start(); if (config.Remote != null) { sln.RetrieveExtraInfoFromRemote(config.Remote); } sw.Stop(); Int64 remoteInfo = sw.ElapsedMilliseconds; sln.FilterOutEntries(); sw.Reset(); sw.Start(); foreach (Tuple <AbsoluteCrosspath, AbsoluteCrosspath> substitution in config.Substitutions) { sln.Rebase(substitution.Item1, substitution.Item2); } sw.Stop(); Int64 rebase = sw.ElapsedMilliseconds; // DONE: also check for: // - project file accessibility // - include dirs accessibility List <IncludeDirectory> remoteNotRebased = new List <IncludeDirectory>(); sln.CheckForTotalRebase(ref remoteNotRebased); try { Directory.Delete(config.Outdir, true); } catch { // ignored } if (config.Remote != null) { sln.DownloadCompilerIncludeDirectoriesFromRemote(config.Remote, config.Outdir); foreach (IncludeDirectory includeDirectory in remoteNotRebased) { Crosspath outdir = Crosspath.FromString(config.Outdir); if (outdir is RelativeCrosspath relativeCrosspath) { outdir = relativeCrosspath.Absolutized(AbsoluteCrosspath.GetCurrentDirectory()); } includeDirectory.RebaseToLocal(config.Remote , ((AbsoluteCrosspath)outdir).Append( RelativeCrosspath.FromString(String.Format(SolutionStructure.RemoteIncludePath , config.Remote.Host)))); } } sw.Reset(); sw.Start(); sln.WriteToDirectory(config.Outdir); sw.Stop(); Int64 write = sw.ElapsedMilliseconds; Console.WriteLine(); Console.WriteLine($"Elapsed time: parseAndGroup = {parseAndGroup} ms, remoteInfo = {remoteInfo} ms" + $", rebase = {rebase} ms, write = {write} ms."); if (config.OpenSolution) { Process.Start(new ProcessStartInfo(Path.Combine(config.Outdir, SolutionStructure.SolutionFilename)) { UseShellExecute = true }); } #if !DEBUG } catch (Exception e) { Console.WriteLine($"[x] {e.Message}"); Console.WriteLine(); Console.WriteLine("Stack trace for debugging purposes:"); Console.WriteLine($"{e.StackTrace}"); Console.WriteLine("Press Enter to continue..."); Console.ReadLine(); } #endif }
/// <summary> /// Writes compiler_${ShortName}.props and compiler_$(ShortName}_compat.h /// </summary> public void WriteToFile(AbsoluteCrosspath solutionDir) { if (Skip) { return; } AbsoluteCrosspath compilerDir = RelativeCrosspath.FromString(PropsFileName).Absolutized(AbsoluteCrosspath.GetCurrentDirectory()).ToContainingDirectory(); Directory.CreateDirectory(compilerDir.ToString()); foreach (CompilerInstance compilerInstance in Instances) { compilerInstance.WriteToFile(solutionDir); } XmlDocument doc = new XmlDocument(); doc.AppendChild(doc.CreateXmlDeclaration("1.0", "utf-8", null)); XmlElement projectNode = doc.CreateElement("Project"); projectNode.SetAttribute("DefaultTargets", "Build"); projectNode.SetAttribute("ToolsVersion", "Current"); projectNode.SetAttribute("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003"); XmlElement projectImportProps = doc.CreateElement("Import"); projectImportProps.SetAttribute("Project", @"$(SolutionDir)\Solution.props"); projectNode.AppendChild(projectImportProps); XmlElement projectPropertyGroupCompiler = doc.CreateElement("PropertyGroup"); XmlElement projectCompilerExeName = doc.CreateElement("RemoteCCompileToolExe"); projectCompilerExeName.InnerText = ExePath.ToString(); projectPropertyGroupCompiler.AppendChild(projectCompilerExeName); XmlElement projectCompilerCppExeName = doc.CreateElement("RemoteCppCompileToolExe"); projectCompilerCppExeName.InnerText = ExePath.ToString(); projectPropertyGroupCompiler.AppendChild(projectCompilerCppExeName); projectNode.AppendChild(projectPropertyGroupCompiler); doc.AppendChild(projectNode); doc.Save(PropsFileName); }
public void WriteToDirectory(String directory) { Directory.CreateDirectory(directory); String pwd = Directory.GetCurrentDirectory(); Directory.SetCurrentDirectory(directory); AbsoluteCrosspath solutionDir = AbsoluteCrosspath.GetCurrentDirectory(); foreach (Compiler compiler in solutionCompilers) { compiler.WriteToFile(solutionDir); } foreach (Project projectKvp in projects.Values) { // remember there will also be .vcxproj.filters projectKvp.WriteToFile(solutionDir); } // TODO: add them as "Solution Items" File.WriteAllText(SolutionStructure.ForcedIncludes.SolutionCompat, @"#pragma once"); File.WriteAllText(SolutionStructure.ForcedIncludes.SolutionPostCompat, templates.SolutionCompat); // regarding compiler_compat.h: // generate one file per compiler and reference them from projects // see Compiler.WriteToFile() instead File.WriteAllBytes(SolutionStructure.SolutionPropsFilename, templates.SolutionProps); // write .sln itself // using simple text generator using (StreamWriter sw = new StreamWriter(SolutionStructure.SolutionFilename, false, Encoding.UTF8)) { sw.WriteLine(""); sw.WriteLine("Microsoft Visual Studio Solution File, Format Version 12.00"); sw.WriteLine("# Visual Studio Version 16"); sw.WriteLine("VisualStudioVersion = 16.0.31613.86"); sw.WriteLine("MinimumVisualStudioVersion = 10.0.40219.1"); foreach (Project project in projects.Values) { if (project.Skip || project.CompilerInstance.BaseCompiler.Skip) { continue; } // this magic GUID is "Windows (Visual C++)" project type sw.WriteLine($"Project(\"{{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}}\") = \"{project.Name}\", \"{project.Filename}\", \"{{{project.Guid.ToString().ToUpper()}}}\""); sw.WriteLine("EndProject"); } // this magic GUID is "Solution Folder" sw.WriteLine($"Project(\"{{2150E333-8FDC-42A3-9474-1A3956D46DE8}}\") = \"Compat files\", \"Compat files\", \"{{{AllocateGuid()}}}\""); sw.WriteLine("\tProjectSection(SolutionItems) = preProject"); sw.WriteLine("\t\tsolution_compat.h = solution_compat.h"); sw.WriteLine("\t\tsolution_post_compiler_compat.h = solution_post_compiler_compat.h"); sw.WriteLine("\tEndProjectSection"); sw.WriteLine("EndProject"); sw.WriteLine("Global"); sw.WriteLine("GlobalSection(SolutionConfigurationPlatforms) = preSolution"); foreach (String cfg in SolutionStructure.SolutionConfigurations) { sw.WriteLine($"\t\t{cfg}|{SolutionStructure.SolutionPlatformName} = {cfg}|{SolutionStructure.SolutionPlatformName}"); } sw.WriteLine("EndGlobalSection"); sw.WriteLine("GlobalSection(ProjectConfigurationPlatforms) = postSolution"); String[] cfgStages = { "ActiveCfg", "Build.0", "Deploy.0" }; foreach (Project project in projects.Values) { if (project.Skip || project.CompilerInstance.BaseCompiler.Skip) { continue; } foreach (String cfg in SolutionStructure.SolutionConfigurations) { foreach (String cfgStage in cfgStages) { sw.WriteLine($"\t\t{{{project.Guid.ToString().ToUpper()}}}.{cfg}|{SolutionStructure.SolutionPlatformName}.{cfgStage} = {cfg}|{project.CompilerInstance.VSPlatform}"); } } } sw.WriteLine("\tEndGlobalSection"); sw.WriteLine("\tGlobalSection(SolutionProperties) = preSolution"); sw.WriteLine("\t\tHideSolutionNode = FALSE"); sw.WriteLine("\tEndGlobalSection"); sw.WriteLine("\tGlobalSection(ExtensibilityGlobals) = postSolution"); sw.WriteLine($"\t\tSolutionGuid = {{{selfGuid}}}"); sw.WriteLine("\tEndGlobalSection"); sw.WriteLine("EndGlobal"); sw.Close(); } Directory.SetCurrentDirectory(pwd); }