Add app packaging for macOS

This commit is contained in:
Wojtek Figat
2022-01-13 18:19:49 +01:00
parent 5d7f8e2df9
commit 08bebc0f89
5 changed files with 175 additions and 10 deletions

View File

@@ -535,7 +535,13 @@ Rectangle MacPlatform::GetVirtualDesktopBounds()
String MacPlatform::GetMainDirectory()
{
return StringUtils::GetDirectoryName(GetExecutableFilePath());
String path = StringUtils::GetDirectoryName(GetExecutableFilePath());
if (path.EndsWith(TEXT("/Contents/MacOS")))
{
// If running from executable in a package, go up to the Contents
path = StringUtils::GetDirectoryName(path);
}
return path;
}
String MacPlatform::GetExecutableFilePath()
@@ -589,18 +595,26 @@ bool MacPlatform::SetEnvironmentVariable(const String& name, const String& value
int32 MacProcess(const StringView& cmdLine, const StringView& workingDir, const Dictionary<String, String>& environment, bool waitForEnd, bool logOutput)
{
LOG(Info, "Command: {0}", cmdLine);
String cwd;
if (workingDir.Length() != 0)
{
LOG(Info, "Working directory: {0}", workingDir);
cwd = Platform::GetWorkingDirectory();
Platform::SetWorkingDirectory(workingDir);
}
StringAsANSI<> cmdLineAnsi(*cmdLine, cmdLine.Length());
FILE* pipe = popen(cmdLineAnsi.Get(), "r");
if (cwd.Length() != 0)
{
Platform::SetWorkingDirectory(cwd);
}
if (!pipe)
{
LOG(Warning, "Failed to start process, errno={}", errno);
return -1;
}
// TODO: workingDir
// TODO: environment
int32 returnCode = 0;

View File

@@ -6,6 +6,9 @@
#include "Engine/Core/Config/PlatformSettingsBase.h"
#include "Engine/Core/Types/String.h"
#include "Engine/Scripting/SoftObjectReference.h"
class Texture;
/// <summary>
/// Mac platform settings.
@@ -20,6 +23,12 @@ API_CLASS(sealed, Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API
API_FIELD(Attributes="EditorOrder(0), EditorDisplay(\"General\")")
String AppIdentifier = TEXT("com.${COMPANY_NAME}.${PROJECT_NAME}");
/// <summary>
/// Custom icon texture to use for the application (overrides the default one).
/// </summary>
API_FIELD(Attributes="EditorOrder(1000), EditorDisplay(\"Other\")")
SoftObjectReference<Texture> OverrideIcon;
public:
/// <summary>
/// Gets the instance of the settings asset (default value if missing). Object returned by this method is always loaded with valid data to use.
@@ -30,6 +39,7 @@ public:
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) final override
{
DESERIALIZE(AppIdentifier);
DESERIALIZE(OverrideIcon);
}
};