Skip to content

Commit

Permalink
for XCode scheme, Add ArgumentsPassedOnLaunch
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanWuXiaoYong authored and jspelletier committed Sep 15, 2023
1 parent b722b4a commit e6b4638
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Sharpmake.Generators/Apple/XCodeProj.Template.cs
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,21 @@ private static class Template
" }
};

public static string CommandLineArgumentsBegin =
@"
<CommandLineArguments>";

public static string CommandLineArgument =
@"
<CommandLineArgument
argument = ""[argument]""
isEnabled = ""YES"">
</CommandLineArgument>";

public static string CommandLineArgumentsEnd =
@"
</CommandLineArguments>";

public static string SchemeTestableReference =
@"
<TestableReference
Expand Down Expand Up @@ -546,7 +561,7 @@ private static class Template
BlueprintName = ""[item.Identifier]""
ReferencedContainer = ""container:[projectFile].xcodeproj"">
</BuildableReference>
</BuildableProductRunnable>
</BuildableProductRunnable>[commandLineArguments]
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
Expand Down
15 changes: 15 additions & 0 deletions Sharpmake.Generators/Apple/XCodeProj.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,20 @@ string projectFile
}
}

// Build commandLineArguments
var debugArguments = Options.GetObject<Options.XCode.Scheme.DebugArguments>(configurations[0]);
var commandLineArguments = new StringBuilder();
if (debugArguments != null)
{
commandLineArguments.Append(Template.CommandLineArgumentsBegin);
foreach(var argument in debugArguments)
{
using (fileGenerator.Declare("argument", argument))
commandLineArguments.Append(fileGenerator.Resolver.Resolve(Template.CommandLineArgument));
}
commandLineArguments.Append(Template.CommandLineArgumentsEnd);
}

// Write the scheme file
var defaultTarget = _nativeOrLegacyTargets.Values.Where(target => target.OutputFile.OutputType != Project.Configuration.OutputType.IosTestBundle).FirstOrDefault();

Expand All @@ -296,6 +310,7 @@ string projectFile
using (fileGenerator.Declare("options", options))
using (fileGenerator.Declare("testableElements", testableElements))
using (fileGenerator.Declare("DefaultTarget", targetName))
using (fileGenerator.Declare("commandLineArguments", commandLineArguments))
{
fileGenerator.Write(Template.SchemeFileTemplate);
}
Expand Down
12 changes: 12 additions & 0 deletions Sharpmake/Options.XCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,18 @@ public enum MetalAPIValidation
Enable,
Disable
}

/// <summary>
/// Resolve to <CommandLineArguments> in xcscheme,
/// for configuring 'Arguments Passed On Launch' as 'Edit Scheme' in XCode can do
/// </summary>
public class DebugArguments: List<string>
{
public DebugArguments(List<string> args)
: base(args)
{
}
}
}
}
}
Expand Down

0 comments on commit e6b4638

Please sign in to comment.