Skip to content

Commit

Permalink
Add GeneratedPaths output property that contains the paths of all gen…
Browse files Browse the repository at this point in the history
…erated items
  • Loading branch information
pepone committed Jan 18, 2021
1 parent dd27672 commit 826b11c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
11 changes: 11 additions & 0 deletions Tasks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,13 @@ public ITaskItem[] ComputedSources
private set;
}

[Output]
public string[] GeneratedPaths
{
get;
private set;
}

protected abstract string ToolName
{
get;
Expand Down Expand Up @@ -711,6 +718,7 @@ public virtual Dictionary<string, string> GetOptions(ITaskItem item)
public override bool Execute()
{
List<ITaskItem> computed = new List<ITaskItem>();
List<string> generatedPaths = new List<string>();
foreach(ITaskItem source in Sources)
{
bool skip = true;
Expand All @@ -728,6 +736,8 @@ public override bool Execute()
var generatedItems = GeneratedItems(source);
FileInfo generatedInfo = null;
FileInfo dependInfo = null;

generatedPaths.AddRange(generatedItems.Select(item => item.GetMetadata("FullPath")));
//
// Check if the Slice compiler is older than the source file
//
Expand Down Expand Up @@ -922,6 +932,7 @@ public override bool Execute()
computed.Add(computedSource);
}
ComputedSources = computed.ToArray();
GeneratedPaths = generatedPaths.ToArray();
return true;
}
}
Expand Down
14 changes: 6 additions & 8 deletions msbuild/zeroc.icebuilder.msbuild.cpp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
ItemName = "_SliceCompile"
TaskParameter = "ComputedSources"/>

<Output
PropertyName = "_SliceCompileGeneratedPaths"
TaskParameter = "GeneratedPaths"/>

</Slice2CppDependTask>

<!-- Compile the Slice files -->
Expand Down Expand Up @@ -102,17 +106,11 @@
a persistent way. If the extension is not enabled or we are building from the command line we just add the
missing items in a transient way.
First create a property `_SliceCompileGeneratedItems` to hold the paths of all generated items, then we
create a ItemGroup to add a ClCompile item for each generated item that is not part of the project. Using an
intermediate property for the ClCompile Include avoids _SliceCompile item metadata being copied to the
generated ClCompile item.
The builder's depend task has an output property named GeneratedPaths that contains the paths of all generated items.
-->
<CreateProperty Value="$([System.IO.Path]::GetFullPath('%(_SliceCompile.OutputDir)\%(_SliceCompile.Filename).%(_SliceCompile.SourceExt)'))">
<Output TaskParameter="Value" PropertyName="_SliceCompileGeneratedItems" />
</CreateProperty>

<ItemGroup>
<ClCompile Include="$(_SliceCompileGeneratedItems)"
<ClCompile Include="$(_SliceCompileGeneratedPaths)"
Exclude="@(ClCompile->'%(FullPath)');@(ClCompile->'%(Identity)')" />
</ItemGroup>

Expand Down
15 changes: 6 additions & 9 deletions msbuild/zeroc.icebuilder.msbuild.csharp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@
ItemName = "_SliceCompile"
TaskParameter = "ComputedSources"/>

<Output
PropertyName = "_SliceCompileGeneratedPaths"
TaskParameter = "GeneratedPaths"/>

</Slice2CSharpDependTask>

<!-- Compile the Slice files -->
Expand All @@ -88,18 +92,11 @@
a persistent way. If the extension is not enabled or we are building from the command line we just add the
missing items in a transient way.
First create a property `_SliceCompileGeneratedItems` to hold the paths of all generated items, then we
create a ItemGroup to add a Compile item for each generated item that is not part of the project. Using an
intermediate property for the Compile Include avoids _SliceCompile item metadata being copied to the
generated Compile item.
The builder's depend task has an output property named GeneratedPaths that contains the paths of all generated items.
-->

<CreateProperty Value="$([System.IO.Path]::GetFullPath('%(_SliceCompile.OutputDir)\%(_SliceCompile.Filename).cs'))">
<Output TaskParameter="Value" PropertyName="_SliceCompileGeneratedItems" />
</CreateProperty>

<ItemGroup>
<Compile Include="$(_SliceCompileGeneratedItems)"
<Compile Include="$(_SliceCompileGeneratedPaths)"
Exclude="@(Compile->'%(FullPath)');@(Compile->'%(Identity)')" />
</ItemGroup>
</Target>
Expand Down

0 comments on commit 826b11c

Please sign in to comment.