Skip to content

Commit

Permalink
Merge branch 'xcode-default-build-config' into 'main'
Browse files Browse the repository at this point in the history
Add an option to set the default XCode build configuration from a sharpmake script

See merge request Sharpmake/sharpmake!439
  • Loading branch information
jspelletier committed Sep 13, 2023
2 parents 490f9ea + d8e9b4e commit 23e9294
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
10 changes: 5 additions & 5 deletions Sharpmake.Generators/Apple/XCodeProj.Template.cs
Original file line number Diff line number Diff line change
Expand Up @@ -520,15 +520,15 @@ private static class Template
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = ""[optimization]""
buildConfiguration = ""[DefaultTarget]""
selectedDebuggerIdentifier = ""Xcode.DebuggerFoundation.Debugger.LLDB""
selectedLauncherIdentifier = ""Xcode.DebuggerFoundation.Launcher.LLDB""
shouldUseLaunchSchemeArgsEnv = ""YES"">
<Testables>[testableElements]
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = ""[optimization]""
buildConfiguration = ""[DefaultTarget]""
selectedDebuggerIdentifier = ""Xcode.DebuggerFoundation.Debugger.LLDB""
selectedLauncherIdentifier = ""Xcode.DebuggerFoundation.Launcher.LLDB""
launchStyle = ""0""
Expand All @@ -551,17 +551,17 @@ private static class Template
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = ""[optimization]""
buildConfiguration = ""[DefaultTarget]""
shouldUseLaunchSchemeArgsEnv = ""YES""
savedToolIdentifier = """"
useCustomWorkingDirectory = ""NO""
debugDocumentVersioning = ""YES"">
</ProfileAction>
<AnalyzeAction
buildConfiguration = ""[optimization]"">
buildConfiguration = ""[DefaultTarget]"">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = ""[optimization]""
buildConfiguration = ""[DefaultTarget]""
revealArchiveInOrganizer = ""YES"">
</ArchiveAction>
</Scheme>
Expand Down
6 changes: 5 additions & 1 deletion Sharpmake.Generators/Apple/XCodeProj.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,15 @@ string projectFile
Options.Option(Options.XCode.Scheme.MetalAPIValidation.Disable, () => options["MetalAPIValidation"] = "1")
);

var defaultConfiguration = configurations.Where(conf => conf.UseAsDefaultForXCode == true).FirstOrDefault();
Project.Configuration activeConfiguration = defaultConfiguration != null ? defaultConfiguration : configurations[0];
string targetName = $"&quot;{activeConfiguration.Target.Name}&quot;";

using (fileGenerator.Declare("projectFile", projectFile))
using (fileGenerator.Declare("item", defaultTarget))
using (fileGenerator.Declare("options", options))
using (fileGenerator.Declare("testableElements", testableElements))
using (fileGenerator.Declare("optimization", configurations[0].Target.Name))
using (fileGenerator.Declare("DefaultTarget", targetName))
{
fileGenerator.Write(Template.SchemeFileTemplate);
}
Expand Down
4 changes: 4 additions & 0 deletions Sharpmake/Project.Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2348,6 +2348,10 @@ public string TargetFileExtension
set { }
}

/// <summary>
/// Mark the configuration to be the default build configuration for XCode project
/// </summary>
public bool UseAsDefaultForXCode = false;

// FastBuild configuration
/// <summary>
Expand Down

0 comments on commit 23e9294

Please sign in to comment.