Exemplo n.º 1
0
        private void CreateCompilationCommands(Utility.CompileCommandFileWriter fileWriter, EnvDTE.Project project, ref int projectsProcessed)
        {
            try
            {
                SolutionParser.SolutionParser solutionParser = new SolutionParser.SolutionParser(new VsPathResolver(_targetDir));

                solutionParser.CreateCompileCommands(
                    project, _configurationName, _platformName, _cStandard, _additionalClangOptions, _nonSystemIncludesUseAngleBrackets,
                    (CompileCommand command) => { fileWriter.PushCommand(command); }
                    );

                lock (_lockObject)
                {
                    projectsProcessed++;
                }

                float relativProgress = (float)projectsProcessed / (float)_projects.Count;
                Logging.Logging.LogInfo("Processing project \"" + Logging.Obfuscation.NameObfuscator.GetObfuscatedName(project.Name) + "\"");
                backgroundWorker1.ReportProgress((int)(relativProgress * 100), "Processing project \"" + project.Name + "\"");
            }
            catch (Exception e)
            {
                Logging.Logging.LogError("Failed to create CDB for project with exception: " + e.Message);
                Logging.Logging.LogError("Stack Trace: " + e.StackTrace);
                throw;
            }
        }
Exemplo n.º 2
0
		private static CompilationDatabase CreateCompilationDatabaseForCurrentSolution(bool nonSystemIncludesUseAngleBrackets)
		{
			DTE dte = (DTE)VsIdeTestHostContext.ServiceProvider.GetService(typeof(DTE));
			Assert.IsNotNull(dte);

			CompilationDatabase cdb = new CompilationDatabase();
			foreach (Project project in dte.Solution.Projects)
			{
				List<string> configurationNames = Utility.SolutionUtility.GetConfigurationNames(dte);
				Assert.IsTrue(configurationNames.Count > 0, "No target configurations found in loaded solution.");

				List<string> platformNames = Utility.SolutionUtility.GetPlatformNames(dte);
				Assert.IsTrue(platformNames.Count > 0, "No target platforms found in loaded solution.");

				SolutionParser.SolutionParser solutionParser = new SolutionParser.SolutionParser(new TestPathResolver());
				solutionParser.CreateCompileCommands(
					project, configurationNames[0], platformNames[0], "c11", null, nonSystemIncludesUseAngleBrackets,
					(CompileCommand command) =>
					{
						cdb.AddCompileCommand(command);
					}
				);
			}

			return cdb;
		}
        private void CreateCompilationCommands(Utility.QueuedFileWriter fileWriter, EnvDTE.Project project, ref int projectsProcessed, bool lastProject = false)
        {
            try
            {
                SolutionParser.SolutionParser solutionParser = new SolutionParser.SolutionParser(new VsPathResolver(_targetDir));

                solutionParser.CreateCompileCommands(
                    project, _configurationName, _platformName, _cStandard, _additionalClangOptions,
                    (CompileCommand command, bool lastFile) => {
                    string serializedCommand = "";
                    foreach (string line in command.SerializeToJson().Split('\n'))
                    {
                        serializedCommand += "  " + line + "\n";
                    }
                    serializedCommand = serializedCommand.TrimEnd('\n');

                    fileWriter.PushMessage(serializedCommand + (lastProject && lastFile ? "\n" : ",\n"));
                }
                    );

                lock (_lockObject)
                {
                    projectsProcessed++;
                }

                float relativProgress = (float)projectsProcessed / (float)_projects.Count;
                Logging.Logging.LogInfo("Processing project \"" + Logging.Obfuscation.NameObfuscator.GetObfuscatedName(project.Name) + "\"");
                backgroundWorker1.ReportProgress((int)(relativProgress * 100), "Processing project \"" + project.Name + "\"");
            }
            catch (Exception e)
            {
                Logging.Logging.LogError("Failed to create CDB for project with exception: " + e.Message);
                Logging.Logging.LogError("Stack Trace: " + e.StackTrace);
                throw;
            }
        }