Fix support for codeless game projects
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include "Editor/Cooker/PlatformTools.h"
|
||||
#include "Editor/Editor.h"
|
||||
#include "Editor/ProjectInfo.h"
|
||||
#include "Engine/Engine/Globals.h"
|
||||
|
||||
bool CompileScriptsStep::DeployBinaries(CookingData& data, const String& path, const String& projectFolderPath)
|
||||
{
|
||||
@@ -136,12 +137,8 @@ bool CompileScriptsStep::Perform(CookingData& data)
|
||||
data.StepProgress(TEXT("Compiling game scripts"), 0);
|
||||
|
||||
const ProjectInfo* project = Editor::Project;
|
||||
const String& target = project->GameTarget;
|
||||
if (target.IsEmpty())
|
||||
{
|
||||
LOG(Error, "Empty GameTarget in project.");
|
||||
return true;
|
||||
}
|
||||
String target = project->GameTarget;
|
||||
StringView workingDir;
|
||||
const Char *platform, *architecture, *configuration = ::ToString(data.Configuration);
|
||||
switch (data.Platform)
|
||||
{
|
||||
@@ -189,6 +186,15 @@ bool CompileScriptsStep::Perform(CookingData& data)
|
||||
LOG(Error, "Unknown or unsupported build platform.");
|
||||
return true;
|
||||
}
|
||||
String targetBuildInfo = project->ProjectFolderPath / TEXT("Binaries") / target / platform / architecture / configuration / target + TEXT(".Build.json");
|
||||
if (target.IsEmpty())
|
||||
{
|
||||
// Fallback to engine-only if game has no code
|
||||
LOG(Warning, "Empty GameTarget in project.");
|
||||
target = TEXT("FlaxGame");
|
||||
workingDir = Globals::StartupFolder;
|
||||
targetBuildInfo = Globals::StartupFolder / TEXT("Source/Platforms") / platform / TEXT("Binaries") / TEXT("Game") / architecture / configuration / target + TEXT(".Build.json");
|
||||
}
|
||||
_extensionsToSkip.Clear();
|
||||
_extensionsToSkip.Add(TEXT(".exp"));
|
||||
_extensionsToSkip.Add(TEXT(".ilk"));
|
||||
@@ -229,7 +235,7 @@ bool CompileScriptsStep::Perform(CookingData& data)
|
||||
args += TEXT(" -D");
|
||||
args += define;
|
||||
}
|
||||
if (ScriptsBuilder::RunBuildTool(args))
|
||||
if (ScriptsBuilder::RunBuildTool(args, workingDir))
|
||||
{
|
||||
data.Error(TEXT("Failed to compile game scripts."));
|
||||
return true;
|
||||
@@ -243,7 +249,6 @@ bool CompileScriptsStep::Perform(CookingData& data)
|
||||
data.StepProgress(TEXT("Exporting binaries"), 0.8f);
|
||||
|
||||
// Deploy binary modules
|
||||
const String targetBuildInfo = project->ProjectFolderPath / TEXT("Binaries") / project->GameTarget / platform / architecture / configuration / target + TEXT(".Build.json");
|
||||
if (DeployBinaries(data, targetBuildInfo, project->ProjectFolderPath))
|
||||
return true;
|
||||
|
||||
|
||||
@@ -211,7 +211,7 @@ void ScriptsBuilder::Compile()
|
||||
_isCompileRequested = true;
|
||||
}
|
||||
|
||||
bool ScriptsBuilder::RunBuildTool(const StringView& args)
|
||||
bool ScriptsBuilder::RunBuildTool(const StringView& args, const StringView& workingDir)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
const String buildToolPath = Globals::StartupFolder / TEXT("Binaries/Tools/Flax.Build.exe");
|
||||
@@ -242,7 +242,7 @@ bool ScriptsBuilder::RunBuildTool(const StringView& args)
|
||||
// TODO: Set env var for the mono MONO_GC_PARAMS=nursery-size64m to boost build performance -> profile it
|
||||
|
||||
// Call build tool
|
||||
const int32 result = Platform::RunProcess(StringView(*cmdLine, cmdLine.Length()), StringView::Empty);
|
||||
const int32 result = Platform::RunProcess(StringView(*cmdLine, cmdLine.Length()), workingDir);
|
||||
return result != 0;
|
||||
}
|
||||
|
||||
@@ -357,7 +357,7 @@ void ScriptsBuilder::GetBinariesConfiguration(const Char*& target, const Char*&
|
||||
else
|
||||
{
|
||||
target = TEXT("");
|
||||
LOG(Error, "Missing editor/game targets in project. Please specify EditorTarget and GameTarget properties in .flaxproj file.");
|
||||
LOG(Warning, "Missing editor/game targets in project. Please specify EditorTarget and GameTarget properties in .flaxproj file.");
|
||||
}
|
||||
|
||||
#if PLATFORM_WINDOWS
|
||||
@@ -395,7 +395,7 @@ bool ScriptsBuilderImpl::compileGameScriptsAsyncInner()
|
||||
// Call compilation
|
||||
const Char *target, *platform, *architecture, *configuration;
|
||||
ScriptsBuilder::GetBinariesConfiguration(target, platform, architecture, configuration);
|
||||
if (!target)
|
||||
if (StringUtils::Length(target) == 0)
|
||||
{
|
||||
LOG(Info, "Missing EditorTarget in project. Skipping compilation.");
|
||||
CallEvent(EventType::ReloadCalled);
|
||||
@@ -580,7 +580,7 @@ bool ScriptsBuilderService::Init()
|
||||
// Remove any remaining files from previous Editor run hot-reloads
|
||||
const Char *target, *platform, *architecture, *configuration;
|
||||
ScriptsBuilder::GetBinariesConfiguration(target, platform, architecture, configuration);
|
||||
if (target)
|
||||
if (StringUtils::Length(target) != 0)
|
||||
{
|
||||
const String targetOutput = Globals::ProjectFolder / TEXT("Binaries") / target / platform / architecture / configuration;
|
||||
Array<String> files;
|
||||
|
||||
@@ -97,8 +97,9 @@ public:
|
||||
/// Invokes the Flax.Build tool in the current project workspace and waits for the process end (blocking). Prints the build tool output to the log. Can be invoked from any thread.
|
||||
/// </summary>
|
||||
/// <param name="args">The Flax.Build tool invocation arguments.</param>
|
||||
/// <param name="workingDir">The custom working directory. Use empty or null to execute build tool in the project folder.</param>
|
||||
/// <returns>True if failed, otherwise false.</returns>
|
||||
API_FUNCTION() static bool RunBuildTool(const StringView& args);
|
||||
API_FUNCTION() static bool RunBuildTool(const StringView& args, const StringView& workingDir = StringView::Empty);
|
||||
|
||||
/// <summary>
|
||||
/// Generates the project files.
|
||||
|
||||
@@ -446,9 +446,10 @@ bool Scripting::Load()
|
||||
// Flax.Build outputs the <target>.Build.json with binary modules to use for game scripting
|
||||
const Char *target, *platform, *architecture, *configuration;
|
||||
ScriptsBuilder::GetBinariesConfiguration(target, platform, architecture, configuration);
|
||||
if (target == nullptr)
|
||||
if (StringUtils::Length(target) == 0)
|
||||
{
|
||||
LOG(Info, "Missing EditorTarget in project. Not using game script modules.");
|
||||
_hasGameModulesLoaded = true;
|
||||
return false;
|
||||
}
|
||||
const String targetBuildInfo = Globals::ProjectFolder / TEXT("Binaries") / target / platform / architecture / configuration / target + TEXT(".Build.json");
|
||||
|
||||
Reference in New Issue
Block a user