public ProjectGenerator(ProjectModels projectModels, Dictionary <string, Dictionary <CSharpFileModel, CSharpFileModelNodes> > modelsByNamespaceMap) { this.projectModels = projectModels; this.namespaceTree = new NamespaceTreeNode("", ""); foreach (var namespaceAndModels in modelsByNamespaceMap) { // Sort by file so output is same no matter the timing CSharpFileModelNodes[] sortedFileModels = namespaceAndModels.Value.Values.ToSortedArray(); this.namespaceTree.Add(namespaceAndModels.Key, 0, sortedFileModels); } // Sort by namespace so output is same no matter the timing this.namespaceTree.Sort(); }
public CSharpFileModel(ProjectModels containingProject, Document document) { this.containingProject = containingProject; this.document = document; }
static int Main(string[] args) { var startTime = Stopwatch.GetTimestamp(); try { int argsLength = getopt(args); String configFile = null; if (argsLength == 1) { configFile = args[0]; } else if (argsLength > 1) { Console.WriteLine("Error: too many command line arguments"); return(1); } if (configFile == null) { configFile = FindConversionRootAndConfigFile(); } else { if (!File.Exists(configFile)) { throw new ErrorMessageException(String.Format("{0} does not exist", configFile)); } conversionRoot = Path.GetDirectoryName(configFile); } config = new Config(configFile); if (config.projects.Count == 0) { Console.WriteLine("There are no projects configured"); return(0); } mscorlibPath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), Path.Combine("..", Path.Combine("..", Path.Combine("mscorlib", "cs2d"))))); if (!config.noMscorlib) { String mscorlibFilename = Path.Combine(mscorlibPath, "mscorlib.lib"); // Check that mscorlib exists if (!File.Exists(mscorlibFilename)) { Console.WriteLine("Error: mscorlib is not built: {0}", mscorlibFilename); return(1); } } //Console.WriteLine("[DEBUG] There are {0} project(s)", config.projects.Count); ProjectModels[] projectModelsArray = new ProjectModels[config.projects.Count]; { int projectIndex = 0; foreach (ProjectConfig projectConfig in config.projects) { String projectFileFullPath = Path.Combine(conversionRoot, projectConfig.projectFile); if (!File.Exists(projectFileFullPath)) { Console.WriteLine("Error: project does not exist: {0}", projectFileFullPath); return(1); } projectModelsArray[projectIndex] = new ProjectModels(projectConfig, projectFileFullPath); projectIndex++; } } // Setup Directory generatedCodePath = Path.Combine(conversionRoot, "cs2d"); if (Directory.Exists(generatedCodePath)) { if (clean) { Console.WriteLine("[{0}] Cleaning '{1}'", Thread.CurrentThread.ManagedThreadId, generatedCodePath); Directory.Delete(generatedCodePath, true); Directory.CreateDirectory(generatedCodePath); } } else { Directory.CreateDirectory(generatedCodePath); } MSBuildWorkspace workspace = MSBuildWorkspace.Create(config.msbuildProperties); workspace.LoadMetadataForReferencedProjects = true; workspace.SkipUnrecognizedProjects = false; // Start the tasks to load and process all the projects/files for (int projectIndex = 0; projectIndex < projectModelsArray.Length; projectIndex++) { ProjectModels projectModels = projectModelsArray[projectIndex]; Console.WriteLine("[{0}] Starting project loader for '{1}'...", Thread.CurrentThread.ManagedThreadId, projectModels.fileFullPath); TaskManager.AddTask(workspace.OpenProjectAsync(projectModels.fileFullPath). ContinueWith(projectModels.ProjectLoaded)); } // Wait for all files in all projects to be processed if (!TaskManager.WaitLoop()) { return(1); // fail } DlangBuildGenerator.MakeDProjectFile(config, projectModelsArray); // // Compile D Code // String rdmdProgram = FindProgram("rdmd"); if (rdmdProgram == null) { Console.WriteLine("rdmd not found, cannot compile D code"); } else { Console.WriteLine(); Console.WriteLine("======================= Compiling D Code ========================"); { Process compilerProcess = new Process(); compilerProcess.StartInfo.FileName = rdmdProgram; compilerProcess.StartInfo.Arguments = Path.Combine(generatedCodePath, "build.d"); compilerProcess.StartInfo.UseShellExecute = false; Console.WriteLine("[RUN] '{0} {1}'", compilerProcess.StartInfo.FileName, compilerProcess.StartInfo.Arguments); compilerProcess.Start(); compilerProcess.WaitForExit(); if (compilerProcess.ExitCode != 0) { Console.WriteLine("Compile Failed (exit code {0})", compilerProcess.ExitCode); return(1); } } } Console.WriteLine("TotalTime Time: {0} secs", (float)(Stopwatch.GetTimestamp() - startTime) / (float)Stopwatch.Frequency); return(0); } catch (ErrorMessageException e) { Console.WriteLine("Error: {0}", e.Message); return(1); } catch (AlreadyPrintedErrorException) { return(1); } }