Skip to content

Commit

Permalink
Added support for OutputItemType to CustomFileBuildStep. (#345)
Browse files Browse the repository at this point in the history
* Added support for OutputItemType to CustomFileBuildStep.
This (optionally) allows for specifying to Vcxproj what the output files of a custom build step should be treated as. Useful in contexts where a custom build step generates other build inputs.

* Switch to RemoveLineTag instead of using an if to output the OutputItemType tag in Vcx generator

* Extended comment on OutputItemType field of CustomFileBuildStep data to note that it is not supported by FASTBuild
  • Loading branch information
cfehunter authored Mar 15, 2024
1 parent 966e5d7 commit b890493
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Sharpmake.Generators/VisualStudio/Vcxproj.Template.cs
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,10 @@ public static class Project

public static string ProjectFilesCustomBuildLinkObject =
@" <LinkObjects Condition=""'$(Configuration)|$(Platform)'=='[conf.Name]|[platformName]'"">[linkobjects]</LinkObjects>
";

public static string ProjectFilesCustomBuildOutputItemType =
@" <OutputItemType>[outputItemType]</OutputItemType>
";

public static string ProjectFilesCustomBuildEnd =
Expand Down
8 changes: 7 additions & 1 deletion Sharpmake.Generators/VisualStudio/Vcxproj.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ public class CombinedCustomFileBuildStep
public string Description = "";
public string Outputs = "";
public string AdditionalInputs = "";
public string OutputItemType = "";
};

public static Dictionary<string, CombinedCustomFileBuildStep> CombineCustomFileBuildSteps(string referencePath, Resolver resolver, IEnumerable<Project.Configuration.CustomFileBuildStep> buildSteps)
Expand All @@ -174,7 +175,7 @@ public static Dictionary<string, CombinedCustomFileBuildStep> CombineCustomFileB
foreach (var customBuildStep in buildSteps)
{
var relativeBuildStep = customBuildStep.MakePathRelative(resolver, (path, commandRelative) => Util.SimplifyPath(Util.PathGetRelative(referencePath, path)));
if(!customBuildStep.UseExecutableFromSystemPath)
if (!customBuildStep.UseExecutableFromSystemPath)
{
relativeBuildStep.AdditionalInputs.Add(relativeBuildStep.Executable);
}
Expand Down Expand Up @@ -205,6 +206,9 @@ public static Dictionary<string, CombinedCustomFileBuildStep> CombineCustomFileB
combinedCustomBuildStep.Description += relativeBuildStep.Description;
combinedCustomBuildStep.Outputs = Util.EscapeXml(relativeBuildStep.Output);
combinedCustomBuildStep.AdditionalInputs = Util.EscapeXml(relativeBuildStep.AdditionalInputs.JoinStrings(";"));

//Vcxproj only allows specifying one output item type per build command
combinedCustomBuildStep.OutputItemType = customBuildStep.OutputItemType;
}

return steps;
Expand Down Expand Up @@ -1532,11 +1536,13 @@ IList<string> skipFiles
using (fileGenerator.Declare("command", buildStep.Commands))
using (fileGenerator.Declare("inputs", buildStep.AdditionalInputs))
using (fileGenerator.Declare("outputs", buildStep.Outputs))
using (fileGenerator.Declare("outputItemType", string.IsNullOrEmpty(buildStep.OutputItemType) ? FileGeneratorUtilities.RemoveLineTag : buildStep.OutputItemType))
{
fileGenerator.Write(Template.Project.ProjectFilesCustomBuildDescription);
fileGenerator.Write(Template.Project.ProjectFilesCustomBuildCommand);
fileGenerator.Write(Template.Project.ProjectFilesCustomBuildInputs);
fileGenerator.Write(Template.Project.ProjectFilesCustomBuildOutputs);
fileGenerator.Write(Template.Project.ProjectFilesCustomBuildOutputItemType);
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions Sharpmake/Project.Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2229,6 +2229,13 @@ public enum ProjectFilter
/// This is what we tell the build system we're going to produce.
/// </summary>
public string Output = "";

/// <summary>
/// Not supported by FASTBuild.
/// Optional string to hint to the build system at what to treat the output from the build command as
/// </summary>
public string OutputItemType = "";

/// <summary>
/// Not supported by FASTBuild.
/// Additional files that will cause a re-run of this custom build step can be be specified here.
Expand Down

0 comments on commit b890493

Please sign in to comment.