From 849ef79139a9100fc520d88f88c62a6d9f95865f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Pelletier?= Date: Fri, 13 Sep 2024 11:56:12 -0400 Subject: [PATCH] Improvements for xcode fastbuild projects - Added a new property in Project.Configuration: XCodeFastbuildAppUseNativeProject. This property is used for executables in fastbuild xcode project and is used to force a makefile project for those projects. The side effect of this is you now need to handle yourself all the xcode postbuild steps: the signing, package bundle, etc... - All the fastbuild projects generated with a makefile project will now include source files/headers in projects. Any fastbuild executable project still using native project will not have them or it would cause double compilation of the files and link errors. - project schema for fastbuild project now disable implicit dependencies - Fastbuild Executable project with makefile project now generates a predefined RunnablePath section with the default target executable path. --- .../Apple/XCodeProj.Template.cs | 55 +++++++++++++++---- Sharpmake.Generators/Apple/XCodeProj.cs | 26 +++++++-- Sharpmake/Project.Configuration.cs | 15 +++++ 3 files changed, 79 insertions(+), 17 deletions(-) diff --git a/Sharpmake.Generators/Apple/XCodeProj.Template.cs b/Sharpmake.Generators/Apple/XCodeProj.Template.cs index 7ecf21ee2..5b0155d95 100644 --- a/Sharpmake.Generators/Apple/XCodeProj.Template.cs +++ b/Sharpmake.Generators/Apple/XCodeProj.Template.cs @@ -518,14 +518,48 @@ private static class Template "; - public static string SchemeFileTemplate = + /// + /// This section is used to configure the executable to run for native projects. + /// + public static string SchemeRunnableNativeProject = +@" + + + + "; + + /// + /// This section is used to configure the executable to run for makefile projects. + /// + public static string SchemeRunnableMakeFileProject = +@" + + "; + + /// + /// First part of schema file + /// + /// + /// Schema files have the following format: + /// SchemeFileTemplatePart1 + /// SchemeRunnableNativeProject OR SchemeRunnableMakeFileProject + /// SchemeFileTemplatePart2 + /// + public static string SchemeFileTemplatePart1 = @" + buildImplicitDependencies = ""[buildImplicitDependencies]""> - - - - [commandLineArguments] + allowLocationSimulation = ""YES"">"; + + /// + /// Secondpart of schema file + /// + public static string SchemeFileTemplatePart2 = +@"[commandLineArguments] diff --git a/Sharpmake.Generators/Apple/XCodeProj.cs b/Sharpmake.Generators/Apple/XCodeProj.cs index 7d0e4fc71..1d2721203 100644 --- a/Sharpmake.Generators/Apple/XCodeProj.cs +++ b/Sharpmake.Generators/Apple/XCodeProj.cs @@ -332,6 +332,14 @@ string projectFile var defaultConfiguration = configurations.Where(conf => conf.UseAsDefaultForXCode == true).FirstOrDefault(); Project.Configuration activeConfiguration = defaultConfiguration != null ? defaultConfiguration : configurations[0]; string targetName = $""{activeConfiguration.Target.Name}""; + string buildImplicitDependencies = activeConfiguration.IsFastBuild ? "NO" : "YES"; + bool useBuildableProductRunnableSection = true; + string runnableFilePath = string.Empty; + if (activeConfiguration.IsFastBuild && activeConfiguration.Output == Project.Configuration.OutputType.AppleApp && !activeConfiguration.XcodeUseNativeProjectForFastBuildApp) + { + useBuildableProductRunnableSection = false; + runnableFilePath = Path.Combine(activeConfiguration.TargetPath, activeConfiguration.TargetFileFullNameWithExtension); + } using (fileGenerator.Declare("projectFile", projectFile)) using (fileGenerator.Declare("item", defaultTarget)) @@ -339,8 +347,15 @@ string projectFile using (fileGenerator.Declare("testableElements", testableElements)) using (fileGenerator.Declare("DefaultTarget", targetName)) using (fileGenerator.Declare("commandLineArguments", commandLineArguments)) + using (fileGenerator.Declare("buildImplicitDependencies", buildImplicitDependencies)) + using (fileGenerator.Declare("runnableFilePath", runnableFilePath)) { - fileGenerator.Write(Template.SchemeFileTemplate); + fileGenerator.Write(Template.SchemeFileTemplatePart1); + if (useBuildableProductRunnableSection) + fileGenerator.Write(Template.SchemeRunnableNativeProject); + else + fileGenerator.Write(Template.SchemeRunnableMakeFileProject); + fileGenerator.Write(Template.SchemeFileTemplatePart2); } // Remove all line that contain RemoveLineTag @@ -497,7 +512,8 @@ private void PrepareSections(XCodeGenerationContext context, List + /// This property is used to override default behavior for XCode executable projects + /// configuration compiled using fastbuild. + /// If true(default), it will use a native XCode project to execute fastbuild + /// If false, it will use a makefile project to execute fastbuild. + /// + /// + /// When using the default value, the project will not contain source files. The reason is we can't have source files + /// in the project as otherwise xcode will compile them itself and it will then try to relink the executable with those. + /// This will create unresolved errors. + /// When a native project is used Xcode will handle signing, package creation. These steps must be implemented by yourself if you + /// decide to use a makefile project. However only a makefile project can have source files. + /// + public bool XcodeUseNativeProjectForFastBuildApp { get; set; } = true; + public Strings ResolvedSourceFilesBlobExclude = new Strings(); public Strings ResolvedSourceFilesGenerateXmlDocumentationExclude = new Strings();