Add support for packaging editor with bundled platform data

This commit is contained in:
Wojtek Figat
2023-10-19 19:09:06 +02:00
parent 6c45141ef9
commit 2bb8c82329
3 changed files with 43 additions and 7 deletions

View File

@@ -66,12 +66,6 @@ namespace Flax.Deploy
{ {
Initialize(); Initialize();
if (Configuration.DeployEditor)
{
BuildEditor();
Deployment.Editor.Package();
}
if (Configuration.DeployPlatforms) if (Configuration.DeployPlatforms)
{ {
if (Configuration.BuildPlatforms == null || Configuration.BuildPlatforms.Length == 0) if (Configuration.BuildPlatforms == null || Configuration.BuildPlatforms.Length == 0)
@@ -94,6 +88,12 @@ namespace Flax.Deploy
} }
} }
} }
if (Configuration.DeployEditor)
{
BuildEditor();
Deployment.Editor.Package();
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -183,6 +183,10 @@ namespace Flax.Deploy
{ {
if (Platform.IsPlatformSupported(platform, architecture)) if (Platform.IsPlatformSupported(platform, architecture))
{ {
Log.Info(string.Empty);
Log.Info($"Build {platform} {architecture} platform");
Log.Info(string.Empty);
foreach (var configuration in Configurations) foreach (var configuration in Configurations)
{ {
FlaxBuild.Build(Globals.EngineRoot, "FlaxGame", platform, architecture, configuration); FlaxBuild.Build(Globals.EngineRoot, "FlaxGame", platform, architecture, configuration);

View File

@@ -127,6 +127,33 @@ namespace Flax.Deploy
// Deploy project // Deploy project
DeployFile(RootPath, OutputPath, "Flax.flaxproj"); DeployFile(RootPath, OutputPath, "Flax.flaxproj");
// When deploying Editor with Platforms at once then bundle them inside it
if (Configuration.DeployPlatforms && Platforms.PackagedPlatforms != null)
{
foreach (var platform in Platforms.PackagedPlatforms)
{
Log.Info(string.Empty);
Log.Info($"Bunding {platform} platform with Editor");
Log.Info(string.Empty);
string platformName = platform.ToString();
string platformFiles = Path.Combine(Deployer.PackageOutputPath, platformName);
string platformData = Path.Combine(OutputPath, "Source", "Platforms", platformName);
if (Directory.Exists(platformFiles))
{
// Copy deployed files
Utilities.DirectoryCopy(platformFiles, platformData);
}
else
{
// Extract deployed files
var packageZipPath = Path.Combine(Deployer.PackageOutputPath, platformName + ".zip");
Log.Verbose(packageZipPath + " -> " + platformData);
System.IO.Compression.ZipFile.ExtractToDirectory(packageZipPath, platformData, true);
}
}
}
// Package Editor into macOS app // Package Editor into macOS app
if (Platform.BuildTargetPlatform == TargetPlatform.Mac) if (Platform.BuildTargetPlatform == TargetPlatform.Mac)
{ {
@@ -167,6 +194,7 @@ namespace Flax.Deploy
// Build a disk image // Build a disk image
var dmgPath = Path.Combine(Deployer.PackageOutputPath, "FlaxEditor.dmg"); var dmgPath = Path.Combine(Deployer.PackageOutputPath, "FlaxEditor.dmg");
Log.Info(string.Empty);
Log.Info("Building disk image..."); Log.Info("Building disk image...");
if (File.Exists(dmgPath)) if (File.Exists(dmgPath))
File.Delete(dmgPath); File.Delete(dmgPath);
@@ -178,7 +206,6 @@ namespace Flax.Deploy
// Compress // Compress
if (Configuration.DontCompress) if (Configuration.DontCompress)
return; return;
Log.Info(string.Empty); Log.Info(string.Empty);
Log.Info("Compressing editor files..."); Log.Info("Compressing editor files...");
string editorPackageZipPath; string editorPackageZipPath;

View File

@@ -10,8 +10,13 @@ namespace Flax.Deploy
{ {
public class Platforms public class Platforms
{ {
internal static List<TargetPlatform> PackagedPlatforms;
public static void Package(TargetPlatform platform) public static void Package(TargetPlatform platform)
{ {
if (PackagedPlatforms == null)
PackagedPlatforms = new List<TargetPlatform>();
PackagedPlatforms.Add(platform);
var platformsRoot = Path.Combine(Globals.EngineRoot, "Source", "Platforms"); var platformsRoot = Path.Combine(Globals.EngineRoot, "Source", "Platforms");
Log.Info(string.Empty); Log.Info(string.Empty);