Skip to content

Commit

Permalink
Replace GeneratedPaths with GeneratedCompiledPaths
Browse files Browse the repository at this point in the history
The new property only include the paths of generated items that need to
be compiled, for example it excludes the C++ generated headers.
  • Loading branch information
pepone committed Jan 18, 2021
1 parent 826b11c commit a0b5354
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
31 changes: 27 additions & 4 deletions Tasks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ public ITaskItem[] ComputedSources
}

[Output]
public string[] GeneratedPaths
public string[] GeneratedCompiledPaths
{
get;
private set;
Expand All @@ -682,6 +682,10 @@ protected abstract string ToolName

abstract protected ITaskItem[] GeneratedItems(ITaskItem source);

// Same as generated items but only returns the generated items that need to be compiled
// for example it excludes C++ headers
protected abstract ITaskItem[] GeneratedCompiledItems(ITaskItem source);

protected virtual string GetGeneratedPath(ITaskItem item, string outputDir, string ext)
{
return Path.Combine(outputDir,
Expand Down Expand Up @@ -718,7 +722,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>();
List<string> generatedCompiledPaths = new List<string>();
foreach(ITaskItem source in Sources)
{
bool skip = true;
Expand All @@ -737,7 +741,8 @@ public override bool Execute()
FileInfo generatedInfo = null;
FileInfo dependInfo = null;

generatedPaths.AddRange(generatedItems.Select(item => item.GetMetadata("FullPath")));
generatedCompiledPaths.AddRange(
GeneratedCompiledItems(source).Select(item => item.GetMetadata("FullPath")));
//
// Check if the Slice compiler is older than the source file
//
Expand Down Expand Up @@ -932,7 +937,7 @@ public override bool Execute()
computed.Add(computedSource);
}
ComputedSources = computed.ToArray();
GeneratedPaths = generatedPaths.ToArray();
GeneratedCompiledPaths = generatedCompiledPaths.ToArray();
return true;
}
}
Expand Down Expand Up @@ -990,6 +995,17 @@ protected override ITaskItem[] GeneratedItems(ITaskItem source)
new TaskItem(GetGeneratedPath(source, headerOutputDir, headerExt))
};
}

// Same as generated items but only returns the generated items that need to be compiled
// for example it excludes C++ headers
protected override ITaskItem[] GeneratedCompiledItems(ITaskItem source)
{
var generatedItems = GeneratedItems(source);
return new ITaskItem[]
{
generatedItems[0]
};
}
}

public class Slice2CSharpDependTask : SliceDependTask
Expand All @@ -1002,6 +1018,13 @@ protected override ITaskItem[] GeneratedItems(ITaskItem source)
};
}

// Same as generated items but only returns the generated items that need to be compiled
// for example it excludes C++ headers
protected override ITaskItem[] GeneratedCompiledItems(ITaskItem source)
{
return GeneratedItems(source);
}

protected override string ToolName
{
get
Expand Down
2 changes: 1 addition & 1 deletion msbuild/zeroc.icebuilder.msbuild.cpp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@

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

</Slice2CppDependTask>

Expand Down
2 changes: 1 addition & 1 deletion msbuild/zeroc.icebuilder.msbuild.csharp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@

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

</Slice2CSharpDependTask>

Expand Down

0 comments on commit a0b5354

Please sign in to comment.