Ejemplo n.º 1
0
        public static async Task RefreshAsync(
            EnvDTE.Project project,
            string projectPath,
            string configId = null,
            IEnumerable <string> selectedFiles = null)
        {
            if (project == null || !QtProjectTracker.IsTracked(projectPath))
            {
                return;
            }
            var tracker = QtProjectTracker.Get(project, projectPath);
            await tracker.Initialized;

            var properties = new Dictionary <string, string>();

            properties["QtVSToolsBuild"] = "true";
            if (selectedFiles != null)
            {
                properties["SelectedFiles"] = string.Join(";", selectedFiles);
            }
            var targets = new List <string> {
                "QtVars"
            };

            if (QtVsToolsPackage.Instance.Options.BuildRunQtTools)
            {
                targets.Add("Qt");
            }

            IEnumerable <string> configs;

            if (configId != null)
            {
                configs = new[] { configId };
            }
            else
            {
                var knownConfigs = await tracker.UnconfiguredProject.Services
                                   .ProjectConfigurationsService.GetKnownProjectConfigurationsAsync();

                configs = knownConfigs.Select(x => x.Name);
            }

            foreach (var config in configs)
            {
                await QtProjectBuild.StartBuildAsync(
                    project, projectPath, config, properties, targets,
                    LoggerVerbosity.Quiet);
            }
        }
Ejemplo n.º 2
0
        public static void AddProject(EnvDTE.Project project)
        {
            lock (criticalSection) {
                if (Instances == null)
                {
                    Instances = new ConcurrentDictionary <string, QtProjectTracker>();
                }
            }
            QtProjectTracker instance = null;

            if (!Instances.TryGetValue(project.FullName, out instance) || instance == null)
            {
                Instances[project.FullName] = new QtProjectTracker(project);
            }
        }
Ejemplo n.º 3
0
        public static void RefreshIntelliSense(EnvDTE.Project project, string configId = null)
        {
            lock (criticalSection) {
                if (Instances == null)
                {
                    return;
                }
            }
            QtProjectTracker instance = null;

            if (!Instances.TryGetValue(project.FullName, out instance) || instance == null)
            {
                return;
            }
            Task.Run(async() => await instance.RefreshIntelliSenseAsync(configId));
        }
Ejemplo n.º 4
0
 public Subscriber(QtProjectTracker tracker, ConfiguredProject config)
 {
     Tracker      = tracker;
     Config       = config;
     Subscription = Config.Services.ProjectSubscription.JointRuleSource.SourceBlock
                    .LinkTo(new SubscriberAction(ProjectUpdateAsync),
                            ruleNames: new[]
     {
         "ClCompile",
         "QtRule10_Settings",
         "QtRule30_Moc",
         "QtRule40_Rcc",
         "QtRule60_Repc",
         "QtRule50_Uic",
         "QtRule_Translation",
         "QtRule70_Deploy",
     },
                            initialDataAsNew: false
                            );
 }
Ejemplo n.º 5
0
        public static void Refresh(
            EnvDTE.Project project,
            string configId = null,
            IEnumerable <string> selectedFiles = null)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (project == null || !QtProjectTracker.IsTracked(project.FullName))
            {
                return;
            }

            if (QtVsToolsPackage.Instance.Options.BuildDebugInformation)
            {
                Messages.Print(string.Format(
                                   "{0:HH:mm:ss.FFF} QtProjectIntellisense({1}): Refreshing: [{2}] {3}",
                                   DateTime.Now, Thread.CurrentThread.ManagedThreadId,
                                   (configId != null) ? configId : "(all configs)", project.FullName));
            }
            string projectPath = project.FullName;

            _ = Task.Run(() => RefreshAsync(project, projectPath, configId, selectedFiles));
        }
Ejemplo n.º 6
0
        public static async Task StartBuildAsync(
            EnvDTE.Project project,
            string projectPath,
            string configName,
            Dictionary <string, string> properties,
            IEnumerable <string> targets,
            LoggerVerbosity verbosity)
        {
            if (project == null)
            {
                throw new ArgumentException("Project cannot be null.");
            }
            if (configName == null)
            {
                throw new ArgumentException("Configuration name cannot be null.");
            }

            RequestTimer.Restart();
            var tracker = QtProjectTracker.Get(project, projectPath);
            await tracker.Initialized;

            if (QtVsToolsPackage.Instance.Options.BuildDebugInformation)
            {
                Messages.Print(string.Format(
                                   "{0:HH:mm:ss.FFF} QtProjectBuild({1}): Request [{2}] {3}",
                                   DateTime.Now, Thread.CurrentThread.ManagedThreadId,
                                   configName, tracker.UnconfiguredProject.FullPath));
            }

            var knownConfigs = await tracker.UnconfiguredProject.Services
                               .ProjectConfigurationsService.GetKnownProjectConfigurationsAsync();

            ConfiguredProject configuredProject = null;

            foreach (var config in knownConfigs)
            {
                var configProject = await tracker.UnconfiguredProject
                                    .LoadConfiguredProjectAsync(config);

                if (configProject.ProjectConfiguration.Name == configName)
                {
                    configuredProject = configProject;
                    break;
                }
            }
            if (configuredProject == null)
            {
                throw new ArgumentException(string.Format("Unknown configuration '{0}'.", configName));
            }

            BuildQueue.Enqueue(new QtProjectBuild()
            {
                Project             = project,
                VcProject           = tracker.VcProject,
                UnconfiguredProject = tracker.UnconfiguredProject,
                ConfiguredProject   = configuredProject,
                Properties          = properties?.ToDictionary(x => x.Key, x => x.Value),
                Targets             = targets?.ToList(),
                LoggerVerbosity     = verbosity
            });
            StaticThreadSafeInit(() => BuildDispatcher,
                                 () => BuildDispatcher = Task.Run(BuildDispatcherLoopAsync))
            .Forget();
        }