From e6b46388480290a05d3b27de95c771908aea46ab Mon Sep 17 00:00:00 2001 From: Sean Wu Date: Fri, 15 Sep 2023 13:17:37 +0000 Subject: [PATCH] for XCode scheme, Add ArgumentsPassedOnLaunch --- .../Apple/XCodeProj.Template.cs | 17 ++++++++++++++++- Sharpmake.Generators/Apple/XCodeProj.cs | 15 +++++++++++++++ Sharpmake/Options.XCode.cs | 12 ++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/Sharpmake.Generators/Apple/XCodeProj.Template.cs b/Sharpmake.Generators/Apple/XCodeProj.Template.cs index f34b72162..99ecb9586 100644 --- a/Sharpmake.Generators/Apple/XCodeProj.Template.cs +++ b/Sharpmake.Generators/Apple/XCodeProj.Template.cs @@ -481,6 +481,21 @@ private static class Template " } }; + public static string CommandLineArgumentsBegin = +@" + "; + + public static string CommandLineArgument = +@" + + "; + + public static string CommandLineArgumentsEnd = +@" + "; + public static string SchemeTestableReference = @" - + [commandLineArguments] diff --git a/Sharpmake.Generators/Apple/XCodeProj.cs b/Sharpmake.Generators/Apple/XCodeProj.cs index a13a7db66..0203267e8 100644 --- a/Sharpmake.Generators/Apple/XCodeProj.cs +++ b/Sharpmake.Generators/Apple/XCodeProj.cs @@ -270,6 +270,20 @@ string projectFile } } + // Build commandLineArguments + var debugArguments = Options.GetObject(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(); @@ -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); } diff --git a/Sharpmake/Options.XCode.cs b/Sharpmake/Options.XCode.cs index 07d17467b..a515283f6 100644 --- a/Sharpmake/Options.XCode.cs +++ b/Sharpmake/Options.XCode.cs @@ -1148,6 +1148,18 @@ public enum MetalAPIValidation Enable, Disable } + + /// + /// Resolve to in xcscheme, + /// for configuring 'Arguments Passed On Launch' as 'Edit Scheme' in XCode can do + /// + public class DebugArguments: List + { + public DebugArguments(List args) + : base(args) + { + } + } } } }