diff options
-rw-r--r-- | src/qtmsbuild/qt.props | 17 | ||||
-rw-r--r-- | src/qtmsbuild/qt_settings.xml | 10 | ||||
-rw-r--r-- | src/qtprojectlib/MsBuildProject.cs | 102 |
3 files changed, 114 insertions, 15 deletions
diff --git a/src/qtmsbuild/qt.props b/src/qtmsbuild/qt.props index 90ef73ee..960207a8 100644 --- a/src/qtmsbuild/qt.props +++ b/src/qtmsbuild/qt.props @@ -147,6 +147,23 @@ <!-- ///////////////////////////////////////////////////////////////////////////////////////////////// + // QML debugging + // --> + <PropertyGroup> + <QmlDebug Condition="'$(QtQMLDebugEnable)' == 'true'" + >-qmljsdebugger=file:$(ProjectGuid),block</QmlDebug> + <LocalDebuggerCommandArguments + >$(QmlDebug)</LocalDebuggerCommandArguments> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(QtVsProjectSettings)' == 'true'"> + <ClCompile Condition="'$(QtQMLDebugEnable)' == 'true'"> + <PreprocessorDefinitions + >QT_QML_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + </ItemDefinitionGroup> + + <!-- + ///////////////////////////////////////////////////////////////////////////////////////////////// // Read subfolder dependencies (qt_import.props) // --> <PropertyGroup> diff --git a/src/qtmsbuild/qt_settings.xml b/src/qtmsbuild/qt_settings.xml index b7925097..ba27fa64 100644 --- a/src/qtmsbuild/qt_settings.xml +++ b/src/qtmsbuild/qt_settings.xml @@ -41,6 +41,7 @@ <Rule.Categories> <Category Name="QtSettings_General" DisplayName="General"/> <Category Name="QtSettings_LUpdateLRelease" DisplayName="lupdate/lrelease"/> + <Category Name="QtSettings_QML" DisplayName="QML"/> <Category Name="QtSettings_QMake" DisplayName="qmake"/> </Rule.Categories> <EnumProperty @@ -97,4 +98,13 @@ Name="QMakeCodeLines" Category="QtSettings_QMake" DisplayName="Additional Project Settings" /> + <BoolProperty + Name="QtQMLDebugEnable" + Category="QtSettings_QML" + DisplayName="Enable QML Debugging" + Description="Select whether to launch a QML session when debugging."> + <BoolProperty.DataSource> + <DataSource Persistence="ProjectFile" Label="Configuration" HasConfigurationCondition="true"/> + </BoolProperty.DataSource> + </BoolProperty> </Rule> diff --git a/src/qtprojectlib/MsBuildProject.cs b/src/qtprojectlib/MsBuildProject.cs index 74c64b05..92b18cb6 100644 --- a/src/qtprojectlib/MsBuildProject.cs +++ b/src/qtprojectlib/MsBuildProject.cs @@ -301,8 +301,6 @@ namespace QtProjectLib .Elements(ns + "VisualStudio") .Elements(ns + "UserProperties") .FirstOrDefault(); - if (userProps == null) - return false; // Copy Qt build reference to QtInstall project property this[Files.Project].xml @@ -312,20 +310,23 @@ namespace QtProjectLib .ToList() .ForEach(config => { - string platform = null; - try { - platform = ConfigCondition - .Parse((string)config.Attribute("Condition")) - .GetValues<string>("Platform") - .FirstOrDefault(); - } catch { } - - if (!string.IsNullOrEmpty(platform)) { - var qtInstallName = string.Format("Qt5Version_x0020_{0}", platform); - var qtInstallValue = (string)userProps.Attribute(qtInstallName); - if (!string.IsNullOrEmpty(qtInstallValue)) - config.Add(new XElement(ns + "QtInstall", qtInstallValue)); + string qtInstallValue = defaultVersionName; + if (userProps != null) { + string platform = null; + try { + platform = ConfigCondition + .Parse((string)config.Attribute("Condition")) + .GetValues<string>("Platform") + .FirstOrDefault(); + } catch { } + + if (!string.IsNullOrEmpty(platform)) { + var qtInstallName = string.Format("Qt5Version_x0020_{0}", platform); + qtInstallValue = (string)userProps.Attribute(qtInstallName); + } } + if (!string.IsNullOrEmpty(qtInstallValue)) + config.Add(new XElement(ns + "QtInstall", qtInstallValue)); }); // Get C++ compiler properties @@ -487,6 +488,77 @@ namespace QtProjectLib .ToList() .ForEach(x => x.Add(new XElement(ns + "QtModules", string.Join(";", moduleNames)))); + // Remove project user properties (old format) + if (userProps != null) { + userProps.Attributes().ToList().ForEach(userProp => + { + if (userProp.Name.LocalName == "lupdateOptions" + || userProp.Name.LocalName == "lupdateOnBuild" + || userProp.Name.LocalName == "lreleaseOptions" + || userProp.Name.LocalName == "MocDir" + || userProp.Name.LocalName == "MocOptions" + || userProp.Name.LocalName == "RccDir" + || userProp.Name.LocalName == "UicDir" + || userProp.Name.LocalName.StartsWith("Qt5Version_x0020_")) + { + userProp.Remove(); + } + }); + } + + // Remove old properties from .user file + if (this[Files.User].xml != null) { + this[Files.User].xml + .Elements(ns + "Project") + .Elements(ns + "PropertyGroup") + .Elements() + .ToList() + .ForEach(userProp => + { + if (userProp.Name.LocalName == "QTDIR" + || userProp.Name.LocalName == "QmlDebug" + || userProp.Name.LocalName == "QmlDebugSettings" + || (userProp.Name.LocalName == "LocalDebuggerCommandArguments" + && (string)userProp == "$(QmlDebug)" + ) + || (userProp.Name.LocalName == "LocalDebuggerEnvironment" + && (string)userProp == "PATH=$(QTDIR)\\bin%3b$(PATH)" + ) + ) { + userProp.Remove(); + } + }); + this[Files.User].isDirty = true; + } + + // Remove old properties from project items + var oldQtProps = new[] { "QTDIR", "InputFile", "OutputFile", "ExecutionDescription" }; + var oldCppProps = new[] { "IncludePath", "Define", "Undefine" }; + var oldPropsAny = oldQtProps.Union(oldCppProps); + this[Files.Project].xml + .Elements(ns + "Project") + .Elements(ns + "ItemDefinitionGroup") + .Union(this[Files.Project].xml + .Elements(ns + "Project") + .Elements(ns + "ItemGroup")) + .Elements().ToList().ForEach(item => + { + var itemName = item.Name.LocalName; + item.Elements().ToList().ForEach(itemProp => + { + var propName = itemProp.Name.LocalName; + if ((itemName == "QtMoc" && oldPropsAny.Contains(propName)) + || (itemName == "QtRcc" && oldQtProps.Contains(propName)) + || (itemName == "QtUic" && oldQtProps.Contains(propName)) + || (itemName == "QtRepc" && oldPropsAny.Contains(propName)) + ) { + itemProp.Remove(); + } + }); + }); + + this[Files.Project].isDirty = true; + Commit(); return true; } |