aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiguel Costa <miguel.costa@qt.io>2017-12-13 12:38:35 +0100
committerMiguel Costa <miguel.costa@qt.io>2017-12-21 10:04:08 +0000
commit5d758a7b90274152d62149d7d52d832dbeb77cd0 (patch)
tree809044e44b5eddf8acbbe845149f357c62c455b4
parent8c3cb9d9e3322b22fdd0f519299a02ca771cc5e3 (diff)
Do not add generated files to project
Files generated by the Qt tools are no longer added to the project structure. Source files generated by moc and rcc are included in the build dynamically. This allows for an increase in performance of the VS Tools (e.g. when adding header files to a project, 90% of the time is spent processing generated files). NOTE: Only works for new files/projects. This patch breaks import and conversion of existing projects. Fixed in a following patch. Task-number: QTVSADDINBUG-64 Change-Id: I8762adfc08962a54da256fe5ced6e1ec4504caaf Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
-rw-r--r--src/qtmsbuild/qt.props2
-rw-r--r--src/qtmsbuild/qt.targets27
-rw-r--r--src/qtmsbuild/qtmoc.xml17
-rw-r--r--src/qtmsbuild/qtrcc.xml13
-rw-r--r--src/qtprojectlib/QtMsBuild.cs2
-rw-r--r--src/qtprojectlib/QtProject.cs82
6 files changed, 92 insertions, 51 deletions
diff --git a/src/qtmsbuild/qt.props b/src/qtmsbuild/qt.props
index 24a80970..2d791e9d 100644
--- a/src/qtmsbuild/qt.props
+++ b/src/qtmsbuild/qt.props
@@ -17,6 +17,7 @@
<QTDIR>$(QTDIR)</QTDIR>
<InputFile>%(FullPath)</InputFile>
<OutputFile>$(ProjectDir)GeneratedFiles\$(Configuration)\moc_%(Filename).cpp</OutputFile>
+ <DynamicSource>output</DynamicSource>
<ParallelProcess>true</ParallelProcess>
<CommandLineTemplate>[AllOptions] [AdditionalOptions]</CommandLineTemplate>
<Outputs>%(OutputFile)</Outputs>
@@ -41,6 +42,7 @@
<OutputFile>$(ProjectDir)GeneratedFiles\qrc_%(Filename).cpp</OutputFile>
<InitFuncName>%(Filename)</InitFuncName>
<Compression>default</Compression>
+ <DynamicSource>output</DynamicSource>
<ParallelProcess>true</ParallelProcess>
<CommandLineTemplate>[AllOptions] [AdditionalOptions]</CommandLineTemplate>
<Outputs>%(OutputFile)</Outputs>
diff --git a/src/qtmsbuild/qt.targets b/src/qtmsbuild/qt.targets
index 1b919447..30b68fbd 100644
--- a/src/qtmsbuild/qt.targets
+++ b/src/qtmsbuild/qt.targets
@@ -408,9 +408,36 @@
$(CleanDependsOn);
QtClean;
</CleanDependsOn>
+ <BuildDependsOn>
+ QtDynamicSources;
+ $(BuildDependsOn)
+ </BuildDependsOn>
</PropertyGroup>
<Target Name="QtClean">
<Delete
Files="@(QtMoc->'%(OutputFile)');@(QtRcc->'%(OutputFile)');@(QtUic->'%(OutputFile)')" />
</Target>
+ <Target Name="QtDynamicSources">
+ <ItemGroup>
+ <ClCompile
+ Condition="'%(QtMoc.ExcludedFromBuild)' != 'true' and '%(QtMoc.DynamicSource)' == 'output'"
+ Include="@(QtMoc->'%(OutputFile)')">
+ <AdditionalIncludeDirectories>$(AdditionalIncludeDirectories);%(QtMoc.IncludePath)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>$(PreprocessorDefinitions);%(QtMoc.Define)</PreprocessorDefinitions>
+ <UndefinePreprocessorDefinitions>$(UndefinePreprocessorDefinitions);%(QtMoc.Undefine)</UndefinePreprocessorDefinitions>
+ </ClCompile>
+ <ClCompile
+ Condition="'%(QtMoc.ExcludedFromBuild)' != 'true' and '%(QtMoc.DynamicSource)' == 'input'"
+ Include="@(QtMoc->'%(InputFile)')">
+ <AdditionalIncludeDirectories>$(AdditionalIncludeDirectories);%(QtMoc.IncludePath)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>$(PreprocessorDefinitions);%(QtMoc.Define)</PreprocessorDefinitions>
+ <UndefinePreprocessorDefinitions>$(UndefinePreprocessorDefinitions);%(QtMoc.Undefine)</UndefinePreprocessorDefinitions>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile
+ Condition="'%(QtRcc.ExcludedFromBuild)' != 'true' and '%(QtRcc.DynamicSource)' == 'output'"
+ Include="@(QtRcc->'%(OutputFile)')"/>
+ </ItemGroup>
+ </Target>
</Project>
diff --git a/src/qtmsbuild/qtmoc.xml b/src/qtmsbuild/qtmoc.xml
index 11cfb36c..6c100c7c 100644
--- a/src/qtmsbuild/qtmoc.xml
+++ b/src/qtmsbuild/qtmoc.xml
@@ -229,6 +229,23 @@
<sys:String>Additional Options</sys:String>
</StringProperty.Description>
</StringProperty>
+ <EnumProperty
+ Name="DynamicSource"
+ DisplayName="Dynamic C++ Source"
+ Description="Add file to list of C++ sources during build.">
+ <EnumValue
+ Name="output"
+ DisplayName="Output File"
+ Description="Use output as dynamic C++ source."/>
+ <EnumValue
+ Name="input"
+ DisplayName="Input File"
+ Description="Use input as dynamic C++ source."/>
+ <EnumValue
+ Name="false"
+ DisplayName="Disable"
+ Description="Disable dynamic source."/>
+ </EnumProperty>
<BoolProperty
Name="ParallelProcess"
DisplayName="Parallel Process"
diff --git a/src/qtmsbuild/qtrcc.xml b/src/qtmsbuild/qtrcc.xml
index 82dea845..5eca94ed 100644
--- a/src/qtmsbuild/qtrcc.xml
+++ b/src/qtmsbuild/qtrcc.xml
@@ -252,6 +252,19 @@
<sys:String>Additional Options</sys:String>
</StringProperty.Description>
</StringProperty>
+ <EnumProperty
+ Name="DynamicSource"
+ DisplayName="Dynamic C++ Source"
+ Description="Add file to list of C++ sources during build.">
+ <EnumValue
+ Name="output"
+ DisplayName="Output File"
+ Description="Use output as dynamic C++ source."/>
+ <EnumValue
+ Name="false"
+ DisplayName="Disable"
+ Description="Disable dynamic source."/>
+ </EnumProperty>
<BoolProperty
Name="ParallelProcess"
DisplayName="Parallel Process"
diff --git a/src/qtprojectlib/QtMsBuild.cs b/src/qtprojectlib/QtMsBuild.cs
index 19adb280..c82638e4 100644
--- a/src/qtprojectlib/QtMsBuild.cs
+++ b/src/qtprojectlib/QtMsBuild.cs
@@ -564,6 +564,7 @@ namespace QtProjectLib.QtMsBuild
OptionsFile,
CommandLineTemplate,
AdditionalOptions,
+ DynamicSource,
ParallelProcess,
AdditionalDependencies,
}
@@ -860,6 +861,7 @@ namespace QtProjectLib.QtMsBuild
FormatVersion,
CommandLineTemplate,
AdditionalOptions,
+ DynamicSource,
ParallelProcess,
AdditionalDependencies,
}
diff --git a/src/qtprojectlib/QtProject.cs b/src/qtprojectlib/QtProject.cs
index 2a19e3d5..1b715773 100644
--- a/src/qtprojectlib/QtProject.cs
+++ b/src/qtprojectlib/QtProject.cs
@@ -594,7 +594,7 @@ namespace QtProjectLib
compiler.AddAdditionalIncludeDirectories(uiDir);
}
}
- if (!uiFileExists)
+ if (toolSettings == CustomTool.CustomBuildStep && !uiFileExists)
AddFileInFilter(Filters.GeneratedFiles(), uiFile);
} catch {
throw new QtVSException(SR.GetString("QtProject_CannotAddUicStep", file.FullPath));
@@ -1002,7 +1002,6 @@ namespace QtProjectLib
void AddMocStepMsBuildTarget(
VCFile sourceFile,
VCFileConfiguration workConfig,
- VCFile mocFile,
string defines,
string includes,
string description)
@@ -1013,24 +1012,18 @@ namespace QtProjectLib
var stringToReplace = Path.GetFileName(outputMocFile);
var outputMocMacro = outputMocPath + "\\"
+ stringToReplace.Replace(baseFileName, ProjectMacros.Name);
- var workFile = workConfig.File as VCFile;
- workFile.ItemType = QtMoc.ItemTypeName;
- if (sourceFile.FullPath == workFile.FullPath) {
- qtMsBuild.SetItemProperty(workConfig,
- QtMoc.Property.InputFile, ProjectMacros.Path);
- } else {
- qtMsBuild.SetItemProperty(workConfig,
- QtMoc.Property.InputFile, sourceFile.ItemName);
- qtMsBuild.SetItemProperty(workConfig,
- QtMoc.Property.AdditionalDependencies, sourceFile.ItemName);
- }
- if (workFile.FullPath == mocFile.FullPath) {
+ sourceFile.ItemType = QtMoc.ItemTypeName;
+ qtMsBuild.SetItemProperty(workConfig,
+ QtMoc.Property.InputFile, ProjectMacros.Path);
+ qtMsBuild.SetItemProperty(workConfig,
+ QtMoc.Property.OutputFile, outputMocMacro);
+ if (!HelperFunctions.IsSourceFile(sourceFile.FullPath)) {
qtMsBuild.SetItemProperty(workConfig,
- QtMoc.Property.OutputFile, ProjectMacros.Path);
+ QtMoc.Property.DynamicSource, "output");
} else {
qtMsBuild.SetItemProperty(workConfig,
- QtMoc.Property.OutputFile, outputMocMacro);
+ QtMoc.Property.DynamicSource, "input");
}
qtMsBuild.SetItemProperty(workConfig,
QtMoc.Property.ExecutionDescription, description);
@@ -1062,27 +1055,28 @@ namespace QtProjectLib
subfilterName += '_';
subfilterName += platformName;
}
- var mocFile = GetFileFromProject(mocRelPath);
- if (mocFile == null) {
- var fi = new FileInfo(VCProject.ProjectDirectory + "\\" + mocRelPath);
- if (!fi.Directory.Exists)
- fi.Directory.Create();
- mocFile = AddFileInSubfilter(Filters.GeneratedFiles(), subfilterName,
- mocRelPath);
- }
- if (mocFile == null)
- throw new QtVSException(
- SR.GetString("QtProject_CannotAddMocStep", workFile.FullPath));
-
- if (toolSettings == CustomTool.MSBuildTarget || !mocableIsCPP)
- AddMocStepSetBuildExclusions(sourceFile, workConfig, mocFile);
+ VCFile mocFile = null;
+ if (toolSettings == CustomTool.CustomBuildStep) {
+ mocFile = GetFileFromProject(mocRelPath);
+ if (mocFile == null) {
+ var fi = new FileInfo(VCProject.ProjectDirectory + "\\" + mocRelPath);
+ if (!fi.Directory.Exists)
+ fi.Directory.Create();
+ mocFile = AddFileInSubfilter(Filters.GeneratedFiles(), subfilterName,
+ mocRelPath);
+ }
+ if (mocFile != null)
+ AddMocStepSetBuildExclusions(sourceFile, workConfig, mocFile);
+ }
- VCFile cppPropertyFile;
+ VCFile cppPropertyFile = null;
if (!mocableIsCPP)
cppPropertyFile = GetCppFileForMocStep(sourceFile);
- else
+ else if (mocFile != null)
cppPropertyFile = GetCppFileForMocStep(mocFile);
+ else
+ cppPropertyFile = workFile;
VCFileConfiguration defineIncludeConfig;
if (cppPropertyFile != null) {
defineIncludeConfig = GetVCFileConfigurationByName(
@@ -1096,21 +1090,11 @@ namespace QtProjectLib
var defines = GetDefines(defineIncludeConfig);
var includes = GetIncludes(defineIncludeConfig);
var description = "Moc'ing %(Identity)...";
- if (mocableIsCPP) {
- description = string.Format(
- "Moc'ing {0}...",
- Path.GetFileName(sourceFile.FullPath));
- if (toolSettings == CustomTool.MSBuildTarget) {
- mocFile.ItemType = QtMoc.ItemTypeName;
- workConfig = GetVCFileConfigurationByName(mocFile, workConfig.Name);
- }
- }
if (toolSettings == CustomTool.MSBuildTarget) {
AddMocStepMsBuildTarget(
sourceFile,
workConfig,
- mocFile,
defines,
includes,
description);
@@ -1400,7 +1384,8 @@ namespace QtProjectLib
break;
}
}
- AddFileInFilter(Filters.GeneratedFiles(), qrcCppFile, true);
+ if (toolSettings == CustomTool.CustomBuildStep)
+ AddFileInFilter(Filters.GeneratedFiles(), qrcCppFile, true);
} catch (Exception /*e*/) {
Messages.PaneMessage(dteObject, "*** WARNING (RCC): Couldn't add rcc step");
}
@@ -1562,16 +1547,11 @@ namespace QtProjectLib
public void RemoveMocStepQtMsBuild(VCFile file)
{
if (HelperFunctions.IsHeaderFile(file.Name)) {
- foreach (VCFileConfiguration config in (IVCCollection)file.FileConfigurations) {
- var outputFile = qtMsBuild.GetPropertyValue(config, QtMoc.Property.OutputFile);
- HelperFunctions.ExpandString(ref outputFile, config);
- var mocFile = GetFileFromProject(outputFile);
- if (mocFile != null)
- RemoveFileFromFilter(mocFile, Filters.GeneratedFiles());
- }
file.ItemType = "ClInclude";
+ } else if (HelperFunctions.IsSourceFile(file.Name)) {
+ file.ItemType = "ClCompile";
} else {
- RemoveFileFromFilter(file, Filters.GeneratedFiles());
+ file.ItemType = "None";
}
}