Merge remote-tracking branch 'origin/master' into 1.2

This commit is contained in:
Wojtek Figat
2021-03-30 17:58:29 +02:00
38 changed files with 303 additions and 109 deletions

View File

@@ -101,7 +101,7 @@ namespace Flax.Build
}
// Mono on Linux is using dynamic linking and needs additional link files
if (buildOptions.Platform.Target == TargetPlatform.Linux)
if (buildOptions.Platform.Target == TargetPlatform.Linux && Platform.BuildTargetPlatform == TargetPlatform.Linux && !IsPreBuilt)
{
var task = graph.Add<Task>();
task.PrerequisiteFiles.Add(Path.Combine(buildOptions.OutputFolder, "libmonosgen-2.0.so"));
@@ -120,6 +120,8 @@ namespace Flax.Build
private void BuildMainExecutable(TaskGraph graph, BuildOptions buildOptions)
{
if (IsPreBuilt)
return;
var outputPath = Path.Combine(buildOptions.OutputFolder, buildOptions.Platform.GetLinkOutputFileName(OutputName, LinkerOutput.Executable));
var exeBuildOptions = Builder.GetBuildOptions(this, buildOptions.Platform, buildOptions.Toolchain, buildOptions.Architecture, buildOptions.Configuration, buildOptions.WorkingDirectory);
exeBuildOptions.LinkEnv.Output = LinkerOutput.Executable;
@@ -139,7 +141,7 @@ namespace Flax.Build
// Build Main module
var mainModule = rules.GetModule("Main");
var mainModuleOutputPath = Path.Combine(exeBuildOptions.IntermediateFolder, mainModule.Name);
if (!IsPreBuilt && !Directory.Exists(mainModuleOutputPath))
if (!Directory.Exists(mainModuleOutputPath))
Directory.CreateDirectory(mainModuleOutputPath);
var mainModuleOptions = new BuildOptions
{

View File

@@ -45,7 +45,7 @@ namespace Flax.Build
throw new Exception($"Invalid or missing editor target {project.EditorTarget} specified in project {project.Name} (referenced by project {Project.Name}).");
return result;
}
if (!IsEditor && !string.IsNullOrEmpty(project.GameTarget))
if (!string.IsNullOrEmpty(project.GameTarget))
{
var result = projectTargets.FirstOrDefault(x => x.Name == project.GameTarget);
if (result == null)

View File

@@ -15,5 +15,17 @@ namespace Flax.Build
/// </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;
}
}

View File

@@ -12,6 +12,18 @@ namespace Flax.Deploy
{
partial class Deployment
{
private static void CodeSign(string file)
{
if (string.IsNullOrEmpty(Configuration.DeployCert))
return;
switch (Platform.BuildTargetPlatform)
{
case TargetPlatform.Windows:
VCEnvironment.CodeSign(file, Configuration.DeployCert, Configuration.DeployCertPass);
break;
}
}
public class Editor
{
private static string RootPath;
@@ -37,6 +49,7 @@ namespace Flax.Deploy
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");
DeployFile(src, dst, "Ionic.Zip.Reduced.dll");
DeployFile(src, dst, "Newtonsoft.Json.dll");
@@ -112,15 +125,26 @@ namespace Flax.Deploy
// Compress
Log.Info(string.Empty);
Log.Info("Compressing editor files...");
var editorPackageZipPath = Path.Combine(Deployer.PackageOutputPath, "Editor.zip");
using (ZipFile zip = new ZipFile())
string editorPackageZipPath;
if (Platform.BuildPlatform.Target == TargetPlatform.Linux)
{
zip.AddDirectory(OutputPath);
// Use system tool (preserves executable file attributes and link files)
editorPackageZipPath = Path.Combine(Deployer.PackageOutputPath, "FlaxEditorLinux.zip");
Utilities.Run("zip", "Editor.zip -r .", null, OutputPath, Utilities.RunOptions.None);
File.Move(Path.Combine(OutputPath, "Editor.zip"), editorPackageZipPath);
}
else
{
editorPackageZipPath = Path.Combine(Deployer.PackageOutputPath, "Editor.zip");
using (ZipFile zip = new ZipFile())
{
zip.AddDirectory(OutputPath);
zip.CompressionLevel = CompressionLevel.BestCompression;
zip.Comment = string.Format("Flax Editor {0}.{1}.{2}\nDate: {3}", Deployer.VersionMajor, Deployer.VersionMinor, Deployer.VersionBuild, DateTime.UtcNow);
zip.CompressionLevel = CompressionLevel.BestCompression;
zip.Comment = string.Format("Flax Editor {0}.{1}.{2}\nDate: {3}", Deployer.VersionMajor, Deployer.VersionMinor, Deployer.VersionBuild, DateTime.UtcNow);
zip.Save(editorPackageZipPath);
zip.Save(editorPackageZipPath);
}
}
Log.Info("Compressed editor package size: " + Utilities.GetFileSize(editorPackageZipPath));
@@ -166,12 +190,14 @@ 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"));
// Deploy debug symbols files
DeployFiles(src, dstDebug, "*.pdb");

View File

@@ -37,6 +37,22 @@ namespace Flax.Deploy
File.Delete(Path.Combine(dst, "Binaries", "Game", "x64", "Release", "FlaxGame.a"));
}
// Sign binaries
if (platform == TargetPlatform.Windows && !string.IsNullOrEmpty(Configuration.DeployCert))
{
var binaries = Path.Combine(dst, "Binaries", "Game", "x64", "Debug");
CodeSign(Path.Combine(binaries, "FlaxGame.exe"));
CodeSign(Path.Combine(binaries, "FlaxEngine.CSharp.dll"));
binaries = Path.Combine(dst, "Binaries", "Game", "x64", "Development");
CodeSign(Path.Combine(binaries, "FlaxGame.exe"));
CodeSign(Path.Combine(binaries, "FlaxEngine.CSharp.dll"));
binaries = Path.Combine(dst, "Binaries", "Game", "x64", "Release");
CodeSign(Path.Combine(binaries, "FlaxGame.exe"));
CodeSign(Path.Combine(binaries, "FlaxEngine.CSharp.dll"));
}
// Don't distribute engine deps
Utilities.DirectoryDelete(Path.Combine(dst, "Binaries", "ThirdParty"));

View File

@@ -21,6 +21,8 @@ namespace Flax.Deploy
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)

View File

@@ -2,6 +2,7 @@
using System;
using System.IO;
using System.Linq;
using Flax.Build;
using Flax.Build.Platforms;
using Flax.Build.Projects.VisualStudio;
@@ -255,5 +256,22 @@ namespace Flax.Deploy
string cmdLine = string.Format("\"{0}\" /t:Clean /verbosity:minimal /nologo", solutionFile);
Utilities.Run(msBuild, cmdLine);
}
internal static void CodeSign(string file, string certificatePath, string certificatePass)
{
if (!File.Exists(file))
throw new FileNotFoundException("Missing file to sign.", file);
if (!File.Exists(certificatePath))
throw new FileNotFoundException("Missing certificate to sign with.", certificatePath);
var sdks = WindowsPlatformBase.GetSDKs();
if (sdks.Count == 0)
throw new Exception("No Windows SDK found. Cannot sign file.");
var sdkKeys = sdks.Keys.ToList();
sdkKeys.Sort();
var sdk = sdks[sdkKeys.Last()];
var signtool = Path.Combine(sdk, "bin", "x64", "signtool.exe");
var cmdLine = string.Format("sign /debug /f \"{0}\" /p \"{1}\" /tr http://timestamp.comodoca.com /td sha256 /fd sha256 \"{2}\"", certificatePath, certificatePass, file);
Utilities.Run(signtool, cmdLine);
}
}
}

View File

@@ -39,6 +39,46 @@ namespace Flax.Deps.Dependencies
{
var root = options.IntermediateFolder;
var moduleFilename = "assimp.Build.cs";
var configs = new string[]
{
"-DASSIMP_NO_EXPORT=ON",
"-DASSIMP_BUILD_ASSIMP_TOOLS=OFF",
"-DASSIMP_BUILD_TESTS=OFF",
"-DASSIMP_BUILD_AMF_IMPORTER=FALSE",
"-DASSIMP_BUILD_AC_IMPORTER=FALSE",
"-DASSIMP_BUILD_ASE_IMPORTER=FALSE",
"-DASSIMP_BUILD_ASSBIN_IMPORTER=FALSE",
"-DASSIMP_BUILD_ASSXML_IMPORTER=FALSE",
"-DASSIMP_BUILD_DXF_IMPORTER=FALSE",
"-DASSIMP_BUILD_CSM_IMPORTER=FALSE",
"-DASSIMP_BUILD_HMP_IMPORTER=FALSE",
"-DASSIMP_BUILD_NFF_IMPORTER=FALSE",
"-DASSIMP_BUILD_NDO_IMPORTER=FALSE",
"-DASSIMP_BUILD_IFC_IMPORTER=FALSE",
"-DASSIMP_BUILD_FBX_IMPORTER=FALSE",
"-DASSIMP_BUILD_RAW_IMPORTER=FALSE",
"-DASSIMP_BUILD_TERRAGEN_IMPORTER=FALSE",
"-DASSIMP_BUILD_3MF_IMPORTER=FALSE",
"-DASSIMP_BUILD_STEP_IMPORTER=FALSE",
"-DASSIMP_BUILD_3DS_IMPORTER=FALSE",
"-DASSIMP_BUILD_BVH_IMPORTER=FALSE",
"-DASSIMP_BUILD_IRRMESH_IMPORTER=FALSE",
"-DASSIMP_BUILD_IRR_IMPORTER=FALSE",
"-DASSIMP_BUILD_MD2_IMPORTER=FALSE",
"-DASSIMP_BUILD_MD3_IMPORTER=FALSE",
"-DASSIMP_BUILD_MD5_IMPORTER=FALSE",
"-DASSIMP_BUILD_MDC_IMPORTER=FALSE",
"-DASSIMP_BUILD_MDL_IMPORTER=FALSE",
"-DASSIMP_BUILD_OFF_IMPORTER=FALSE",
"-DASSIMP_BUILD_COB_IMPORTER=FALSE",
"-DASSIMP_BUILD_Q3D_IMPORTER=FALSE",
"-DASSIMP_BUILD_Q3BSP_IMPORTER=FALSE",
"-DASSIMP_BUILD_SIB_IMPORTER=FALSE",
"-DASSIMP_BUILD_SMD_IMPORTER=FALSE",
"-DASSIMP_BUILD_X3D_IMPORTER=FALSE",
"-DASSIMP_BUILD_MMD_IMPORTER=FALSE",
};
var globalConfig = string.Join(" ", configs);
// Get the source
CloneGitRepo(root, "https://github.com/FlaxEngine/assimp.git");
@@ -73,13 +113,11 @@ namespace Flax.Deps.Dependencies
case TargetPlatform.Linux:
{
// Build for Linux
RunCmake(root, TargetPlatform.Linux, TargetArchitecture.x64, " -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DASSIMP_NO_EXPORT=ON -DASSIMP_BUILD_ASSIMP_TOOLS=OFF -DASSIMP_BUILD_TESTS=OFF");
RunCmake(root, TargetPlatform.Linux, TargetArchitecture.x64, " -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF " + globalConfig);
Utilities.Run("make", null, null, root, Utilities.RunOptions.None);
var depsFolder = GetThirdPartyFolder(options, TargetPlatform.Linux, TargetArchitecture.x64);
var srcName = "libassimp.so.4.1.0";
var dstName = "libassimp.so";
Utilities.FileCopy(Path.Combine(root, "lib", srcName), Path.Combine(depsFolder, dstName));
Utilities.Run("strip", dstName, null, depsFolder, Utilities.RunOptions.None);
Utilities.FileCopy(Path.Combine(root, "lib", "libassimp.a"), Path.Combine(depsFolder, "libassimp.a"));
Utilities.FileCopy(Path.Combine(root, "lib", "libIrrXML.a"), Path.Combine(depsFolder, "libIrrXML.a"));
break;
}
}

View File

@@ -119,6 +119,8 @@ namespace Flax.Build
private bool IsTargetCSharpOnly(string name)
{
if (string.IsNullOrWhiteSpace(name))
return true;
var rules = Builder.GenerateRulesAssembly();
var target = rules.GetTarget(name);
return target == null || target.Modules.TrueForAll(x => !rules.GetModule(x).BuildNativeCode);