Ejemplo n.º 1
0
        bool GetProjectInfo(string execPath, bool native, out string execCmd, out IEnumerable <string> rccItems)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            execCmd  = "";
            rccItems = null;

            foreach (var project in HelperFunctions.ProjectsInSolution(QtVsToolsPackage.Instance.Dte))
            {
                var vcProject = project.Object as VCProject;
                if (vcProject == null)
                {
                    continue;
                }

                var vcConfigs = vcProject.Configurations as IVCCollection;
                if (vcConfigs == null)
                {
                    continue;
                }
                var activeConfig = project.ConfigurationManager.ActiveConfiguration;
                if (activeConfig == null)
                {
                    continue;
                }
                var activeConfigId = string.Format("{0}|{1}",
                                                   activeConfig.ConfigurationName, activeConfig.PlatformName);
                var vcConfig = vcConfigs.Item(activeConfigId) as VCConfiguration;
                if (vcConfig == null)
                {
                    continue;
                }

                var props = vcProject as IVCBuildPropertyStorage;

                var localDebugCommand = props.GetPropertyValue("LocalDebuggerCommand",
                                                               vcConfig.Name, "UserFile");

                var remoteDebugCommand = props.GetPropertyValue("RemoteDebuggerCommand",
                                                                vcConfig.Name, "UserFile");

                string debugCommand = (native || string.IsNullOrEmpty(remoteDebugCommand))
                    ? localDebugCommand : remoteDebugCommand;

                bool sameFile = string.Equals(execPath, Path.GetFullPath(debugCommand),
                                              StringComparison.InvariantCultureIgnoreCase);

                if (!sameFile)
                {
                    continue;
                }

                OutputWriteLine(string.Format("Debugging project '{0}'...", vcProject.Name));

                var qtProject = QtProject.Create(vcProject);
                if (qtProject == null)
                {
                    OutputWriteLine("DISABLED: Non-Qt project");
                    return(false);
                }

                if (!qtProject.IsQtMsBuildEnabled())
                {
                    OutputWriteLine("DISABLED: Non-Qt/MSBuild project");
                    return(false);
                }

                if (!qtProject.QmlDebug)
                {
                    OutputWriteLine("DISABLED: QML debugging disabled in Qt project settings");
                    return(false);
                }

                var execArgs = props.GetPropertyValue(
                    native ? "LocalDebuggerCommandArguments" : "RemoteDebuggerCommandArguments",
                    vcConfig.Name, "UserFile");
                if (string.IsNullOrEmpty(execArgs))
                {
                    OutputWriteLine("DISABLED: Error reading command line arguments");
                    return(false);
                }

                var cmd = "\"" + execPath + "\" " + execArgs;

                if (!QmlDebugger.CheckCommandLine(execPath, cmd))
                {
                    OutputWriteLine("DISABLED: Error parsing command line arguments");
                    return(false);
                }

                OutputWriteLine("Starting QML debug session...");

                execCmd  = cmd;
                rccItems = ((IVCCollection)vcProject.Files).Cast <VCFile>()
                           .Where(x => x.ItemType == QtRcc.ItemTypeName)
                           .Select(x => x.FullPath);

                return(true);
            }

            OutputWriteLine("DISABLED: Could not identify project being debugged");

            return(false);
        }
Ejemplo n.º 2
0
        public static QmlDebugger Create(IDebuggerEventSink sink, string execPath, string args)
        {
            var _this = new QmlDebugger();

            return(_this.Initialize(sink, execPath, args) ? _this : null);
        }