diff --git a/Sharpmake.Generators/FastBuild/Bff.cs b/Sharpmake.Generators/FastBuild/Bff.cs index 51ad268ef..f67ddee66 100644 --- a/Sharpmake.Generators/FastBuild/Bff.cs +++ b/Sharpmake.Generators/FastBuild/Bff.cs @@ -585,7 +585,11 @@ List skipFiles postBuildEvents.Add(eventPair.Key, eventPair.Value); } - var extraPlatformEvents = platformBff.GetExtraPostBuildEvents(conf, fastBuildOutputFile).Select(step => { step.Resolve(resolver); return step; }); + var extraPlatformEvents = new List(); + if (!FastBuildSettings.FastBuildSupportLinkerStampList) + extraPlatformEvents.AddRange(platformBff.GetExtraStampEvents(conf, fastBuildOutputFile).Select(step => { step.Resolve(resolver); return step; })); + + extraPlatformEvents.AddRange(platformBff.GetExtraPostBuildEvents(conf, fastBuildOutputFile).Select(step => { step.Resolve(resolver); return step; })); foreach (var buildEvent in extraPlatformEvents.Concat(conf.ResolvedEventPostBuildExe)) { string eventKey = ProjectOptionsGenerator.MakeBuildStepName(conf, buildEvent, Vcxproj.BuildStep.PostBuild, project.RootPath, projectPath); @@ -830,22 +834,29 @@ List skipFiles fastBuildCompilerForceUsing = builderForceUsingFiles.ToString(); } - if (isOutputTypeExeOrDll && (conf.PostBuildStampExe != null || conf.PostBuildStampExes.Any())) + if (isOutputTypeExeOrDll) { - List fastbuildStampExecutableList = new List(); - List fastBuildStampArgumentsList = new List(); + var extraPlatformEvents = new List(); + if (FastBuildSettings.FastBuildSupportLinkerStampList) + extraPlatformEvents.AddRange(platformBff.GetExtraStampEvents(conf, fastBuildOutputFile).Select(step => { step.Resolve(resolver); return step; })); - foreach (var stampExe in conf.PostBuildStampExes.Prepend(conf.PostBuildStampExe).Where(x => x != null)) + if (conf.PostBuildStampExe != null || conf.PostBuildStampExes.Any() || extraPlatformEvents.Any()) { - fastbuildStampExecutableList.Add(CurrentBffPathKeyCombine(Util.PathGetRelative(projectPath, stampExe.ExecutableFile, true))); - fastBuildStampArgumentsList.Add(string.Format("{0} {1} {2}", - stampExe.ExecutableInputFileArgumentOption, - stampExe.ExecutableOutputFileArgumentOption, - stampExe.ExecutableOtherArguments)); - } + var fastbuildStampExecutableList = new List(); + var fastBuildStampArgumentsList = new List(); - fastBuildStampExecutable = UtilityMethods.FBuildFormatList(fastbuildStampExecutableList, 30); - fastBuildStampArguments = UtilityMethods.FBuildFormatList(fastBuildStampArgumentsList, 30); + foreach (var stampExe in extraPlatformEvents.Concat(conf.PostBuildStampExes.Prepend(conf.PostBuildStampExe)).Where(x => x != null)) + { + fastbuildStampExecutableList.Add(CurrentBffPathKeyCombine(Util.PathGetRelative(projectPath, stampExe.ExecutableFile, true))); + fastBuildStampArgumentsList.Add(string.Format("{0} {1} {2}", + stampExe.ExecutableInputFileArgumentOption, + stampExe.ExecutableOutputFileArgumentOption, + stampExe.ExecutableOtherArguments)); + } + + fastBuildStampExecutable = UtilityMethods.FBuildFormatList(fastbuildStampExecutableList, 30); + fastBuildStampArguments = UtilityMethods.FBuildFormatList(fastBuildStampArgumentsList, 30); + } } bool linkObjects = false; diff --git a/Sharpmake.Generators/FastBuild/IPlatformBff.cs b/Sharpmake.Generators/FastBuild/IPlatformBff.cs index 0d29eb954..b5e92dd56 100644 --- a/Sharpmake.Generators/FastBuild/IPlatformBff.cs +++ b/Sharpmake.Generators/FastBuild/IPlatformBff.cs @@ -70,6 +70,14 @@ public interface IPlatformBff /// The list of post build step to execute. IEnumerable GetExtraPostBuildEvents(Project.Configuration configuration, string fastBuildOutputFile); + /// + /// Get the extra list of stamp steps to execute for this platform. + /// + /// The project configuration + /// The file name of the build output. + /// The list of stamp step to execute. + IEnumerable GetExtraStampEvents(Project.Configuration configuration, string fastBuildOutputFile); + /// /// Get the linker output name for this platform. /// diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Apple/BaseApplePlatform.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Apple/BaseApplePlatform.cs index f54581b34..5ad46b505 100644 --- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Apple/BaseApplePlatform.cs +++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Apple/BaseApplePlatform.cs @@ -157,6 +157,11 @@ public IEnumerable GetExtraPostBuildEvents( return Enumerable.Empty(); } + public IEnumerable GetExtraStampEvents(Project.Configuration configuration, string fastBuildOutputFile) + { + return Enumerable.Empty(); + } + public string GetOutputFilename(Project.Configuration.OutputType outputType, string fastBuildOutputFile) => fastBuildOutputFile; public void AddCompilerSettings(IDictionary masterCompilerSettings, Project.Configuration conf) diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BasePlatform.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BasePlatform.cs index dc9da11b8..08c22ba78 100644 --- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BasePlatform.cs +++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BasePlatform.cs @@ -123,6 +123,11 @@ public virtual IEnumerable GetExtraPostBuil return Enumerable.Empty(); } + public virtual IEnumerable GetExtraStampEvents(Project.Configuration configuration, string fastBuildOutputFile) + { + return Enumerable.Empty(); + } + public virtual string GetOutputFilename(Project.Configuration.OutputType outputType, string fastBuildOutputFile) => fastBuildOutputFile; public virtual void AddCompilerSettings(IDictionary masterCompilerSettings, Project.Configuration conf) diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Linux/LinuxPlatform.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Linux/LinuxPlatform.cs index bb4b030d1..b585a9991 100644 --- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Linux/LinuxPlatform.cs +++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Linux/LinuxPlatform.cs @@ -459,7 +459,31 @@ public override void SetupExtraLinkerSettings(IFileGenerator fileGenerator, Proj } } + public override IEnumerable GetExtraStampEvents(Project.Configuration configuration, string fastBuildOutputFile) + { + if (FastBuildSettings.FastBuildSupportLinkerStampList) + { + foreach (var step in GetStripDebugSymbolsSteps(configuration, asStampSteps: true)) + yield return step; + } + } + public override IEnumerable GetExtraPostBuildEvents(Project.Configuration configuration, string fastBuildOutputFile) + { + if (!FastBuildSettings.FastBuildSupportLinkerStampList) + { + foreach (var step in GetStripDebugSymbolsSteps(configuration, asStampSteps: false)) + yield return step; + } + } + + /// + /// Get the list of steps (if any), to strip the exe/dll from debug symbols for FastBuild + /// + /// The configuration + /// Indicates if those steps are post build or stamp, the latter being more efficient + /// The list of steps + private IEnumerable GetStripDebugSymbolsSteps(Project.Configuration configuration, bool asStampSteps) { if (configuration.Output == Project.Configuration.OutputType.Exe || configuration.Output == Project.Configuration.OutputType.Dll) { @@ -482,8 +506,8 @@ public override IEnumerable GetExtraPostBui string objCopySentinelFile = @"[conf.IntermediatePath]\" + fileFullname + ".extracted"; yield return new Project.Configuration.BuildStepExecutable( Path.Combine(binPath, GlobalSettings.UseLlvmObjCopy ? "llvm-objcopy.exe" : "objcopy.exe"), - targetFileFullPath, - objCopySentinelFile, + asStampSteps ? string.Empty : targetFileFullPath, + asStampSteps ? string.Empty : objCopySentinelFile, string.Join(" ", "--only-keep-debug", targetFileFullPath, @@ -495,8 +519,8 @@ public override IEnumerable GetExtraPostBui string strippedSentinelFile = @"[conf.IntermediatePath]\" + fileFullname + ".stripped"; yield return new Project.Configuration.BuildStepExecutable( Path.Combine(binPath, GlobalSettings.UseLlvmObjCopy ? "llvm-objcopy.exe" : "strip.exe"), - objCopySentinelFile, - strippedSentinelFile, + asStampSteps ? string.Empty : objCopySentinelFile, + asStampSteps ? string.Empty : strippedSentinelFile, string.Join(" ", "--strip-debug", "--strip-unneeded", @@ -508,8 +532,8 @@ public override IEnumerable GetExtraPostBui string linkedSentinelFile = @"[conf.IntermediatePath]\" + fileFullname + ".linked"; yield return new Project.Configuration.BuildStepExecutable( Path.Combine(binPath, GlobalSettings.UseLlvmObjCopy ? "llvm-objcopy.exe" : "objcopy.exe"), - strippedSentinelFile, - linkedSentinelFile, + asStampSteps ? string.Empty : strippedSentinelFile, + asStampSteps ? string.Empty : linkedSentinelFile, string.Join(" ", $@"--add-gnu-debuglink=""{targetDebugFileFullPath}""", targetFileFullPath diff --git a/Sharpmake/FastBuildSettings.cs b/Sharpmake/FastBuildSettings.cs index 529d51993..8158c6184 100644 --- a/Sharpmake/FastBuildSettings.cs +++ b/Sharpmake/FastBuildSettings.cs @@ -101,6 +101,11 @@ public enum CacheTypes public static bool FastBuildNoUnity = false; public static bool FastBuildValidateCopyFiles = true; + /// + /// Controls whether FastBuild supports a list of LinkerStamp steps + /// + public static bool FastBuildSupportLinkerStampList = false; + /// /// Allows retention of build state across BFF changes. Requires v0.97 ///