From bb56b169fc313459986a1cc4bfd26b0c37a17669 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin <stenzek@gmail.com> Date: Tue, 28 Jul 2020 03:08:41 +1000 Subject: [PATCH] VSProps: Support compiling Qt translation files --- dep/msvc/vsprops/QtCompile.props | 25 +++++++++++++++++++++++++ dep/msvc/vsprops/QtCompile.targets | 2 +- dep/msvc/vsprops/QtCompile.xml | 3 +++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/dep/msvc/vsprops/QtCompile.props b/dep/msvc/vsprops/QtCompile.props index a99ba4004..e8ac1f4db 100644 --- a/dep/msvc/vsprops/QtCompile.props +++ b/dep/msvc/vsprops/QtCompile.props @@ -13,6 +13,7 @@ <QtPluginsDir>$(QTDIR)plugins\</QtPluginsDir> <QtToolOutDir>$(SolutionDir)build\$(ProjectName)-$(Platform)-$(Configuration)\</QtToolOutDir> <QtMocOutPrefix>$(QtToolOutDir)moc_</QtMocOutPrefix> + <QtTsOutDir>$(BinaryOutputDir)translations\</QtTsOutDir> <QtDebugSuffix>d</QtDebugSuffix> <QtLibSuffix Condition="'$(Configuration)'=='Debug' Or '$(Configuration)'=='DebugFast'">$(QtDebugSuffix)</QtLibSuffix> <QtPluginFolder>QtPlugins</QtPluginFolder> @@ -113,6 +114,9 @@ <AvailableItemName Include="QtMoc"> <Targets>QtMoc</Targets> </AvailableItemName> + <AvailableItemName Include="QtTs"> + <Targets>QtTs</Targets> + </AvailableItemName> </ItemGroup> <!--Copy the needed dlls--> @@ -157,4 +161,25 @@ Overwrite="true" /> </Target> + + <!--Compiles all translation files--> + <ItemGroup> + <TsFiles Include="$(MSBuildProjectDirectory)\**\*.ts" /> + </ItemGroup> + <Target Name="QtTs" + BeforeTargets="ClCompile" + Inputs="@(TsFiles)" + Condition="'@(QtTs)'!=''" + Outputs="@(TsFiles->'$(QtTsOutDir)%(Filename).qm')"> + <Message Text="lrelease %(TsFiles.Filename)" Importance="High" /> + <Error Condition="!$(QtDirValid)" Text="QTDIR not set or non-existent (pull the submodule?)" /> + <MakeDir Directories="$(QtTsOutDir)" /> + <Exec Command=""$(QtBinDir)lrelease.exe" "%(TsFiles.FullPath)" -qm "$(QtTsOutDir)%(TsFiles.Filename).qm"" /> + </Target> + <ItemGroup> + <TsOutputs Include="$(QtTsOutDir)*.qm" /> + </ItemGroup> + <Target Name="QtTsClean"> + <Delete Files="@(TsOutputs)" /> + </Target> </Project> diff --git a/dep/msvc/vsprops/QtCompile.targets b/dep/msvc/vsprops/QtCompile.targets index 9ab1522a8..75ac29f30 100644 --- a/dep/msvc/vsprops/QtCompile.targets +++ b/dep/msvc/vsprops/QtCompile.targets @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> - <CleanDependsOn>QtResourceClean;QtUiClean;QtMocClean;$(CleanDependsOn)</CleanDependsOn> + <CleanDependsOn>QtResourceClean;QtUiClean;QtMocClean;QtTsClean;$(CleanDependsOn)</CleanDependsOn> <!-- <ComputeLinkInputsTargets>$(ComputeLinkInputsTargets);QtComputeMocOutput;</ComputeLinkInputsTargets> <ComputeLibInputsTargets>$(ComputeLibInputsTargets);QtComputeMocOutput;</ComputeLibInputsTargets> diff --git a/dep/msvc/vsprops/QtCompile.xml b/dep/msvc/vsprops/QtCompile.xml index 976c2d2b8..376118df7 100644 --- a/dep/msvc/vsprops/QtCompile.xml +++ b/dep/msvc/vsprops/QtCompile.xml @@ -3,9 +3,12 @@ <ItemType Name="QtResource" DisplayName="Qt Resource File" /> <ItemType Name="QtUi" DisplayName="Qt User Interface File" /> <ItemType Name="QtMoc" DisplayName="Qt Meta Object File" /> + <ItemType Name="QtTs" DisplayName="Qt Translation File" /> <ContentType Name="QtUi" DisplayName="Qt User Interface Compiler" /> <ContentType Name="QtResource" DisplayName="Qt Resource Compiler" /> <ContentType Name="QtMoc" DisplayName="Qt Meta Object Compiler" /> + <ContentType Name="QtTs" DisplayName="Qt Translation Compiler" /> <FileExtension Name="*.qrc" ContentType="QtResource" /> <FileExtension Name="*.ui" ContentType="QtUi" /> + <FileExtension Name="*.ts" ContentType="QtTs" /> </ProjectSchemaDefinitions> \ No newline at end of file