Split Yasm targets into reusable file

This commit is contained in:
Niels Martin Hansen 2015-01-19 22:45:02 +01:00
parent e692759ea1
commit 2cfa6f14f2
2 changed files with 107 additions and 61 deletions

View File

@ -11,6 +11,9 @@
<ImportGroup Label="PropertySheets">
<Import Project="$(MSBuildThisFileDirectory)..\aegisub.props" />
</ImportGroup>
<ImportGroup Label="Targets">
<Import Project="$(MSBuildThisFileDirectory)..\yasm.targets" />
</ImportGroup>
<!-- Project specific configuration -->
<ItemDefinitionGroup>
@ -56,70 +59,12 @@
</InstallHeader>
<Yasm>
<InputRelativeSourceDir>$(FfmpegSrcDir)\</InputRelativeSourceDir>
<Include>%(Include) -I$(MSBuildThisFileDirectory) -I$(MSBuildThisFileDirectory)$(FfmpegSrcDir)</Include>
<Config Condition="'$(Platform)'=='Win32'">%(Config) -DPREFIX -Pconfig-x86.asm</Config>
<Config Condition="'$(Platform)'=='x64'">%(Config) -Pconfig-x64.asm</Config>
</Yasm>
</ItemDefinitionGroup>
<PropertyGroup>
<BuildCompileTargets>
_YasmAssemble;
$(BuildCompileTargets)
</BuildCompileTargets>
</PropertyGroup>
<Target
Name="_YasmAssemble"
DependsOnTargets="ComputeYasmRelativeObjectDir;YasmCreateOutputDir;YasmAssemble"
/>
<!-- See standard-outdirs.props for explanation of the logic here -->
<Target
Name="ComputeYasmRelativeObjectDir"
BeforeTargets="YasmAssemble"
Inputs="@(Yasm)"
Outputs="%(InputRelativeSourceDir)|%(RelativeDir)"
>
<PropertyGroup>
<InputRelativeDir>%(Yasm.RelativeDir)</InputRelativeDir>
<InputRelativeDir Condition="'%(Yasm.InputRelativeSourceDir)' != ''">$(InputRelativeDir.Replace("%(Yasm.InputRelativeSourceDir)",""))</InputRelativeDir>
<InputRelativeSourceDir>%(Yasm.InputRelativeSourceDir)</InputRelativeSourceDir>
<InputRelativeSourceDir Condition="!HasTrailingSlash('$(InputRelativeSourceDir)')">$(InputRelativeSourceDir)\</InputRelativeSourceDir>
<InputRelativeDir>$(InputRelativeDir.Replace("$(InputRelativeSourceDir)",""))</InputRelativeDir>
</PropertyGroup>
<ItemGroup>
<Yasm>
<OutputDir>$(AegisubObjectDir)$(InputRelativeDir)</OutputDir>
</Yasm>
</ItemGroup>
</Target>
<Target
Name="YasmCreateOutputDir"
Inputs="@(Yasm)"
Outputs="%(Yasm.OutputDir)"
>
<MakeDir
Directories="%(Yasm.OutputDir)"
/>
</Target>
<Target
Name="YasmAssemble"
Inputs="@(Yasm)"
Outputs="%(Yasm.OutputDir)%(Yasm.Filename).obj"
>
<PropertyGroup>
<YasmInclude>-I. -I$(MSBuildThisFileDirectory) -I$(FfmpegSrcDir) -I%(Yasm.RootDir)%(Yasm.Directory)</YasmInclude>
<YasmOutName>@(Yasm -> '%(OutputDir)%(Filename)').obj</YasmOutName>
<YasmConfig Condition="'$(Platform)'=='Win32'">-m x86 -DPREFIX -Pconfig-x86.asm</YasmConfig>
<YasmConfig Condition="'$(Platform)'=='x64'">-m amd64 -Pconfig-x64.asm</YasmConfig>
</PropertyGroup>
<Exec
Command="echo $(InputRelativeDir)%(Yasm.Filename)%(Yasm.Extension) &amp;&amp; yasm -f win32 $(YasmConfig) $(YasmInclude) -o $(YasmOutName) %(Yasm.FullPath)"
WorkingDirectory="$(AegisubObjectDir)"
/>
<ItemGroup>
<Link Include="$(YasmOutName)" />
<Lib Include="$(YasmOutName)" />
<ImpLib Include="$(YasmOutName)" />
</ItemGroup>
</Target>
<!-- Project References -->
<ItemGroup>
<ProjectReference Include="..\zlib\zlib.vcxproj">

101
build/yasm.targets Normal file
View File

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_PropertySheetDisplayName>Yasm compile targets</_PropertySheetDisplayName>
</PropertyGroup>
<PropertyGroup>
<BuildCompileTargets>
_YasmAssemble;
$(BuildCompileTargets)
</BuildCompileTargets>
</PropertyGroup>
<ItemDefinitionGroup>
<Yasm>
<InputRelativeSourceDir></InputRelativeSourceDir>
<Include></Include>
<ExcludeFromBuild>false</ExcludeFromBuild>
<Config Condition="'$(Platform)'=='Win32'">-m x86</Config>
<Config Condition="'$(Platform)'=='x64'">-m amd64</Config>
</Yasm>
</ItemDefinitionGroup>
<Target
Name="_YasmAssemble"
DependsOnTargets="ComputeYasmOutputs;YasmAssemble"
Condition="'@(Yasm)' != ''"
/>
<!-- See standard-outdirs.props for explanation of the logic here -->
<Target
Name="ComputeYasmOutputs"
Inputs="@(Yasm)"
Outputs="%(InputRelativeSourceDir)|%(RelativeDir)"
>
<CalculateOutputDir
Items="@(Yasm)"
SourceDir="%(InputRelativeSourceDir)"
DestinationDir=".\"
Condition="'%(Yasm.InputRelativeSourceDir)' != ''"
>
<Output ItemName="_Yasm" TaskParameter="Outputs" />
</CalculateOutputDir>
<ItemGroup>
<!-- If the items don't have the InputRelativeSourceDir metadata, still
copy them to _Yasm and add an OutputDir metadata to them. -->
<_Yasm Include="@(Yasm)" Condition="'%(Yasm.InputRelativeSourceDir)' == ''">
<OutputDir></OutputDir>
</_Yasm>
<!-- Remove items marked for exclusion (e.g. due to platform) -->
<_Yasm Remove="@(_Yasm->WithMetadataValue('ExcludeFromBuild','true'))" />
</ItemGroup>
</Target>
<Target
Name="ComputeYasmFinalOutputDir"
Inputs="@(_Yasm)"
Outputs="%(OutputDir)|%(RelativeDir)"
>
<ItemGroup>
<_Yasm>
<Include>%(Include) -I%(RootDir)%(Directory)</Include>
<OutputDir Condition="'%(OutputDir)' == '.\'"></OutputDir>
<RelativeOutputDir>%(OutputDir)</RelativeOutputDir>
<OutputDir>$(AegisubObjectDir)%(OutputDir)</OutputDir>
</_Yasm>
</ItemGroup>
</Target>
<Target
Name="YasmCreateOutputDir"
DependsOnTargets="ComputeYasmFinalOutputDir"
Inputs="@(_Yasm)"
Outputs="@(_Yasm->'%(OutputDir)')"
>
<MakeDir
Directories="@(_Yasm->'%(OutputDir)')"
/>
</Target>
<Target
Name="YasmAssemble"
DependsOnTargets="ComputeYasmFinalOutputDir;YasmCreateOutputDir"
Inputs="@(_Yasm)"
Outputs="%(_Yasm.OutputDir)%(_Yasm.Filename).obj"
>
<Message
Importance="High"
Text="%(_Yasm.RelativeOutputDir)%(_Yasm.Filename)%(_Yasm.Extension)"
/>
<Exec
Command="Yasm -f win32 %(_Yasm.Config) %(_Yasm.Include) -o &quot;%(_Yasm.OutputDir)%(_Yasm.Filename).obj&quot; &quot;%(_Yasm.FullPath)&quot;"
WorkingDirectory="%(_Yasm.OutputDir)"
/>
<ItemGroup>
<Link Include="%(_Yasm.OutputDir)%(_Yasm.Filename).obj" />
<Lib Include="%(_Yasm.OutputDir)%(_Yasm.Filename).obj" />
<ImpLib Include="%(_Yasm.OutputDir)%(_Yasm.Filename).obj" />
</ItemGroup>
</Target>
</Project>