Skip to content

Commit

Permalink
Merge pull request #260 from Unity-Technologies/add-keep-native-symbols
Browse files Browse the repository at this point in the history
Added --keep-native-symbols cmdline option
  • Loading branch information
joncham committed Mar 22, 2024
2 parents 698c777 + e03b3d8 commit f5cc7e8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions unity/CITools/BuildDriver/CoreCLR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static string ToSubSetString(this BuildTargets targets)
return subsets.AggregateWith("+");
}

public static void Build(GlobalConfig gConfig, BuildTargets buildTargets)
public static void Build(GlobalConfig gConfig, BuildTargets buildTargets, bool keepNativeSymbols)
{
Console.WriteLine("******************************");
Console.WriteLine("Unity: Building CoreCLR runtime");
Expand All @@ -49,7 +49,7 @@ public static void Build(GlobalConfig gConfig, BuildTargets buildTargets)
args.Add($"-ninja{crossbuild}");
}

if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
if (keepNativeSymbols && RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
// The default build uses `dsymutil --flat`, which generates .dwarf files that are
// not automatically picked up by anything. Standard .dSYM are a pain to deal with.
Expand Down
18 changes: 16 additions & 2 deletions unity/CITools/BuildDriver/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,18 @@ public static int Main(string[] args)
}
});

var keepNativeSymbols = new Option<bool>("--keep-native-symbols")
{
DefaultValueFactory = (_) => !RunningOnYamato(),
Description = "Do not strip binaries and keep native symbols",
};
keepNativeSymbols.Validators.Add(result =>
{
bool val = result.GetValue(keepNativeSymbols);
if (val && RunningOnYamato())
result.AddError($"Yamato builds must strip binaries and {keepNativeSymbols.Name} must not be used");
});

RootCommand rootCommand = new RootCommand("Unity CoreCLR Builder")
{
buildOption,
Expand All @@ -119,7 +131,8 @@ public static int Main(string[] args)
configurationOption,
verbosityOption,
zipOption,
deployToPlayer
deployToPlayer,
keepNativeSymbols
};
rootCommand.SetAction(Run);

Expand All @@ -133,6 +146,7 @@ void Run(InvocationContext context)
string? architecture = context.ParseResult.GetValue(architectureOption);
string? configuration = context.ParseResult.GetValue(configurationOption);
string? deployToProjectPath = context.ParseResult.GetValue(deployToPlayer);
bool keepSymbols = context.ParseResult.GetValue(keepNativeSymbols);

if (bTargets == BuildTargets.None && tTargets == TestTargets.None && string.IsNullOrEmpty(deployToProjectPath))
bTargets = BuildTargets.All;
Expand All @@ -159,7 +173,7 @@ void Run(InvocationContext context)
if (bTargets != BuildTargets.None)
{
if (bTargets.HasFlag(BuildTargets.Runtime) || bTargets.HasFlag(BuildTargets.ClassLibs))
CoreCLR.Build(gConfig, bTargets);
CoreCLR.Build(gConfig, bTargets, keepSymbols);

// TODO: Switch to using Embedding Host build to perform the copy instead of this once that lands.
NPath artifacts = Artifacts.ConsolidateArtifacts(gConfig);
Expand Down

0 comments on commit f5cc7e8

Please sign in to comment.