Update Flax deployment scripts for dotnet7
This commit is contained in:
@@ -157,79 +157,60 @@ namespace Flax.Build
|
||||
var outputPath = Path.GetDirectoryName(buildData.Target.GetOutputFilePath(buildOptions));
|
||||
var outputFile = Path.Combine(outputPath, name + ".dll");
|
||||
var outputDocFile = Path.Combine(outputPath, name + ".xml");
|
||||
string monoRoot, monoPath = null, cscPath, referenceAssemblies, referenceAnalyzers, dotnetPath = "dotnet";
|
||||
string cscPath, referenceAssemblies;
|
||||
#if USE_NETCORE
|
||||
var dotnetSdk = DotNetSdk.Instance;
|
||||
if (!dotnetSdk.IsValid)
|
||||
throw new Exception("Cannot compile C# without .NET SDK");
|
||||
string dotnetPath = "dotnet", referenceAnalyzers;
|
||||
#else
|
||||
string monoRoot, monoPath;
|
||||
#endif
|
||||
switch (buildPlatform)
|
||||
{
|
||||
case TargetPlatform.Windows:
|
||||
{
|
||||
monoRoot = Path.Combine(Globals.EngineRoot, "Source", "Platforms", "Editor", "Windows", "Mono");
|
||||
|
||||
// Prefer installed Roslyn C# compiler over Mono one
|
||||
cscPath = Path.Combine(Path.GetDirectoryName(VCEnvironment.MSBuildPath), "Roslyn", "csc.exe");
|
||||
|
||||
#if USE_NETCORE
|
||||
var dotnetSdk = DotNetSdk.Instance;
|
||||
if (dotnetSdk.IsValid)
|
||||
{
|
||||
// Use dotnet
|
||||
dotnetPath = Path.Combine(dotnetSdk.RootPath, "dotnet.exe");
|
||||
cscPath = Path.Combine(dotnetSdk.RootPath, @$"sdk\{dotnetSdk.VersionName}\Roslyn\bincore\csc.dll");
|
||||
referenceAssemblies = Path.Combine(dotnetSdk.RootPath, @$"shared\Microsoft.NETCore.App\{dotnetSdk.RuntimeVersionName}\");
|
||||
referenceAnalyzers = Path.Combine(dotnetSdk.RootPath, @$"packs\Microsoft.NETCore.App.Ref\{dotnetSdk.RuntimeVersionName}\analyzers\dotnet\cs\");
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// Fallback to Mono binaries
|
||||
#else
|
||||
monoRoot = Path.Combine(Globals.EngineRoot, "Source", "Platforms", "Editor", "Windows", "Mono");
|
||||
monoPath = Path.Combine(monoRoot, "bin", "mono.exe");
|
||||
cscPath = Path.Combine(Path.GetDirectoryName(VCEnvironment.MSBuildPath), "Roslyn", "csc.exe");
|
||||
if (!File.Exists(cscPath))
|
||||
cscPath = Path.Combine(monoRoot, "lib", "mono", "4.5", "csc.exe");
|
||||
referenceAssemblies = Path.Combine(monoRoot, "lib", "mono", "4.5-api");
|
||||
referenceAnalyzers = "";
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case TargetPlatform.Linux:
|
||||
{
|
||||
#if USE_NETCORE
|
||||
var dotnetSdk = DotNetSdk.Instance;
|
||||
if (dotnetSdk.IsValid)
|
||||
{
|
||||
// Use dotnet
|
||||
cscPath = Path.Combine(dotnetSdk.RootPath, $"sdk/{dotnetSdk.VersionName}/Roslyn/bincore/csc.dll");
|
||||
referenceAssemblies = Path.Combine(dotnetSdk.RootPath, $"shared/Microsoft.NETCore.App/{dotnetSdk.RuntimeVersionName}/");
|
||||
referenceAnalyzers = Path.Combine(dotnetSdk.RootPath, $"packs/Microsoft.NETCore.App.Ref/{dotnetSdk.RuntimeVersionName}/analyzers/dotnet/cs/");
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#else
|
||||
monoRoot = Path.Combine(Globals.EngineRoot, "Source", "Platforms", "Editor", "Linux", "Mono");
|
||||
monoPath = Path.Combine(monoRoot, "bin", "mono");
|
||||
cscPath = Path.Combine(monoRoot, "lib", "mono", "4.5", "csc.exe");
|
||||
referenceAssemblies = Path.Combine(monoRoot, "lib", "mono", "4.5-api");
|
||||
referenceAnalyzers = "";
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case TargetPlatform.Mac:
|
||||
{
|
||||
#if USE_NETCORE
|
||||
var dotnetSdk = DotNetSdk.Instance;
|
||||
if (dotnetSdk.IsValid)
|
||||
{
|
||||
// Use dotnet
|
||||
cscPath = Path.Combine(dotnetSdk.RootPath, $"sdk/{dotnetSdk.VersionName}/Roslyn/bincore/csc.dll");
|
||||
referenceAssemblies = Path.Combine(dotnetSdk.RootPath, $"shared/Microsoft.NETCore.App/{dotnetSdk.RuntimeVersionName}/");
|
||||
referenceAnalyzers = Path.Combine(dotnetSdk.RootPath, $"packs/Microsoft.NETCore.App.Ref/{dotnetSdk.RuntimeVersionName}/analyzers/dotnet/cs/");
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#else
|
||||
monoRoot = Path.Combine(Globals.EngineRoot, "Source", "Platforms", "Editor", "Mac", "Mono");
|
||||
monoPath = Path.Combine(monoRoot, "bin", "mono");
|
||||
cscPath = Path.Combine(monoRoot, "lib", "mono", "4.5", "csc.exe");
|
||||
referenceAssemblies = Path.Combine(monoRoot, "lib", "mono", "4.5-api");
|
||||
referenceAnalyzers = "";
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
default: throw new InvalidPlatformException(buildPlatform);
|
||||
@@ -305,6 +286,12 @@ namespace Flax.Build
|
||||
task.InfoMessage = "Compiling " + outputFile;
|
||||
task.Cost = task.PrerequisiteFiles.Count;
|
||||
|
||||
// The "/shared" flag enables the compiler server support:
|
||||
// https://github.com/dotnet/roslyn/blob/main/docs/compilers/Compiler%20Server.md
|
||||
#if USE_NETCORE
|
||||
task.CommandPath = dotnetPath;
|
||||
task.CommandArguments = $"exec \"{cscPath}\" /noconfig /shared @\"{responseFile}\"";
|
||||
#else
|
||||
if (monoPath != null)
|
||||
{
|
||||
task.CommandPath = monoPath;
|
||||
@@ -312,17 +299,10 @@ namespace Flax.Build
|
||||
}
|
||||
else
|
||||
{
|
||||
// The "/shared" flag enables the compiler server support:
|
||||
// https://github.com/dotnet/roslyn/blob/main/docs/compilers/Compiler%20Server.md
|
||||
|
||||
#if USE_NETCORE
|
||||
task.CommandPath = dotnetPath;
|
||||
task.CommandArguments = $"exec \"{cscPath}\" /noconfig /shared @\"{responseFile}\"";
|
||||
#else
|
||||
task.CommandPath = cscPath;
|
||||
task.CommandArguments = $"/noconfig /shared @\"{responseFile}\"";
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
BuildDotNetAssembly?.Invoke(graph, buildData, buildOptions, task, binaryModule);
|
||||
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
|
||||
|
||||
namespace Flax.Build
|
||||
{
|
||||
public static partial class Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// Package deployment output path.
|
||||
/// </summary>
|
||||
[CommandLine("deployOutput", "Package deployment output path.")]
|
||||
public static string DeployOutput;
|
||||
|
||||
/// <summary>
|
||||
/// Builds and packages the editor.
|
||||
/// </summary>
|
||||
[CommandLine("deployEditor", "Builds and packages the editor.")]
|
||||
public static bool DeployEditor;
|
||||
|
||||
/// <summary>
|
||||
/// Builds and packages the platforms data.
|
||||
/// </summary>
|
||||
[CommandLine("deployPlatforms", "Builds and packages the platforms data.")]
|
||||
public static bool DeployPlatforms;
|
||||
|
||||
/// <summary>
|
||||
/// Certificate file path for binaries signing.
|
||||
/// </summary>
|
||||
[CommandLine("deployCert", "Certificate file path for binaries signing.")]
|
||||
public static string DeployCert;
|
||||
|
||||
/// <summary>
|
||||
/// Certificate file password for binaries signing.
|
||||
/// </summary>
|
||||
[CommandLine("deployCertPass", "Certificate file password for binaries signing.")]
|
||||
public static string DeployCertPass;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,42 @@ using System.IO;
|
||||
using System.Text;
|
||||
using Flax.Build;
|
||||
|
||||
namespace Flax.Build
|
||||
{
|
||||
public static partial class Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// Package deployment output path.
|
||||
/// </summary>
|
||||
[CommandLine("deployOutput", "Package deployment output path.")]
|
||||
public static string DeployOutput;
|
||||
|
||||
/// <summary>
|
||||
/// Builds and packages the editor.
|
||||
/// </summary>
|
||||
[CommandLine("deployEditor", "Builds and packages the editor.")]
|
||||
public static bool DeployEditor;
|
||||
|
||||
/// <summary>
|
||||
/// Builds and packages the platforms data.
|
||||
/// </summary>
|
||||
[CommandLine("deployPlatforms", "Builds and packages the platforms data.")]
|
||||
public static bool DeployPlatforms;
|
||||
|
||||
/// <summary>
|
||||
/// Certificate file path for binaries signing.
|
||||
/// </summary>
|
||||
[CommandLine("deployCert", "Certificate file path for binaries signing.")]
|
||||
public static string DeployCert;
|
||||
|
||||
/// <summary>
|
||||
/// Certificate file password for binaries signing.
|
||||
/// </summary>
|
||||
[CommandLine("deployCertPass", "Certificate file password for binaries signing.")]
|
||||
public static string DeployCertPass;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Flax.Deploy
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -49,37 +49,33 @@ namespace Flax.Deploy
|
||||
var src = Path.Combine(RootPath, binariesSubDir);
|
||||
var dst = Path.Combine(OutputPath, binariesSubDir);
|
||||
|
||||
DeployFile(src, dst, "Flax.Build.exe");
|
||||
CodeSign(Path.Combine(dst, "Flax.Build.exe"));
|
||||
DeployFile(src, dst, "Flax.Build.xml");
|
||||
var buildToolExe = Platform.BuildTargetPlatform == TargetPlatform.Windows ? "Flax.Build.exe" : "Flax.Build";
|
||||
DeployFile(src, dst, buildToolExe);
|
||||
CodeSign(Path.Combine(dst, buildToolExe));
|
||||
var buildToolDll = "Flax.Build.dll";
|
||||
DeployFile(src, dst,buildToolDll);
|
||||
CodeSign(Path.Combine(dst, buildToolDll));
|
||||
DeployFile(src, dst, "Flax.Build.xml", true);
|
||||
DeployFile(src, dst, "Flax.Build.pdb");
|
||||
DeployFile(src, dst, "Flax.Build.deps.json");
|
||||
DeployFile(src, dst, "Flax.Build.runtimeconfig.json");
|
||||
DeployFile(src, dst, "Ionic.Zip.Reduced.dll");
|
||||
DeployFile(src, dst, "Newtonsoft.Json.dll");
|
||||
DeployFile(src, dst, "Mono.Cecil.dll");
|
||||
DeployFile(src, dst, "Microsoft.CodeAnalysis.dll");
|
||||
DeployFile(src, dst, "Microsoft.CodeAnalysis.CSharp.dll");
|
||||
DeployFile(src, dst, "Microsoft.VisualStudio.Setup.Configuration.Interop.dll");
|
||||
}
|
||||
|
||||
// Deploy content
|
||||
DeployFolder(RootPath, OutputPath, "Content");
|
||||
|
||||
// Deploy Mono runtime data files
|
||||
switch (Platform.BuildTargetPlatform)
|
||||
{
|
||||
case TargetPlatform.Windows:
|
||||
DeployFolder(RootPath, OutputPath, "Source/Platforms/Editor/Windows/Mono");
|
||||
break;
|
||||
case TargetPlatform.Linux:
|
||||
DeployFolder(RootPath, OutputPath, "Source/Platforms/Editor/Linux/Mono");
|
||||
break;
|
||||
case TargetPlatform.Mac:
|
||||
DeployFolder(RootPath, OutputPath, "Source/Platforms/Editor/Mac/Mono");
|
||||
break;
|
||||
default: throw new InvalidPlatformException(Platform.BuildTargetPlatform);
|
||||
}
|
||||
|
||||
// Deploy DotNet deps
|
||||
{
|
||||
var subDir = "Source/Platforms/DotNet";
|
||||
DeployFile(RootPath, OutputPath, subDir, "Newtonsoft.Json.dll");
|
||||
DeployFile(RootPath, OutputPath, subDir, "Newtonsoft.Json.xml");
|
||||
DeployFile(RootPath, OutputPath, Path.Combine(subDir, "AOT"), "Newtonsoft.Json.dll");
|
||||
}
|
||||
|
||||
// Deploy sources
|
||||
@@ -199,6 +195,12 @@ namespace Flax.Deploy
|
||||
var dst = Path.Combine(OutputPath, binariesSubDir);
|
||||
Directory.CreateDirectory(dst);
|
||||
|
||||
DeployFile(src, dst, "FlaxEditor.Build.json");
|
||||
DeployFile(src, dst, "FlaxEngine.CSharp.runtimeconfig.json");
|
||||
DeployFile(src, dst, "FlaxEngine.CSharp.pdb");
|
||||
DeployFile(src, dst, "FlaxEngine.CSharp.xml");
|
||||
DeployFile(src, dst, "Newtonsoft.Json.pdb");
|
||||
|
||||
if (Platform.BuildTargetPlatform == TargetPlatform.Windows)
|
||||
{
|
||||
var dstDebug = Path.Combine(Deployer.PackageOutputPath, "EditorDebugSymbols/Win64/" + configuration);
|
||||
@@ -215,11 +217,7 @@ namespace Flax.Deploy
|
||||
// Deploy binaries
|
||||
DeployFile(src, dst, editorExeName);
|
||||
CodeSign(Path.Combine(dst, editorExeName));
|
||||
DeployFile(src, dst, "FlaxEditor.Build.json");
|
||||
DeployFile(src, dst, "FlaxEditor.lib");
|
||||
DeployFile(src, dst, "FlaxEngine.CSharp.pdb");
|
||||
DeployFile(src, dst, "FlaxEngine.CSharp.xml");
|
||||
DeployFile(src, dst, "Newtonsoft.Json.pdb");
|
||||
DeployFiles(src, dst, "*.dll");
|
||||
CodeSign(Path.Combine(dst, "FlaxEngine.CSharp.dll"));
|
||||
|
||||
@@ -237,10 +235,6 @@ namespace Flax.Deploy
|
||||
{
|
||||
// Deploy binaries
|
||||
DeployFile(src, dst, "FlaxEditor");
|
||||
DeployFile(src, dst, "FlaxEditor.Build.json");
|
||||
DeployFile(src, dst, "FlaxEngine.CSharp.pdb");
|
||||
DeployFile(src, dst, "FlaxEngine.CSharp.xml");
|
||||
DeployFile(src, dst, "Newtonsoft.Json.pdb");
|
||||
DeployFiles(src, dst, "*.dll");
|
||||
DeployFiles(src, dst, "*.so");
|
||||
DeployFile(src, dst, "Logo.png");
|
||||
@@ -253,10 +247,6 @@ namespace Flax.Deploy
|
||||
{
|
||||
// Deploy binaries
|
||||
DeployFile(src, dst, "FlaxEditor");
|
||||
DeployFile(src, dst, "FlaxEditor.Build.json");
|
||||
DeployFile(src, dst, "FlaxEngine.CSharp.pdb");
|
||||
DeployFile(src, dst, "FlaxEngine.CSharp.xml");
|
||||
DeployFile(src, dst, "Newtonsoft.Json.pdb");
|
||||
DeployFile(src, dst, "MoltenVK_icd.json");
|
||||
DeployFiles(src, dst, "*.dll");
|
||||
DeployFiles(src, dst, "*.dylib");
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Flax.Deploy
|
||||
|
||||
var packageZipPath = Path.Combine(Deployer.PackageOutputPath, platformName + ".zip");
|
||||
Utilities.FileDelete(packageZipPath);
|
||||
#if true
|
||||
#if false
|
||||
using (var zip = new Ionic.Zip.ZipFile())
|
||||
{
|
||||
zip.AddDirectory(dst);
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Flax.Deploy
|
||||
|
||||
Log.Verbose("Deploy file " + filename);
|
||||
|
||||
File.Copy(files[i], Path.Combine(dst, filename));
|
||||
File.Copy(files[i], Path.Combine(dst, filename), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,26 +14,13 @@ namespace Flax.Deploy
|
||||
public static void Build(string root, string target, TargetPlatform platform, TargetArchitecture architecture, TargetConfiguration configuration)
|
||||
{
|
||||
var buildPlatform = Platform.BuildPlatform.Target;
|
||||
var flaxBuildTool = Path.Combine(Globals.EngineRoot, "Binaries/Tools/Flax.Build.exe");
|
||||
var flaxBuildTool = Path.Combine(Globals.EngineRoot, buildPlatform == TargetPlatform.Windows ? "Binaries/Tools/Flax.Build.exe" : "Binaries/Tools/Flax.Build");
|
||||
var format = "-build -buildtargets={0} -log -logfile= -perf -platform={1} -arch={2} -configuration={3}";
|
||||
if (buildPlatform == TargetPlatform.Linux)
|
||||
{
|
||||
format = format.Replace("-", "--");
|
||||
}
|
||||
var cmdLine = string.Format(format, target, platform, architecture, configuration);
|
||||
if (!string.IsNullOrEmpty(Configuration.Compiler))
|
||||
cmdLine += " -compiler=" + Configuration.Compiler;
|
||||
|
||||
int result;
|
||||
if (buildPlatform == TargetPlatform.Windows)
|
||||
{
|
||||
result = Utilities.Run(flaxBuildTool, cmdLine, null, root);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = Utilities.Run("mono", flaxBuildTool + " " + cmdLine, null, root);
|
||||
}
|
||||
|
||||
int result = Utilities.Run(flaxBuildTool, cmdLine, null, root);
|
||||
if (result != 0)
|
||||
{
|
||||
throw new Exception(string.Format("Unable to build target {0}. Flax.Build failed. See log to learn more.", target));
|
||||
|
||||
Reference in New Issue
Block a user