diff options
author | Miguel Costa <miguel.costa@qt.io> | 2018-11-16 16:23:38 +0100 |
---|---|---|
committer | Miguel Costa <miguel.costa@qt.io> | 2018-11-19 10:05:58 +0000 |
commit | 5ce36f941e73ddf49cfffef3c9a4e783e5f47082 (patch) | |
tree | 7807dd0bb3515a636b0d021487d2d0ae64dd8222 | |
parent | ddbb38b4c24e62be0d500e10820bac64bd73e84a (diff) |
Fix manual compilation not working
Reworked the support for manual compilation (i.e. 'Compile' option in
the project file context menu). This had several issues, including never
calling rcc in a manual compilation if no moc headers were present; this
was due to the way the Qt/MSBuild targets' dependency chain was set up.
Also, selecting multiple files for manual compilation was not working.
Task-number: QTVSADDINBUG-584
Change-Id: I627914201e7768beaf3a0aa2acf297ebeb032277
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
-rw-r--r-- | src/qtmsbuild/qt.props | 39 | ||||
-rw-r--r-- | src/qtmsbuild/qt_globals.targets | 86 | ||||
-rw-r--r-- | src/qtmsbuild/qtmoc.targets | 37 | ||||
-rw-r--r-- | src/qtmsbuild/qtrcc.targets | 49 | ||||
-rw-r--r-- | src/qtmsbuild/qtuic.targets | 37 |
5 files changed, 133 insertions, 115 deletions
diff --git a/src/qtmsbuild/qt.props b/src/qtmsbuild/qt.props index 4921cf6c..86988ecf 100644 --- a/src/qtmsbuild/qt.props +++ b/src/qtmsbuild/qt.props @@ -39,19 +39,6 @@ ///////////////////////////////////////////////////////////////////////////////////////////////// // QtMoc // --> - <PropertyGroup - Condition="'$(QtMocBeforeTargets)' == '' - AND '$(QtMocAfterTargets)' == '' - AND '$(ConfigurationType)' != 'Makefile'"> - <QtMocBeforeTargets>ClCompile</QtMocBeforeTargets> - <QtMocAfterTargets>CustomBuild</QtMocAfterTargets> - </PropertyGroup> - <PropertyGroup> - <QtMocDependsOn - Condition="'$(ConfigurationType)' != 'Makefile'"> - _SelectedFiles;$(QtMocDependsOn) - </QtMocDependsOn> - </PropertyGroup> <ItemDefinitionGroup> <QtMoc> <ExecutionDescription>Moc%27ing %(Identity)...</ExecutionDescription> @@ -69,19 +56,6 @@ ///////////////////////////////////////////////////////////////////////////////////////////////// // QtRcc // --> - <PropertyGroup - Condition="'$(QtRccBeforeTargets)' == '' - AND '$(QtRccAfterTargets)' == '' - AND '$(ConfigurationType)' != 'Makefile'"> - <QtRccBeforeTargets>ClCompile</QtRccBeforeTargets> - <QtRccAfterTargets>CustomBuild</QtRccAfterTargets> - </PropertyGroup> - <PropertyGroup> - <QtRccDependsOn - Condition="'$(ConfigurationType)' != 'Makefile'"> - _SelectedFiles;$(QtRccDependsOn) - </QtRccDependsOn> - </PropertyGroup> <ItemDefinitionGroup> <QtRcc> <ExecutionDescription>Rcc%27ing %(Identity)...</ExecutionDescription> @@ -101,19 +75,6 @@ ///////////////////////////////////////////////////////////////////////////////////////////////// // QtUic // --> - <PropertyGroup - Condition="'$(QtUicBeforeTargets)' == '' - AND '$(QtUicAfterTargets)' == '' - AND '$(ConfigurationType)' != 'Makefile'"> - <QtUicBeforeTargets>ClCompile</QtUicBeforeTargets> - <QtUicAfterTargets>CustomBuild</QtUicAfterTargets> - </PropertyGroup> - <PropertyGroup> - <QtUicDependsOn - Condition="'$(ConfigurationType)' != 'Makefile'"> - _SelectedFiles;$(QtUicDependsOn) - </QtUicDependsOn> - </PropertyGroup> <ItemDefinitionGroup> <QtUic> <ExecutionDescription>Uic%27ing %(Identity)...</ExecutionDescription> diff --git a/src/qtmsbuild/qt_globals.targets b/src/qtmsbuild/qt_globals.targets index d84d6b72..ae05ab28 100644 --- a/src/qtmsbuild/qt_globals.targets +++ b/src/qtmsbuild/qt_globals.targets @@ -86,7 +86,7 @@ ///////////////////////////////////////////////////////////////////////////////////////////////// // Prepare Qt build: read and parse work log file // --> - <Target Name="QtPrepare" DependsOnTargets="CustomBuild"> + <Target Name="QtPrepare" AfterTargets="CustomBuild"> <Message Importance="High" Condition="'$(QtDebug)' == 'true'" Text="#### QtPrepare"/> @@ -109,16 +109,18 @@ // previous call is still valid. // --> <Target Name="QtWorkPrepare" DependsOnTargets="$(QtBuildTargets)" - Inputs="%(QtWork.Identity)" Outputs="@(QtWork->'####### Don't skip this target #######')"> + Inputs="%(QtWork.WorkType)(%(QtWork.Identity))" + Outputs="@(QtWork->'####### Don't skip this target #######')"> - <Message Importance="High" Condition="'$(QtDebug)' == 'true'" - Text="## QtWorkPrepare @(QtWork)" /> + <Message Importance="High" Condition="'$(QtDebug)' == 'true' AND '@(QtWork)' != ''" + Text="## QtWorkPrepare %(QtWork.Identity)" /> <!-- /////////////////////////////////////////////////////////////////////////////////////////////// // Calculate hash (SHA1) for the requested work item, based on its associated tool and options // --> - <GetItemHash Item="@(QtWork)" Keys="Identity;WorkType;ToolPath;Options"> + <GetItemHash Condition="'@(QtWork)' != ''" + Item="%(QtWork.Identity)" Keys="Identity;WorkType;ToolPath;Options"> <Output TaskParameter="Hash" PropertyName="work_hash" /> </GetItemHash> @@ -126,18 +128,18 @@ /////////////////////////////////////////////////////////////////////////////////////////////// // Try to find entry in Qt work log for the requested work item; get logged hash // --> - <PropertyGroup> - <log_key>@(QtWork->'%(WorkType)(%(Identity))')</log_key> + <PropertyGroup Condition="'@(QtWork)' != ''"> + <work_key>@(QtWork->'%(WorkType)(%(Identity))')</work_key> <dependencies_changed>@(QtWork->'%(DependenciesChanged)')</dependencies_changed> <input_changed>@(QtWork->'%(InputChanged)')</input_changed> </PropertyGroup> - <FindInList Condition="'$(input_changed)' != 'true'" - CaseSensitive="false" List="@(QtWorkLog)" ItemSpecToFind="$(log_key)"> + <FindInList Condition="'@(QtWork)' != '' AND '$(input_changed)' != 'true'" + CaseSensitive="false" List="@(QtWorkLog)" ItemSpecToFind="$(work_key)"> <Output TaskParameter="ItemFound" ItemName="log_entry"/> </FindInList> - <PropertyGroup> + <PropertyGroup Condition="'@(QtWork)' != ''"> <log_hash Condition="'@(log_entry)' != ''">@(log_entry->'%(Hash)')</log_hash> </PropertyGroup> @@ -145,34 +147,35 @@ /////////////////////////////////////////////////////////////////////////////////////////////// // If the hash of the requested work matches the logged hash, skip work item // --> - <ItemGroup - Condition="'$(dependencies_changed)' != 'true' - OR ('$(input_changed)' != 'true' - AND '$(log_hash)' == '$(work_hash)')"> + <ItemGroup Condition="'@(QtWork)' != '' + AND ('$(dependencies_changed)' != 'true' + OR ('$(input_changed)' != 'true' + AND '$(log_hash)' == '$(work_hash)'))"> <QtWorkResult Include="@(QtWork)"> <ExitCode>0</ExitCode> + <Skipped>true</Skipped> </QtWorkResult> - <QtWork Remove="@(QtWork)"/> + <QtWork Remove="@(QtWork)" /> </ItemGroup> <!-- /////////////////////////////////////////////////////////////////////////////////////////////// // If the hashes do not match, generate new work log entry and ensure path to output exists // --> - <ItemGroup - Condition="'$(dependencies_changed)' == 'true' - AND ('$(input_changed)' == 'true' - OR '$(log_hash)' != '$(work_hash)')"> - <QtWorkLog Remove="$(log_key)"/> - <QtWorkLog Include="$(log_key)"> + <ItemGroup Condition="'@(QtWork)' != '' + AND '$(dependencies_changed)' == 'true' + AND ('$(input_changed)' == 'true' + OR '$(log_hash)' != '$(work_hash)')"> + <QtWorkLog Remove="$(work_key)"/> + <QtWorkLog Include="$(work_key)"> <Hash>$(work_hash)</Hash> </QtWorkLog> </ItemGroup> - <MakeDir - Condition="'$(dependencies_changed)' == 'true' - AND ('$(input_changed)' == 'true' - OR '$(log_hash)' != '$(work_hash)')" + <MakeDir Condition="'@(QtWork)' != '' + AND '$(dependencies_changed)' == 'true' + AND ('$(input_changed)' == 'true' + OR '$(log_hash)' != '$(work_hash)')" Directories="$([System.IO.Path]::GetDirectoryName(%(QtWork.OutputFile)))"/> <!-- @@ -180,7 +183,7 @@ // Clean-up // --> <PropertyGroup> - <log_key/> + <work_key/> <log_hash/> <dependencies_changed/> <input_changed/> @@ -192,11 +195,11 @@ <!-- ///////////////////////////////////////////////////////////////////////////////////////////////// - /// TARGET Qt + /// TARGET QtWork ///////////////////////////////////////////////////////////////////////////////////////////////// // Run Qt tools and add dynamic C++ sources to build // --> - <Target Name="Qt" + <Target Name="QtWork" DependsOnTargets="QtVersion;QtPrepare;$(QtBuildTargets);QtWorkPrepare" BeforeTargets="ClCompile"> @@ -228,7 +231,7 @@ <ItemGroup> <read_log Include="^%(QtWorkResult.FullPath); %(QtWorkResult.AdditionalDependencies)" - Condition="'%(QtWorkResult.ExitCode)' == '0'"> + Condition="'%(QtWorkResult.ExitCode)' == '0' AND '%(QtWorkResult.DisableLog)' != 'true'"> <WorkType>%(QtWorkResult.WorkType)</WorkType> </read_log> </ItemGroup> @@ -247,7 +250,7 @@ <ItemGroup> <write_log Include="^%(QtWorkResult.FullPath); $([MSBuild]::NormalizePath('$(MSBuildProjectDirectory)', '%(QtWorkResult.OutputFile)'))" - Condition="'%(QtWorkResult.ExitCode)' == '0'"> + Condition="'%(QtWorkResult.ExitCode)' == '0' AND '%(QtWorkResult.DisableLog)' != 'true'"> <WorkType>%(QtWorkResult.WorkType)</WorkType> </write_log> </ItemGroup> @@ -271,7 +274,7 @@ <WriteLinesToFile Condition="'@(clean_log)' != ''" File="$(TLogLocation)$(ProjectName).write.1u.tlog" Lines="^%(clean_log.Source);@(clean_log->'%(Fullpath)')" - Overwrite="true" Encoding="Unicode"/> + Encoding="Unicode"/> <!-- /////////////////////////////////////////////////////////////////////////////////////////////// @@ -299,6 +302,18 @@ Condition="'%(QtWorkResult.ExitCode)' == '0' AND '%(QtWorkResult.ClCompile)' != ''"/> </ItemGroup> + <!--// If sources were manually selected (e.g. by the 'Compile' option in the context menu for + // project items), add generated C++ sources to the list of selected files --> + <PropertyGroup Condition="'$(SelectedFiles)' != ''"> + <SelectedClCompile>@(QtWorkResult->'%(ClCompile)')</SelectedClCompile> + </PropertyGroup> + <PropertyGroup Condition="'$(SelectedClCompile)' != ''"> + <SelectedFiles>$(SelectedFiles);$(SelectedClCompile)</SelectedFiles> + </PropertyGroup> + <ItemGroup Condition="'$(SelectedClCompile)' != ''"> + <SelectedFiles Include="$(SelectedClCompile)"/> + </ItemGroup> + <!-- /////////////////////////////////////////////////////////////////////////////////////////////// // Clean-up @@ -312,4 +327,13 @@ <clean_log Remove="@(clean_log)"/> </ItemGroup> </Target> + + <!-- + ///////////////////////////////////////////////////////////////////////////////////////////////// + /// TARGET Qt + ///////////////////////////////////////////////////////////////////////////////////////////////// + // Root Qt target + // --> + <Target Name="Qt" DependsOnTargets="QtWork;ClCompile"/> + </Project> diff --git a/src/qtmsbuild/qtmoc.targets b/src/qtmsbuild/qtmoc.targets index ba4ca454..d7f4ffaa 100644 --- a/src/qtmsbuild/qtmoc.targets +++ b/src/qtmsbuild/qtmoc.targets @@ -52,7 +52,7 @@ <PropertyPageSchema Include="$(MSBuildThisFileDirectory)$(MSBuildThisFileName).xml" /> <AvailableItemName Include="QtMoc"> - <Targets>QtMoc</Targets> + <Targets>Qt</Targets> </AvailableItemName> </ItemGroup> @@ -62,29 +62,42 @@ ///////////////////////////////////////////////////////////////////////////////////////////////// // Prepare to process sources // --> - <Target Name="QtMocPrepare"> + <Target Name="QtMocPrepare" DependsOnTargets="_SelectedFiles" + Inputs="%(QtMoc.Identity)" Outputs="@(QtMoc->'####### Don't skip this target #######')"> <Message Importance="High" Condition="'$(QtDebug)' == 'true'" Text="## QtMocPrepare @(QtMoc)"/> + <PropertyGroup> + <selected_files>[@(SelectedFiles->'%(Identity)','][')]</selected_files> + <file>[@(QtMoc->'%(Identity)')]</file> + <output_file>@(QtMoc->'%(OutputFile)')</output_file> + <is_selected Condition="$(selected_files.Contains('$(file)'))">true</is_selected> + </PropertyGroup> + <!--// Delete output file to force build of source if it was manually selected to build // (e.g. by the 'Compile' option in the context menu for the file) --> - <Delete Files="%(QtMoc.OutputFile)" - Condition="'$(SelectedFiles)' == '%(QtMoc.Identity)'" /> + <Delete Files="$(output_file)" + Condition="'$(SelectedFiles)' != '' AND '$(is_selected)' == 'true'" /> <!--// If a source was manually selected to build, remove all other sources --> - <ItemGroup> - <QtMoc Remove="@(QtMoc)" Condition="'@(QtMoc)' != '' - AND '$(SelectedFiles)' != '' - AND '%(QtMoc.Identity)' != '$(SelectedFiles)'" /> + <ItemGroup Condition="'@(SelectedFiles)' != ''"> + <QtMoc Remove="@(QtMoc)" + Condition="'$(SelectedFiles)' != '' AND '$(is_selected)' != 'true'" /> </ItemGroup> <!--// Remove sources excluded from build --> <ItemGroup> - <QtMoc Remove="@(QtMoc)" Condition="'@(QtMoc)' != '' - AND '$(SelectedFiles)' == '' - AND '%(QtMoc.ExcludedFromBuild)' == 'true'"/> + <QtMoc Remove="@(QtMoc)" + Condition="'$(SelectedFiles)' == '' AND '%(QtMoc.ExcludedFromBuild)' == 'true'"/> </ItemGroup> + + <PropertyGroup> + <selected_files/> + <file/> + <output_file/> + <is_selected/> + </PropertyGroup> </Target> <!-- @@ -286,14 +299,12 @@ <!--// Run work in parallel processes --> <run_parallel Condition="'@(QtMoc)' != '' - AND '%(QtMoc.ExcludedFromBuild)' != 'true' AND '%(QtMoc.ParallelProcess)' == 'true' AND '$(SelectedFiles)' == ''" >true</run_parallel> <!--// Run work in single process --> <run_single Condition="'@(QtMoc)' != '' - AND '%(QtMoc.ExcludedFromBuild)' != 'true' AND ('%(QtMoc.ParallelProcess)' != 'true' OR '$(SelectedFiles)' != '')" >true</run_single> diff --git a/src/qtmsbuild/qtrcc.targets b/src/qtmsbuild/qtrcc.targets index b6b84025..9e1a8a2a 100644 --- a/src/qtmsbuild/qtrcc.targets +++ b/src/qtmsbuild/qtrcc.targets @@ -52,7 +52,7 @@ <PropertyPageSchema Include="$(MSBuildThisFileDirectory)$(MSBuildThisFileName).xml" /> <AvailableItemName Include="QtRcc"> - <Targets>QtRcc</Targets> + <Targets>Qt</Targets> </AvailableItemName> </ItemGroup> @@ -62,29 +62,43 @@ ///////////////////////////////////////////////////////////////////////////////////////////////// // Prepare items for processing // --> - <Target Name="QtRccPrepare"> + <Target Name="QtRccPrepare" DependsOnTargets="_SelectedFiles" + Inputs="%(QtRcc.Identity)" Outputs="@(QtRcc->'####### Don't skip this target #######')"> <Message Importance="High" Condition="'$(QtDebug)' == 'true'" - Text="## QtRccPrepare @(QtRcc)"/> + Text="## QtRccPrepare @(QtRcc)"/> + + <PropertyGroup> + <selected_files>[@(SelectedFiles->'%(Identity)','][')]</selected_files> + <file>[@(QtRcc->'%(Identity)')]</file> + <output_file>@(QtRcc->'%(OutputFile)')</output_file> + <is_selected Condition="$(selected_files.Contains('$(file)'))">true</is_selected> + </PropertyGroup> <!--// Delete output file to force build of source if it was manually selected to build // (e.g. by the 'Compile' option in the context menu for the file) --> - <Delete Files="%(QtRcc.OutputFile)" - Condition="'$(SelectedFiles)' == '%(QtRcc.Identity)'" /> + <Delete Files="$(output_file)" + Condition="'$(SelectedFiles)' != '' AND '$(is_selected)' == 'true'" /> <!--// If a source was manually selected to build, remove all other sources --> - <ItemGroup> - <QtRcc Remove="@(QtRcc)" Condition="'@(QtRcc)' != '' - AND '$(SelectedFiles)' != '' - AND '%(QtRcc.Identity)' != '$(SelectedFiles)'" /> + <ItemGroup Condition="'@(SelectedFiles)' != ''"> + <QtRcc Remove="@(QtRcc)" + Condition="'$(SelectedFiles)' != '' AND '$(is_selected)' != 'true'" /> </ItemGroup> <!--// Remove sources excluded from build --> <ItemGroup> - <QtRcc Remove="@(QtRcc)" Condition="'@(QtRcc)' != '' - AND '$(SelectedFiles)' == '' - AND '%(QtRcc.ExcludedFromBuild)' == 'true'"/> + <QtRcc Remove="@(QtRcc)" + Condition="'$(SelectedFiles)' == '' AND '%(QtRcc.ExcludedFromBuild)' == 'true'"/> </ItemGroup> + + <!--// Clean-up --> + <PropertyGroup> + <selected_files/> + <file/> + <output_file/> + <is_selected/> + </PropertyGroup> </Target> <!-- @@ -249,23 +263,21 @@ // --> <PropertyGroup> <!--// Force modified flag if source was manually selected to build --> - <input_changed Condition="'@(SelectedFiles)' == ''" + <input_changed Condition="'$(SelectedFiles)' == ''" >%(QtRcc.InputChanged)</input_changed> - <input_changed Condition="'@(SelectedFiles)' != ''" + <input_changed Condition="'$(SelectedFiles)' != ''" >true</input_changed> <!--// Run work in parallel processes --> <run_parallel Condition="'@(QtRcc)' != '' - AND '%(QtRcc.ExcludedFromBuild)' != 'true' AND '%(QtRcc.ParallelProcess)' == 'true' - AND '@(SelectedFiles)' == ''" + AND '$(SelectedFiles)' == ''" >true</run_parallel> <!--// Run work in single process --> <run_single Condition="'@(QtRcc)' != '' - AND '%(QtRcc.ExcludedFromBuild)' != 'true' AND ('%(QtRcc.ParallelProcess)' != 'true' - OR '@(SelectedFiles)' != '')" + OR '$(SelectedFiles)' != '')" >true</run_single> </PropertyGroup> @@ -276,7 +288,6 @@ <ItemGroup Condition="'$(run_parallel)' == 'true' OR '$(run_single)' == 'true'"> <QtWork Include="@(QtRcc)"> <WorkType>rcc</WorkType> - <DependsOnWork>qmlcachegen_filter</DependsOnWork> <ToolPath>%(QtRcc.QTDIR)\bin\rcc.exe</ToolPath> <Options>$(options)</Options> <Message>%(QtRcc.ExecutionDescription)</Message> diff --git a/src/qtmsbuild/qtuic.targets b/src/qtmsbuild/qtuic.targets index 0b01a79e..2545d802 100644 --- a/src/qtmsbuild/qtuic.targets +++ b/src/qtmsbuild/qtuic.targets @@ -52,7 +52,7 @@ <PropertyPageSchema Include="$(MSBuildThisFileDirectory)$(MSBuildThisFileName).xml" /> <AvailableItemName Include="QtUic"> - <Targets>QtUic</Targets> + <Targets>Qt</Targets> </AvailableItemName> </ItemGroup> @@ -62,29 +62,42 @@ ///////////////////////////////////////////////////////////////////////////////////////////////// // Prepare to process sources // --> - <Target Name="QtUicPrepare"> + <Target Name="QtUicPrepare" DependsOnTargets="_SelectedFiles" + Inputs="%(QtUic.Identity)" Outputs="@(QtUic->'####### Don't skip this target #######')"> <Message Importance="High" Condition="'$(QtDebug)' == 'true'" Text="## QtUicPrepare @(QtUic)"/> + <PropertyGroup> + <selected_files>[@(SelectedFiles->'%(Identity)','][')]</selected_files> + <file>[@(QtUic->'%(Identity)')]</file> + <output_file>@(QtUic->'%(OutputFile)')</output_file> + <is_selected Condition="$(selected_files.Contains('$(file)'))">true</is_selected> + </PropertyGroup> + <!--// Delete output file to force build of source if it was manually selected to build // (e.g. by the 'Compile' option in the context menu for the file) --> - <Delete Files="%(QtUic.OutputFile)" - Condition="'$(SelectedFiles)' == '%(QtUic.Identity)'" /> + <Delete Files="$(output_file)" + Condition="'$(SelectedFiles)' != '' AND '$(is_selected)' == 'true'" /> <!--// If a source was manually selected to build, remove all other sources --> - <ItemGroup> - <QtUic Remove="@(QtUic)" Condition="'@(QtUic)' != '' - AND '$(SelectedFiles)' != '' - AND '%(QtUic.Identity)' != '$(SelectedFiles)'" /> + <ItemGroup Condition="'@(SelectedFiles)' != ''"> + <QtUic Remove="@(QtUic)" + Condition="'$(SelectedFiles)' != '' AND '$(is_selected)' != 'true'" /> </ItemGroup> <!--// Remove sources excluded from build --> <ItemGroup> - <QtUic Remove="@(QtUic)" Condition="'@(QtUic)' != '' - AND '$(SelectedFiles)' == '' - AND '%(QtUic.ExcludedFromBuild)' == 'true'"/> + <QtUic Remove="@(QtUic)" + Condition="'$(SelectedFiles)' == '' AND '%(QtUic.ExcludedFromBuild)' == 'true'"/> </ItemGroup> + + <PropertyGroup> + <selected_files/> + <file/> + <output_file/> + <is_selected/> + </PropertyGroup> </Target> <!-- @@ -210,14 +223,12 @@ <!--// Run work in parallel processes --> <run_parallel Condition="'@(QtUic)' != '' - AND '%(QtUic.ExcludedFromBuild)' != 'true' AND '%(QtUic.ParallelProcess)' == 'true' AND '$(SelectedFiles)' == ''" >true</run_parallel> <!--// Run work in single process --> <run_single Condition="'@(QtUic)' != '' - AND '%(QtUic.ExcludedFromBuild)' != 'true' AND ('%(QtUic.ParallelProcess)' != 'true' OR '$(SelectedFiles)' != '')" >true</run_single> |