Add support for Game Cooker on Linux

This commit is contained in:
Wojtek Figat
2021-03-11 22:39:03 +01:00
parent b04321bdd2
commit b4dcaef61a
4 changed files with 51 additions and 8 deletions

View File

@@ -101,7 +101,7 @@ bool CompileScriptsStep::DeployBinaries(CookingData& data, const String& path, c
// Deploy files // Deploy files
Array<String> files(16); Array<String> files(16);
const String outputPath = StringUtils::GetDirectoryName(path); const String outputPath = StringUtils::GetDirectoryName(path);
FileSystem::DirectoryGetFiles(files, outputPath, TEXT("*.*"), DirectorySearchOption::TopDirectoryOnly); FileSystem::DirectoryGetFiles(files, outputPath, TEXT(""), DirectorySearchOption::TopDirectoryOnly);
for (int32 i = files.Count() - 1; i >= 0; i--) for (int32 i = files.Count() - 1; i >= 0; i--)
{ {
bool skip = false; bool skip = false;

View File

@@ -368,6 +368,7 @@ bool ProcessShaderBase(CookAssetsStep::AssetCookData& data, ShaderAssetBase* ass
// Compile for a target platform // Compile for a target platform
switch (data.Data.Platform) switch (data.Data.Platform)
{ {
#if PLATFORM_TOOLS_WINDOWS
case BuildPlatform::Windows32: case BuildPlatform::Windows32:
case BuildPlatform::Windows64: case BuildPlatform::Windows64:
{ {
@@ -391,6 +392,7 @@ bool ProcessShaderBase(CookAssetsStep::AssetCookData& data, ShaderAssetBase* ass
} }
break; break;
} }
#endif
#if PLATFORM_TOOLS_UWP #if PLATFORM_TOOLS_UWP
case BuildPlatform::UWPx86: case BuildPlatform::UWPx86:
case BuildPlatform::UWPx64: case BuildPlatform::UWPx64:
@@ -408,12 +410,14 @@ bool ProcessShaderBase(CookAssetsStep::AssetCookData& data, ShaderAssetBase* ass
break; break;
} }
#endif #endif
#if PLATFORM_TOOLS_UWP
case BuildPlatform::XboxOne: case BuildPlatform::XboxOne:
{ {
const char* platformDefineName = "PLATFORM_XBOX_ONE"; const char* platformDefineName = "PLATFORM_XBOX_ONE";
COMPILE_PROFILE(DirectX_SM4, SHADER_FILE_CHUNK_INTERNAL_D3D_SM4_CACHE); COMPILE_PROFILE(DirectX_SM4, SHADER_FILE_CHUNK_INTERNAL_D3D_SM4_CACHE);
break; break;
} }
#endif
#if PLATFORM_TOOLS_LINUX #if PLATFORM_TOOLS_LINUX
case BuildPlatform::LinuxX64: case BuildPlatform::LinuxX64:
{ {
@@ -426,24 +430,30 @@ bool ProcessShaderBase(CookAssetsStep::AssetCookData& data, ShaderAssetBase* ass
break; break;
} }
#endif #endif
#if PLATFORM_TOOLS_PS4
case BuildPlatform::PS4: case BuildPlatform::PS4:
{ {
const char* platformDefineName = "PLATFORM_PS4"; const char* platformDefineName = "PLATFORM_PS4";
COMPILE_PROFILE(PS4, SHADER_FILE_CHUNK_INTERNAL_GENERIC_CACHE); COMPILE_PROFILE(PS4, SHADER_FILE_CHUNK_INTERNAL_GENERIC_CACHE);
break; break;
} }
#endif
#if PLATFORM_TOOLS_XBOX_SCARLETT
case BuildPlatform::XboxScarlett: case BuildPlatform::XboxScarlett:
{ {
const char* platformDefineName = "PLATFORM_XBOX_SCARLETT"; const char* platformDefineName = "PLATFORM_XBOX_SCARLETT";
COMPILE_PROFILE(DirectX_SM6, SHADER_FILE_CHUNK_INTERNAL_D3D_SM6_CACHE); COMPILE_PROFILE(DirectX_SM6, SHADER_FILE_CHUNK_INTERNAL_D3D_SM6_CACHE);
break; break;
} }
#endif
#if PLATFORM_TOOLS_ANDROID
case BuildPlatform::AndroidARM64: case BuildPlatform::AndroidARM64:
{ {
const char* platformDefineName = "PLATFORM_ANDROID"; const char* platformDefineName = "PLATFORM_ANDROID";
COMPILE_PROFILE(Vulkan_SM5, SHADER_FILE_CHUNK_INTERNAL_VULKAN_SM5_CACHE); COMPILE_PROFILE(Vulkan_SM5, SHADER_FILE_CHUNK_INTERNAL_VULKAN_SM5_CACHE);
break; break;
} }
#endif
default: default:
{ {
LOG(Warning, "Not implemented platform or shaders not supported."); LOG(Warning, "Not implemented platform or shaders not supported.");
@@ -895,21 +905,27 @@ bool CookAssetsStep::Perform(CookingData& data)
cache.Load(data); cache.Load(data);
// Update build settings // Update build settings
#if PLATFORM_TOOLS_WINDOWS
{ {
const auto settings = WindowsPlatformSettings::Get(); const auto settings = WindowsPlatformSettings::Get();
cache.Settings.Windows.SupportDX11 = settings->SupportDX11; cache.Settings.Windows.SupportDX11 = settings->SupportDX11;
cache.Settings.Windows.SupportDX10 = settings->SupportDX10; cache.Settings.Windows.SupportDX10 = settings->SupportDX10;
cache.Settings.Windows.SupportVulkan = settings->SupportVulkan; cache.Settings.Windows.SupportVulkan = settings->SupportVulkan;
} }
#endif
#if PLATFORM_TOOLS_UWP
{ {
const auto settings = UWPPlatformSettings::Get(); const auto settings = UWPPlatformSettings::Get();
cache.Settings.UWP.SupportDX11 = settings->SupportDX11; cache.Settings.UWP.SupportDX11 = settings->SupportDX11;
cache.Settings.UWP.SupportDX10 = settings->SupportDX10; cache.Settings.UWP.SupportDX10 = settings->SupportDX10;
} }
#endif
#if PLATFORM_TOOLS_LINUX
{ {
const auto settings = LinuxPlatformSettings::Get(); const auto settings = LinuxPlatformSettings::Get();
cache.Settings.Linux.SupportVulkan = settings->SupportVulkan; cache.Settings.Linux.SupportVulkan = settings->SupportVulkan;
} }
#endif
{ {
cache.Settings.Global.ShadersNoOptimize = buildSettings->ShadersNoOptimize; cache.Settings.Global.ShadersNoOptimize = buildSettings->ShadersNoOptimize;
cache.Settings.Global.ShadersGenerateDebugData = buildSettings->ShadersGenerateDebugData; cache.Settings.Global.ShadersGenerateDebugData = buildSettings->ShadersGenerateDebugData;

View File

@@ -51,13 +51,16 @@ public class Editor : EditorModule
var platformToolsRoot = Path.Combine(FolderPath, "Cooker", "Platform"); var platformToolsRoot = Path.Combine(FolderPath, "Cooker", "Platform");
var platformToolsRootExternal = Path.Combine(Globals.EngineRoot, "Source", "Platforms"); var platformToolsRootExternal = Path.Combine(Globals.EngineRoot, "Source", "Platforms");
if (options.Platform.Target == TargetPlatform.Windows)
{
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "Windows", "PLATFORM_TOOLS_WINDOWS"); AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "Windows", "PLATFORM_TOOLS_WINDOWS");
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "UWP", "PLATFORM_TOOLS_UWP"); AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "UWP", "PLATFORM_TOOLS_UWP");
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "UWP", "PLATFORM_TOOLS_XBOX_ONE"); AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "UWP", "PLATFORM_TOOLS_XBOX_ONE");
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "Linux", "PLATFORM_TOOLS_LINUX");
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "PS4", "PLATFORM_TOOLS_PS4"); AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "PS4", "PLATFORM_TOOLS_PS4");
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "XboxScarlett", "PLATFORM_TOOLS_XBOX_SCARLETT"); AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "XboxScarlett", "PLATFORM_TOOLS_XBOX_SCARLETT");
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "Android", "PLATFORM_TOOLS_ANDROID"); AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "Android", "PLATFORM_TOOLS_ANDROID");
}
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "Linux", "PLATFORM_TOOLS_LINUX");
// Visual Studio integration // Visual Studio integration
if (options.Platform.Target == TargetPlatform.Windows) if (options.Platform.Target == TargetPlatform.Windows)

View File

@@ -61,6 +61,9 @@ namespace FlaxEditor.Windows
public abstract class Platform public abstract class Platform
{ {
[HideInEditor]
public bool IsSupported;
[HideInEditor] [HideInEditor]
public bool IsAvailable; public bool IsAvailable;
@@ -93,6 +96,23 @@ namespace FlaxEditor.Windows
{ {
Output = output; Output = output;
// Check if can build on that platform
#if PLATFORM_WINDOWS
IsSupported = true;
#elif PLATFORM_LINUX
switch (BuildPlatform)
{
case BuildPlatform.LinuxX64:
IsSupported = true;
break;
default:
IsSupported = false;
break;
}
#else
#error "Unknown platform."
#endif
// TODO: restore build settings from the Editor cache! // TODO: restore build settings from the Editor cache!
// Check if can find installed tools for this platform // Check if can find installed tools for this platform
@@ -179,7 +199,11 @@ namespace FlaxEditor.Windows
_platform = proxy.Selector.Selected; _platform = proxy.Selector.Selected;
var platformObj = proxy.PerPlatformOptions[_platform]; var platformObj = proxy.PerPlatformOptions[_platform];
if (platformObj.IsAvailable) if (!platformObj.IsSupported)
{
layout.Label("This platform is not supported on this system.", TextAlignment.Center);
}
else if (platformObj.IsAvailable)
{ {
string name; string name;
switch (_platform) switch (_platform)