windows: simplify handling of gettext

fixes binplace on first build
This commit is contained in:
Shawn Hoffman 2022-04-02 15:22:02 -07:00
parent 113fdc959d
commit db4d81b9a8
8 changed files with 23 additions and 319 deletions

View File

@ -8,52 +8,26 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(VSPropsDir)Configuration.Utility.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="po.props" />
</ImportGroup>
<ImportGroup Label="ExtensionSettings" />
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VSPropsDir)Base.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemGroup>
<msgfmt Include="po\ar.po" />
<msgfmt Include="po\ca.po" />
<msgfmt Include="po\cs.po" />
<msgfmt Include="po\da.po" />
<msgfmt Include="po\de.po" />
<msgfmt Include="po\el.po" />
<msgfmt Include="po\en.po" />
<msgfmt Include="po\es.po" />
<msgfmt Include="po\fa.po" />
<msgfmt Include="po\fr.po" />
<msgfmt Include="po\hr.po" />
<msgfmt Include="po\hu.po" />
<msgfmt Include="po\it.po" />
<msgfmt Include="po\ja.po" />
<msgfmt Include="po\ko.po" />
<msgfmt Include="po\ms.po" />
<msgfmt Include="po\nb.po" />
<msgfmt Include="po\nl.po" />
<msgfmt Include="po\pl.po" />
<msgfmt Include="po\pt.po" />
<msgfmt Include="po\pt_BR.po" />
<msgfmt Include="po\ro.po" />
<msgfmt Include="po\ru.po" />
<msgfmt Include="po\sr.po" />
<msgfmt Include="po\sv.po" />
<msgfmt Include="po\tr.po" />
<msgfmt Include="po\zh_CN.po" />
<msgfmt Include="po\zh_TW.po" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="po.targets" />
</ImportGroup>
<ImportGroup Label="ExtensionTargets" />
<PropertyGroup>
<msgfmt>..\Externals\gettext\msgfmt</msgfmt>
</PropertyGroup>
<ItemGroup>
<PoFiles Include="$(OutDir)\**\*.*" />
<PoFiles Include="po\*.po" />
<MoFiles Include="@(PoFiles -> '$(OutDir)%(Filename).mo')" />
<MoFilesDst Include="@(MoFiles -> '$(BinaryOutputDir)Languages\%(Filename)%(Extension)')" />
</ItemGroup>
<Target Name="AfterBuild" Inputs="@(PoFiles)" Outputs="@(PoFiles -> '$(BinaryOutputDir)%(RecursiveDir)%(Filename)%(Extension)')">
<Copy SourceFiles="@(PoFiles)" DestinationFolder="$(BinaryOutputDir)%(RecursiveDir)" />
<Target Name="MsgFmtCompile" BeforeTargets="Midl" AfterTargets="CustomBuild" Inputs="@(PoFiles)" Outputs="@(MoFiles)">
<Exec Command='$(msgfmt) -o "$(OutDir)%(PoFiles.Filename).mo" "@(PoFiles)"' />
</Target>
<Target Name="MsgFmtCopy" AfterTargets="MsgFmtCompile" Inputs="@(MoFiles)" Outputs="@(MoFilesDst)">
<Copy SourceFiles="@(MoFiles)" DestinationFiles="@(MoFilesDst)" SkipUnchangedFiles="true" />
</Target>
</Project>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ShowAllFiles>true</ShowAllFiles>
</PropertyGroup>
</Project>

View File

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup
Condition="'$(msgfmtBeforeTargets)' == '' and '$(msgfmtAfterTargets)' == '' and '$(ConfigurationType)' != 'Makefile'">
<msgfmtBeforeTargets>Midl</msgfmtBeforeTargets>
<msgfmtAfterTargets>CustomBuild</msgfmtAfterTargets>
</PropertyGroup>
<PropertyGroup>
<msgfmtDependsOn
Condition="'$(ConfigurationType)' != 'Makefile'">_SelectedFiles;$(msgfmtDependsOn)</msgfmtDependsOn>
</PropertyGroup>
<ItemDefinitionGroup>
<msgfmt>
<Verbose>False</Verbose>
<OutputName>$(OutDir)Languages\%(Filename)\dolphin-emu.mo</OutputName>
<CommandLineTemplate>..\Externals\gettext\msgfmt [AllOptions] [AdditionalOptions] [inputs]</CommandLineTemplate>
<Outputs>%(OutputName)</Outputs>
<ExecutionDescription>Compiling %(Filename) locale</ExecutionDescription>
</msgfmt>
</ItemDefinitionGroup>
</Project>

View File

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<VisualStudioToolFile
Name="Message Compiler"
Version="8.00"
>
<Rules>
<CustomBuildRule
Name="msgfmt"
DisplayName="Compile Locale"
CommandLine="..\Externals\gettext\msgfmt [AllOptions] [AdditionalOptions] [inputs]"
Outputs="[$OutputName]"
FileExtensions="*.po"
ExecutionDescription="Compiling $(InputName) locale"
>
<Properties>
<StringProperty
Name="OutputName"
DisplayName="Output File"
Description="Specifies a name to override the default file name"
Switch="-o &quot;[value]&quot;"
DefaultValue="$(OutDir)\Languages\$(InputName)\dolphin-emu.mo"
Delimited="true"
/>
<BooleanProperty
Name="Verbose"
DisplayName="Verbose"
Description="Increase verbosity level"
Switch="-v"
/>
</Properties>
</CustomBuildRule>
</Rules>
</VisualStudioToolFile>

View File

@ -1,83 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<PropertyPageSchema
Include="$(MSBuildThisFileDirectory)$(MSBuildThisFileName).xml" />
<AvailableItemName
Include="msgfmt">
<Targets>_msgfmt</Targets>
</AvailableItemName>
</ItemGroup>
<UsingTask
TaskName="msgfmt"
TaskFactory="XamlTaskFactory"
AssemblyName="Microsoft.Build.Tasks.v4.0">
<Task>$(MSBuildThisFileDirectory)$(MSBuildThisFileName).xml</Task>
</UsingTask>
<Target
Name="_msgfmt"
BeforeTargets="$(msgfmtBeforeTargets)"
AfterTargets="$(msgfmtAfterTargets)"
Condition="'@(msgfmt)' != ''"
DependsOnTargets="$(msgfmtDependsOn);ComputemsgfmtOutput"
Outputs="@(msgfmt-&gt;Metadata('Outputs')-&gt;Distinct())"
Inputs="@(msgfmt);%(msgfmt.AdditionalDependencies);$(MSBuildProjectFile)">
<ItemGroup
Condition="'@(SelectedFiles)' != ''">
<msgfmt
Remove="@(msgfmt)"
Condition="'%(Identity)' != '@(SelectedFiles)'" />
</ItemGroup>
<ItemGroup>
<msgfmt_tlog
Include="%(msgfmt.Outputs)"
Condition="'%(msgfmt.Outputs)' != '' and '%(msgfmt.ExcludedFromBuild)' != 'true'">
<Source>@(msgfmt, '|')</Source>
</msgfmt_tlog>
</ItemGroup>
<Message
Importance="High"
Text="%(msgfmt.ExecutionDescription)" />
<WriteLinesToFile
Condition="'@(msgfmt_tlog)' != '' and '%(msgfmt_tlog.ExcludedFromBuild)' != 'true'"
File="$(IntDir)$(ProjectName).write.1.tlog"
Lines="^%(msgfmt_tlog.Source);@(msgfmt_tlog-&gt;'%(Fullpath)')" />
<msgfmt
Condition="'@(msgfmt)' != '' and '%(msgfmt.ExcludedFromBuild)' != 'true'"
CommandLineTemplate="%(msgfmt.CommandLineTemplate)"
Verbose="%(msgfmt.Verbose)"
OutputName="%(msgfmt.OutputName)"
AdditionalOptions="%(msgfmt.AdditionalOptions)"
Inputs="@(msgfmt)" />
</Target>
<PropertyGroup>
<ComputeLinkInputsTargets>
$(ComputeLinkInputsTargets);
ComputemsgfmtOutput;
</ComputeLinkInputsTargets>
<ComputeLibInputsTargets>
$(ComputeLibInputsTargets);
ComputemsgfmtOutput;
</ComputeLibInputsTargets>
</PropertyGroup>
<Target
Name="ComputemsgfmtOutput"
Condition="'@(msgfmt)' != ''">
<ItemGroup>
<msgfmtDirsToMake
Condition="'@(msgfmt)' != '' and '%(msgfmt.ExcludedFromBuild)' != 'true'"
Include="%(msgfmt.Outputs)" />
<Link
Include="%(msgfmtDirsToMake.Identity)"
Condition="'%(Extension)'=='.obj' or '%(Extension)'=='.res' or '%(Extension)'=='.rsc' or '%(Extension)'=='.lib'" />
<Lib
Include="%(msgfmtDirsToMake.Identity)"
Condition="'%(Extension)'=='.obj' or '%(Extension)'=='.res' or '%(Extension)'=='.rsc' or '%(Extension)'=='.lib'" />
<ImpLib
Include="%(msgfmtDirsToMake.Identity)"
Condition="'%(Extension)'=='.obj' or '%(Extension)'=='.res' or '%(Extension)'=='.rsc' or '%(Extension)'=='.lib'" />
</ItemGroup>
<MakeDir
Directories="@(msgfmtDirsToMake-&gt;'%(RootDir)%(Directory)')" />
</Target>
</Project>

View File

@ -1,140 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ProjectSchemaDefinitions xmlns="clr-namespace:Microsoft.Build.Framework.XamlTypes;assembly=Microsoft.Build.Framework" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:transformCallback="Microsoft.Cpp.Dev10.ConvertPropertyCallback">
<Rule
Name="msgfmt"
PageTemplate="tool"
DisplayName="Compile Locale"
Order="200">
<Rule.DataSource>
<DataSource
Persistence="ProjectFile"
ItemType="msgfmt" />
</Rule.DataSource>
<Rule.Categories>
<Category
Name="General">
<Category.DisplayName>
<sys:String>General</sys:String>
</Category.DisplayName>
</Category>
<Category
Name="Command Line"
Subtype="CommandLine">
<Category.DisplayName>
<sys:String>Command Line</sys:String>
</Category.DisplayName>
</Category>
</Rule.Categories>
<StringListProperty
Name="Inputs"
Category="Command Line"
IsRequired="true"
Switch=" ">
<StringListProperty.DataSource>
<DataSource
Persistence="ProjectFile"
ItemType="msgfmt"
SourceType="Item" />
</StringListProperty.DataSource>
</StringListProperty>
<BoolProperty
Name="Verbose"
HelpContext="0"
DisplayName="Verbose"
Description="Increase verbosity level"
Switch="-v" />
<StringListProperty
Name="OutputName"
HelpContext="0"
DisplayName="Output File"
Description="Specifies a name to override the default file name"
Separator=";"
Switch="-o &quot;[value]&quot;" />
<StringProperty
Name="CommandLineTemplate"
DisplayName="Command Line"
Visible="False"
IncludeInCommandLine="False" />
<DynamicEnumProperty
Name="msgfmtBeforeTargets"
Category="General"
EnumProvider="Targets"
IncludeInCommandLine="False">
<DynamicEnumProperty.DisplayName>
<sys:String>Execute Before</sys:String>
</DynamicEnumProperty.DisplayName>
<DynamicEnumProperty.Description>
<sys:String>Specifies the targets for the build customization to run before.</sys:String>
</DynamicEnumProperty.Description>
<DynamicEnumProperty.ProviderSettings>
<NameValuePair
Name="Exclude"
Value="^msgfmtBeforeTargets|^Compute" />
</DynamicEnumProperty.ProviderSettings>
<DynamicEnumProperty.DataSource>
<DataSource
Persistence="ProjectFile"
HasConfigurationCondition="true" />
</DynamicEnumProperty.DataSource>
</DynamicEnumProperty>
<DynamicEnumProperty
Name="msgfmtAfterTargets"
Category="General"
EnumProvider="Targets"
IncludeInCommandLine="False">
<DynamicEnumProperty.DisplayName>
<sys:String>Execute After</sys:String>
</DynamicEnumProperty.DisplayName>
<DynamicEnumProperty.Description>
<sys:String>Specifies the targets for the build customization to run after.</sys:String>
</DynamicEnumProperty.Description>
<DynamicEnumProperty.ProviderSettings>
<NameValuePair
Name="Exclude"
Value="^msgfmtAfterTargets|^Compute" />
</DynamicEnumProperty.ProviderSettings>
<DynamicEnumProperty.DataSource>
<DataSource
Persistence="ProjectFile"
ItemType=""
HasConfigurationCondition="true" />
</DynamicEnumProperty.DataSource>
</DynamicEnumProperty>
<StringListProperty
Name="Outputs"
DisplayName="Outputs"
Visible="False"
IncludeInCommandLine="False" />
<StringProperty
Name="ExecutionDescription"
DisplayName="Execution Description"
Visible="False"
IncludeInCommandLine="False" />
<StringListProperty
Name="AdditionalDependencies"
DisplayName="Additional Dependencies"
IncludeInCommandLine="False"
Visible="false" />
<StringProperty
Subtype="AdditionalOptions"
Name="AdditionalOptions"
Category="Command Line">
<StringProperty.DisplayName>
<sys:String>Additional Options</sys:String>
</StringProperty.DisplayName>
<StringProperty.Description>
<sys:String>Additional Options</sys:String>
</StringProperty.Description>
</StringProperty>
</Rule>
<ItemType
Name="msgfmt"
DisplayName="Compile Locale" />
<FileExtension
Name="*.po"
ContentType="msgfmt" />
<ContentType
Name="msgfmt"
DisplayName="Compile Locale"
ItemType="msgfmt" />
</ProjectSchemaDefinitions>

View File

@ -466,11 +466,12 @@ if(GETTEXT_MSGFMT_EXECUTABLE)
foreach(po ${LINGUAS})
get_filename_component(lang ${po} NAME_WE)
if(WIN32)
set(mo_dir ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Languages/${lang})
set(mo_dir ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Languages)
set(mo ${mo_dir}/${lang}.mo)
else()
set(mo_dir ${CMAKE_CURRENT_BINARY_DIR}/${lang})
set(mo ${mo_dir}/dolphin-emu.mo)
endif()
set(mo ${mo_dir}/dolphin-emu.mo)
target_sources(dolphin-emu PRIVATE ${mo})
source_group("Localization\\\\Generated" FILES ${mo})

View File

@ -275,7 +275,7 @@ static bool TryInstallTranslator(const QString& exact_language_code)
std::string lang = qlang.toStdString();
auto filename =
#if defined _WIN32
File::GetExeDirectory() + StringFromFormat("/Languages/%s/dolphin-emu.mo", lang.c_str())
File::GetExeDirectory() + StringFromFormat("/Languages/%s.mo", lang.c_str())
#elif defined __APPLE__
File::GetBundleDirectory() +
StringFromFormat("/Contents/Resources/%s.lproj/dolphin-emu.mo", lang.c_str())