Skip to content

Commit

Permalink
[Custom Build Steps] Fixes to get custom build steps working.
Browse files Browse the repository at this point in the history
* Add quotes to executable if it's a single line string that doesn't already have quotes.
* Standardize the path when looking up the build step since it may be lower cased.
  • Loading branch information
kudaba committed Feb 21, 2022
1 parent a0c127e commit 5e7ae00
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 39 deletions.
14 changes: 11 additions & 3 deletions Sharpmake.Generators/VisualStudio/Vcxproj.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,17 @@ public static Dictionary<string, CombinedCustomFileBuildStep> CombineCustomFileB
foreach (var customBuildStep in buildSteps)
{
var relativeBuildStep = customBuildStep.MakePathRelative(resolver, (path, commandRelative) => Util.SimplifyPath(Util.PathGetRelative(referencePath, path)));
relativeBuildStep.AdditionalInputs.Add(relativeBuildStep.Executable);
var executable = relativeBuildStep.Executable;
if (!executable.StartsWith("\"") && !executable.EndsWith("\"") && !executable.Contains("\n"))
{
executable = string.Format("\"{0}\"", executable);
}

relativeBuildStep.AdditionalInputs.Add(executable);
// Build the command.
string command = string.Format(
"{0} {1}",
relativeBuildStep.Executable,
executable,
relativeBuildStep.ExecutableArguments
);

Expand Down Expand Up @@ -1430,10 +1436,12 @@ IList<string> skipFiles
{
fileGenerator.Write(Template.Project.ProjectFilesCustomBuildBegin);

var standardPath = Util.PathMakeStandard(file.FileNameProjectRelative);

foreach (Project.Configuration conf in context.ProjectConfigurations)
{
CombinedCustomFileBuildStep buildStep;
if (configurationCustomFileBuildSteps[conf].TryGetValue(file.FileNameProjectRelative, out buildStep))
if (configurationCustomFileBuildSteps[conf].TryGetValue(standardPath, out buildStep))
{
using (fileGenerator.Declare("conf", conf))
using (fileGenerator.Declare("platformName", Util.GetPlatformString(conf.Platform, conf.Project, conf.Target)))
Expand Down
Loading

0 comments on commit 5e7ae00

Please sign in to comment.