Add build option to change code optimization level in C# modules
This commit is contained in:
@@ -255,11 +255,13 @@ namespace Flax.Build
|
|||||||
#endif
|
#endif
|
||||||
if (buildOptions.ScriptingAPI.IgnoreMissingDocumentationWarnings)
|
if (buildOptions.ScriptingAPI.IgnoreMissingDocumentationWarnings)
|
||||||
args.Add("-nowarn:1591");
|
args.Add("-nowarn:1591");
|
||||||
#if USE_NETCORE
|
|
||||||
// Optimizations prevent debugging, only enable in release builds
|
// Optimizations prevent debugging, only enable in release builds
|
||||||
args.Add(buildData.Configuration == TargetConfiguration.Release ? "/optimize+" : "/optimize-");
|
var optimize = buildData.Configuration == TargetConfiguration.Release;
|
||||||
#else
|
if (buildData.TargetOptions.ScriptingAPI.Optimization.HasValue)
|
||||||
args.Add(buildData.Configuration == TargetConfiguration.Debug ? "/optimize-" : "/optimize+");
|
optimize = buildData.TargetOptions.ScriptingAPI.Optimization.Value;
|
||||||
|
args.Add(optimize ? "/optimize+" : "/optimize-");
|
||||||
|
#if !USE_NETCORE
|
||||||
args.Add(string.Format("/reference:\"{0}mscorlib.dll\"", referenceAssemblies));
|
args.Add(string.Format("/reference:\"{0}mscorlib.dll\"", referenceAssemblies));
|
||||||
#endif
|
#endif
|
||||||
args.Add(string.Format("/out:\"{0}\"", outputFile));
|
args.Add(string.Format("/out:\"{0}\"", outputFile));
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ namespace Flax.Build.NativeCpp
|
|||||||
public string DepsFolder => Path.Combine(Globals.EngineRoot, "Source", "Platforms", Platform.Target.ToString(), "Binaries", "ThirdParty", Architecture.ToString());
|
public string DepsFolder => Path.Combine(Globals.EngineRoot, "Source", "Platforms", Platform.Target.ToString(), "Binaries", "ThirdParty", Architecture.ToString());
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The scripting API building options.
|
/// The C# scripting API building options.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public struct ScriptingAPIOptions
|
public struct ScriptingAPIOptions
|
||||||
{
|
{
|
||||||
@@ -224,6 +224,11 @@ namespace Flax.Build.NativeCpp
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public CSharpNullableReferences CSharpNullableReferences = CSharpNullableReferences.Disable;
|
public CSharpNullableReferences CSharpNullableReferences = CSharpNullableReferences.Disable;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enable code optimization.
|
||||||
|
/// </summary>
|
||||||
|
public bool? Optimization;
|
||||||
|
|
||||||
public ScriptingAPIOptions()
|
public ScriptingAPIOptions()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -232,13 +237,19 @@ namespace Flax.Build.NativeCpp
|
|||||||
/// Adds the other options into this.
|
/// Adds the other options into this.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="other">The other.</param>
|
/// <param name="other">The other.</param>
|
||||||
public void Add(ScriptingAPIOptions other)
|
public void Add(ScriptingAPIOptions other, bool addBuildOptions = true)
|
||||||
{
|
{
|
||||||
Defines.AddRange(other.Defines);
|
Defines.AddRange(other.Defines);
|
||||||
SystemReferences.AddRange(other.SystemReferences);
|
SystemReferences.AddRange(other.SystemReferences);
|
||||||
FileReferences.AddRange(other.FileReferences);
|
FileReferences.AddRange(other.FileReferences);
|
||||||
Analyzers.AddRange(other.Analyzers);
|
Analyzers.AddRange(other.Analyzers);
|
||||||
IgnoreMissingDocumentationWarnings |= other.IgnoreMissingDocumentationWarnings;
|
IgnoreMissingDocumentationWarnings |= other.IgnoreMissingDocumentationWarnings;
|
||||||
|
|
||||||
|
if (addBuildOptions)
|
||||||
|
{
|
||||||
|
if (other.Optimization.HasValue)
|
||||||
|
Optimization |= other.Optimization;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -403,7 +403,7 @@ namespace Flax.Build
|
|||||||
moduleOptions.PrivateIncludePaths.AddRange(dependencyOptions.PublicIncludePaths);
|
moduleOptions.PrivateIncludePaths.AddRange(dependencyOptions.PublicIncludePaths);
|
||||||
moduleOptions.Libraries.AddRange(dependencyOptions.Libraries);
|
moduleOptions.Libraries.AddRange(dependencyOptions.Libraries);
|
||||||
moduleOptions.DelayLoadLibraries.AddRange(dependencyOptions.DelayLoadLibraries);
|
moduleOptions.DelayLoadLibraries.AddRange(dependencyOptions.DelayLoadLibraries);
|
||||||
moduleOptions.ScriptingAPI.Add(dependencyOptions.ScriptingAPI);
|
moduleOptions.ScriptingAPI.Add(dependencyOptions.ScriptingAPI, false);
|
||||||
moduleOptions.ExternalModules.AddRange(dependencyOptions.ExternalModules);
|
moduleOptions.ExternalModules.AddRange(dependencyOptions.ExternalModules);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -418,7 +418,7 @@ namespace Flax.Build
|
|||||||
moduleOptions.PublicIncludePaths.AddRange(dependencyOptions.PublicIncludePaths);
|
moduleOptions.PublicIncludePaths.AddRange(dependencyOptions.PublicIncludePaths);
|
||||||
moduleOptions.Libraries.AddRange(dependencyOptions.Libraries);
|
moduleOptions.Libraries.AddRange(dependencyOptions.Libraries);
|
||||||
moduleOptions.DelayLoadLibraries.AddRange(dependencyOptions.DelayLoadLibraries);
|
moduleOptions.DelayLoadLibraries.AddRange(dependencyOptions.DelayLoadLibraries);
|
||||||
moduleOptions.ScriptingAPI.Add(dependencyOptions.ScriptingAPI);
|
moduleOptions.ScriptingAPI.Add(dependencyOptions.ScriptingAPI, false);
|
||||||
moduleOptions.ExternalModules.AddRange(dependencyOptions.ExternalModules);
|
moduleOptions.ExternalModules.AddRange(dependencyOptions.ExternalModules);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user