Add editor app packaging for macOS

This commit is contained in:
Wojtek Figat
2023-09-23 14:42:05 +02:00
parent dbbd6ce045
commit f09aebacad
4 changed files with 93 additions and 2 deletions

View File

@@ -108,6 +108,14 @@ int32 Engine::Main(const Char* cmdLine)
Globals::StartupFolder = Globals::BinariesFolder = Platform::GetMainDirectory();
#if USE_EDITOR
Globals::StartupFolder /= TEXT("../../../..");
#if PLATFORM_MAC
if (Globals::BinariesFolder.EndsWith(TEXT(".app/Contents")))
{
// If running editor from application package on macOS
Globals::StartupFolder = Globals::BinariesFolder;
Globals::BinariesFolder /= TEXT("MacOS");
}
#endif
#endif
StringUtils::PathRemoveRelativeParts(Globals::StartupFolder);
FileSystem::NormalizePath(Globals::BinariesFolder);
@@ -125,7 +133,6 @@ int32 Engine::Main(const Char* cmdLine)
}
EngineImpl::InitPaths();
EngineImpl::InitLog();
#if USE_EDITOR
@@ -545,7 +552,8 @@ void EngineImpl::InitLog()
LOG(Info, "Product: {0}, Company: {1}", Globals::ProductName, Globals::CompanyName);
LOG(Info, "Current culture: {0}", Platform::GetUserLocaleName());
LOG(Info, "Command line: {0}", CommandLine);
LOG(Info, "Base directory: {0}", Globals::StartupFolder);
LOG(Info, "Base folder: {0}", Globals::StartupFolder);
LOG(Info, "Binaries folder: {0}", Globals::BinariesFolder);
LOG(Info, "Temporary folder: {0}", Globals::TemporaryFolder);
LOG(Info, "Project folder: {0}", Globals::ProjectFolder);
#if USE_EDITOR

Binary file not shown.

View File

@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIconFile</key>
<string>icon.icns</string>
<key>CFBundleExecutable</key>
<string>{Executable}</string>
<key>CFBundleName</key>
<string>FlaxEditor</string>
<key>CFBundleIdentifier</key>
<string>com.flaxengine.editor</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>{Version}</string>
<key>CFBundleVersion</key>
<string>{Version}</string>
<key>NSRequiresAquaSystemAppearance</key>
<false/>
<key>NSHumanReadableCopyright</key>
<string>{Copyright}</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.developer-tools</string>
<key>LSMinimumSystemVersion</key>
<string>10.15</string>
<key>LSMinimumSystemVersionByArchitecture</key>
<dict>
<key>{Arch}</key>
<string>10.15</string>
</dict>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>

View File

@@ -6,6 +6,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
using Flax.Build;
using Flax.Build.Platforms;
@@ -126,6 +127,45 @@ namespace Flax.Deploy
// Deploy project
DeployFile(RootPath, OutputPath, "Flax.flaxproj");
// Package Editor into macOS app
if (Platform.BuildTargetPlatform == TargetPlatform.Mac)
{
var arch = Platform.BuildTargetArchitecture;
Log.Info(string.Empty);
Log.Info("Creating macOS app...");
var appPath = Path.Combine(Deployer.PackageOutputPath, "FlaxEditor.app");
var appContentsPath = Path.Combine(appPath, "Contents");
var appBinariesPath = Path.Combine(appContentsPath, "MacOS");
Utilities.DirectoryDelete(appPath);
Directory.CreateDirectory(appPath);
Directory.CreateDirectory(appContentsPath);
Directory.CreateDirectory(appBinariesPath);
// Copy icons set
Directory.CreateDirectory(Path.Combine(appContentsPath, "Resources"));
Utilities.FileCopy(Path.Combine(Globals.EngineRoot, "Source/Platforms/Mac/Default.icns"), Path.Combine(appContentsPath, "Resources/icon.icns"));
// Create PkgInfo file
File.WriteAllText(Path.Combine(appContentsPath, "PkgInfo"), "APPL???", Encoding.ASCII);
// Create Info.plist
var plist = File.ReadAllText(Path.Combine(Globals.EngineRoot, "Source/Platforms/Mac/Default.plist"));
var flaxProject = EngineTarget.EngineProject;
plist = plist.Replace("{Version}", flaxProject.Version.ToString());
plist = plist.Replace("{Copyright}", flaxProject.Copyright);
plist = plist.Replace("{Executable}", "FlaxEditor");
plist = plist.Replace("{Arch}", arch == TargetArchitecture.ARM64 ? "arm64" : "x86_64");
File.WriteAllText(Path.Combine(appContentsPath, "Info.plist"), plist, Encoding.ASCII);
// Copy output editor files
Utilities.DirectoryCopy(OutputPath, appContentsPath);
// Copy native binaries for app execution
var defaultEditorConfig = "Development";
var ediotrBinariesPath = Path.Combine(appContentsPath, "Binaries/Editor/Mac", defaultEditorConfig);
Utilities.DirectoryCopy(ediotrBinariesPath, appBinariesPath, true, true);
}
// Compress
if (Configuration.DontCompress)
return;