mirror of https://github.com/odrling/Aegisub
Use new task in relative-ObjectFileName target
This commit is contained in:
parent
59ab4cd09b
commit
5e446264a2
|
@ -27,19 +27,8 @@
|
|||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
|
||||
<!-- Magic pseudo-target that makes object filenames relative to a given directory
|
||||
|
||||
First define its relation to the system build targets: It must run as part of the
|
||||
"compile inputs" section, but before all the system things. The system things here
|
||||
include testing whether multiple inputs might have identical outputs, which will
|
||||
produce a warning which we don't want.
|
||||
|
||||
Then define the target, make it depend on all ClCompile items, and have a fake
|
||||
output that can never be a valid filename (due to pipe character). Instead have
|
||||
the output name depend on the two variables involved in how the ObjectFileName
|
||||
is determined: The specified InputRelativeSourceDir, and the actual RelativeDir
|
||||
for the items.
|
||||
This will cause MSBuild to batch the items as appropriate.
|
||||
<!-- Add ObjectFileName for ClCompile items that need to be placed in subdirs
|
||||
for linking to work, for projects with same-named files in separate dirs.
|
||||
|
||||
To use this feature, add a InputRelativeSourceDir metadata to ClCompile for
|
||||
a project.
|
||||
|
@ -55,18 +44,25 @@
|
|||
Inputs="@(ClCompile)"
|
||||
Outputs="%(InputRelativeSourceDir)|%(RelativeDir)"
|
||||
>
|
||||
<PropertyGroup>
|
||||
<InputRelativeDir>%(ClCompile.RelativeDir)</InputRelativeDir>
|
||||
<InputRelativeDir Condition="!HasTrailingSlash('$(InputRelativeDir)')">$(InputRelativeDir)\</InputRelativeDir>
|
||||
<InputRelativeSourceDir>%(ClCompile.InputRelativeSourceDir)</InputRelativeSourceDir>
|
||||
<InputRelativeSourceDir Condition="!HasTrailingSlash('$(InputRelativeSourceDir)')">$(InputRelativeSourceDir)\</InputRelativeSourceDir>
|
||||
<InputRelativeDir>$(InputRelativeDir.Replace("$(InputRelativeSourceDir)",""))</InputRelativeDir>
|
||||
</PropertyGroup>
|
||||
<!-- <Exec Command="echo ClCompile output for @(ClCompile -> '%(Filename)%(Extension)') to $(IntDir)$(InputRelativeDir)" /> -->
|
||||
<!-- Transform paths on items -->
|
||||
<CalculateOutputDir
|
||||
Items="@(ClCompile)"
|
||||
SourceDir="%(InputRelativeSourceDir)"
|
||||
DestinationDir="."
|
||||
Condition="'%(ClCompile.InputRelativeSourceDir)' != ''"
|
||||
>
|
||||
<Output ItemName="_RelativeClCompile" TaskParameter="Outputs" />
|
||||
</CalculateOutputDir>
|
||||
<ItemGroup>
|
||||
<ClCompile Condition="'%(ClCompile.InputRelativeSourceDir)' != ''">
|
||||
<ObjectFileName>$(IntDir)$(InputRelativeDir)</ObjectFileName>
|
||||
</ClCompile>
|
||||
<!-- Add the ObjectFileName -->
|
||||
<_RelativeClCompile Condition="'%(_RelativeClCompile.OutputDir)' != ''">
|
||||
<ObjectFileName>$(IntDir)%(_RelativeClCompile.OutputDir)</ObjectFileName>
|
||||
</_RelativeClCompile>
|
||||
<!-- Remove old items and replace them with new -->
|
||||
<ClCompile Remove="@(_RelativeClCompile->'%(Identity)')" />
|
||||
<ClCompile Include="@(_RelativeClCompile)" />
|
||||
<!-- Forget about the temporary ones -->
|
||||
<_RelativeClCompile Remove="@(_RelativeClCompile)" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
</Project>
|
||||
|
|
Loading…
Reference in New Issue