Mac impl progress
This commit is contained in:
93
Source/Editor/Cooker/Platform/Mac/MacPlatformTools.cpp
Normal file
93
Source/Editor/Cooker/Platform/Mac/MacPlatformTools.cpp
Normal file
@@ -0,0 +1,93 @@
|
||||
// Copyright (c) 2012-2019 Wojciech Figat. All rights reserved.
|
||||
|
||||
#if PLATFORM_TOOLS_MAC
|
||||
|
||||
#include "MacPlatformTools.h"
|
||||
#include "Engine/Platform/FileSystem.h"
|
||||
#include "Engine/Platform/Mac/MacPlatformSettings.h"
|
||||
#include "Engine/Core/Config/GameSettings.h"
|
||||
#include "Editor/Utilities/EditorUtilities.h"
|
||||
#include "Engine/Content/Content.h"
|
||||
#include "Engine/Content/JsonAsset.h"
|
||||
|
||||
IMPLEMENT_SETTINGS_GETTER(MacPlatformSettings, MacPlatform);
|
||||
|
||||
MacPlatformTools::MacPlatformTools(ArchitectureType arch)
|
||||
: _arch(arch)
|
||||
{
|
||||
}
|
||||
|
||||
const Char* MacPlatformTools::GetDisplayName() const
|
||||
{
|
||||
return TEXT("Mac");
|
||||
}
|
||||
|
||||
const Char* MacPlatformTools::GetName() const
|
||||
{
|
||||
return TEXT("Mac");
|
||||
}
|
||||
|
||||
PlatformType MacPlatformTools::GetPlatform() const
|
||||
{
|
||||
return PlatformType::Mac;
|
||||
}
|
||||
|
||||
ArchitectureType MacPlatformTools::GetArchitecture() const
|
||||
{
|
||||
return _arch;
|
||||
}
|
||||
|
||||
bool MacPlatformTools::OnDeployBinaries(CookingData& data)
|
||||
{
|
||||
const auto gameSettings = GameSettings::Get();
|
||||
const auto platformSettings = MacPlatformSettings::Get();
|
||||
const auto outputPath = data.DataOutputPath;
|
||||
|
||||
// Copy binaries
|
||||
{
|
||||
if (!FileSystem::DirectoryExists(outputPath))
|
||||
FileSystem::CreateDirectory(outputPath);
|
||||
const auto binPath = data.GetGameBinariesPath();
|
||||
|
||||
// Gather files to deploy
|
||||
Array<String> files;
|
||||
files.Add(binPath / TEXT("FlaxGame"));
|
||||
FileSystem::DirectoryGetFiles(files, binPath, TEXT("*.a"), DirectorySearchOption::TopDirectoryOnly);
|
||||
|
||||
// Copy data
|
||||
for (int32 i = 0; i < files.Count(); i++)
|
||||
{
|
||||
if (FileSystem::CopyFile(outputPath / StringUtils::GetFileName(files[i]), files[i]))
|
||||
{
|
||||
data.Error(TEXT("Failed to setup output directory."));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Apply game executable file name
|
||||
#if !BUILD_DEBUG
|
||||
const String outputExePath = outputPath / TEXT("FlaxGame");
|
||||
const String gameExePath = outputPath / gameSettings->ProductName;
|
||||
if (FileSystem::FileExists(outputExePath) && gameExePath.Compare(outputExePath, StringSearchCase::IgnoreCase) != 0)
|
||||
{
|
||||
if (FileSystem::MoveFile(gameExePath, outputExePath, true))
|
||||
{
|
||||
data.Error(TEXT("Failed to rename output executable file."));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#else
|
||||
// Don't change application name on a DEBUG build (for build game debugging)
|
||||
const String gameExePath = outputPath / TEXT("FlaxGame");
|
||||
#endif
|
||||
|
||||
// Ensure the output binary can be executed
|
||||
#if PLATFORM_MAC
|
||||
system(*StringAnsi(String::Format(TEXT("chmod +x \"{0}\""), gameExePath)));
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
29
Source/Editor/Cooker/Platform/Mac/MacPlatformTools.h
Normal file
29
Source/Editor/Cooker/Platform/Mac/MacPlatformTools.h
Normal file
@@ -0,0 +1,29 @@
|
||||
// Copyright (c) 2012-2019 Wojciech Figat. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#if PLATFORM_TOOLS_MAC
|
||||
|
||||
#include "../../PlatformTools.h"
|
||||
|
||||
/// <summary>
|
||||
/// The Mac platform support tools.
|
||||
/// </summary>
|
||||
class MacPlatformTools : public PlatformTools
|
||||
{
|
||||
private:
|
||||
ArchitectureType _arch;
|
||||
|
||||
public:
|
||||
|
||||
MacPlatformTools(ArchitectureType arch);
|
||||
|
||||
// [PlatformTools]
|
||||
const Char* GetDisplayName() const override;
|
||||
const Char* GetName() const override;
|
||||
PlatformType GetPlatform() const override;
|
||||
ArchitectureType GetArchitecture() const override;
|
||||
bool OnDeployBinaries(CookingData& data) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user