Add support for Custom Define in Game Cooker for build scripts configuration
This commit is contained in:
@@ -25,13 +25,6 @@ namespace FlaxEditor.Content.Settings
|
||||
Platform = BuildPlatform.Windows64,
|
||||
Mode = BuildConfiguration.Development,
|
||||
},
|
||||
new BuildTarget
|
||||
{
|
||||
Name = "Windows 32bit",
|
||||
Output = "Output\\Win32",
|
||||
Platform = BuildPlatform.Windows32,
|
||||
Mode = BuildConfiguration.Development,
|
||||
},
|
||||
}
|
||||
},
|
||||
new BuildPreset
|
||||
@@ -44,14 +37,7 @@ namespace FlaxEditor.Content.Settings
|
||||
Name = "Windows 64bit",
|
||||
Output = "Output\\Win64",
|
||||
Platform = BuildPlatform.Windows64,
|
||||
Mode = BuildConfiguration.Development,
|
||||
},
|
||||
new BuildTarget
|
||||
{
|
||||
Name = "Windows 32bit",
|
||||
Output = "Output\\Win32",
|
||||
Platform = BuildPlatform.Windows32,
|
||||
Mode = BuildConfiguration.Development,
|
||||
Mode = BuildConfiguration.Release,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
@@ -35,6 +35,12 @@ namespace FlaxEditor.Content.Settings
|
||||
[EditorOrder(30), Tooltip("Configuration build mode")]
|
||||
public BuildConfiguration Mode;
|
||||
|
||||
/// <summary>
|
||||
/// The list of custom defines passed to the build tool when compiling project scripts. Can be used in build scripts for configuration (Configuration.CustomDefines).
|
||||
/// </summary>
|
||||
[EditorOrder(90), Tooltip("The list of custom defines passed to the build tool when compiling project scripts. Can be used in build scripts for configuration (Configuration.CustomDefines).")]
|
||||
public string[] CustomDefines;
|
||||
|
||||
/// <summary>
|
||||
/// The pre-build action command line.
|
||||
/// </summary>
|
||||
@@ -46,11 +52,5 @@ namespace FlaxEditor.Content.Settings
|
||||
/// </summary>
|
||||
[EditorOrder(110)]
|
||||
public string PostBuildAction;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the build options computed from the target configuration.
|
||||
/// </summary>
|
||||
[HideInEditor, NoSerialize]
|
||||
public virtual BuildOptions Options => BuildOptions.None;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,6 +174,11 @@ struct FLAXENGINE_API CookingData
|
||||
/// </summary>
|
||||
BuildOptions Options;
|
||||
|
||||
/// <summary>
|
||||
/// The list of custom defines passed to the build tool when compiling project scripts. Can be used in build scripts for configuration (Configuration.CustomDefines).
|
||||
/// </summary>
|
||||
Array<String> CustomDefines;
|
||||
|
||||
/// <summary>
|
||||
/// The original output path (actual OutputPath could be modified by the Platform Tools or a plugin for additional layout customizations or packaging). This path is preserved.
|
||||
/// </summary>
|
||||
|
||||
@@ -257,7 +257,7 @@ PlatformTools* GameCooker::GetTools(BuildPlatform platform)
|
||||
return result;
|
||||
}
|
||||
|
||||
void GameCooker::Build(BuildPlatform platform, BuildConfiguration configuration, const StringView& outputPath, BuildOptions options)
|
||||
void GameCooker::Build(BuildPlatform platform, BuildConfiguration configuration, const StringView& outputPath, BuildOptions options, const Array<String>& customDefines)
|
||||
{
|
||||
if (IsRunning())
|
||||
{
|
||||
@@ -281,6 +281,7 @@ void GameCooker::Build(BuildPlatform platform, BuildConfiguration configuration,
|
||||
data.Platform = platform;
|
||||
data.Configuration = configuration;
|
||||
data.Options = options;
|
||||
data.CustomDefines = customDefines;
|
||||
data.OutputPath = outputPath;
|
||||
FileSystem::NormalizePath(data.OutputPath);
|
||||
data.OutputPath = data.OriginalOutputPath = FileSystem::ConvertRelativePathToAbsolute(Globals::ProjectFolder, data.OutputPath);
|
||||
|
||||
@@ -84,7 +84,8 @@ public:
|
||||
/// <param name="configuration">The build configuration.</param>
|
||||
/// <param name="outputPath">The output path (output directory).</param>
|
||||
/// <param name="options">The build options.</param>
|
||||
API_FUNCTION() static void Build(BuildPlatform platform, BuildConfiguration configuration, const StringView& outputPath, BuildOptions options);
|
||||
/// <param name="customDefines">The list of custom defines passed to the build tool when compiling project scripts. Can be used in build scripts for configuration (Configuration.CustomDefines).</param>
|
||||
API_FUNCTION() static void Build(BuildPlatform platform, BuildConfiguration configuration, const StringView& outputPath, BuildOptions options, const Array<String>& customDefines);
|
||||
|
||||
/// <summary>
|
||||
/// Sends a cancel event to the game building service.
|
||||
|
||||
@@ -217,6 +217,11 @@ bool CompileScriptsStep::Perform(CookingData& data)
|
||||
args += TEXT(" -SkipTargets=FlaxGame");
|
||||
}
|
||||
#endif
|
||||
for (auto& define : data.CustomDefines)
|
||||
{
|
||||
args += TEXT(" -D");
|
||||
args += define;
|
||||
}
|
||||
if (ScriptsBuilder::RunBuildTool(args))
|
||||
{
|
||||
data.Error(TEXT("Failed to compile game scripts."));
|
||||
|
||||
@@ -73,6 +73,9 @@ namespace FlaxEditor.Windows
|
||||
[EditorOrder(20), Tooltip("Configuration build mode")]
|
||||
public BuildConfiguration ConfigurationMode = BuildConfiguration.Development;
|
||||
|
||||
[EditorOrder(90), Tooltip("The list of custom defines passed to the build tool when compiling project scripts. Can be used in build scripts for configuration (Configuration.CustomDefines).")]
|
||||
public string[] CustomDefines;
|
||||
|
||||
protected abstract BuildPlatform BuildPlatform { get; }
|
||||
|
||||
protected virtual BuildOptions Options
|
||||
@@ -126,7 +129,7 @@ namespace FlaxEditor.Windows
|
||||
public virtual void Build()
|
||||
{
|
||||
var output = StringUtils.ConvertRelativePathToAbsolute(Globals.ProjectFolder, StringUtils.NormalizePath(Output));
|
||||
GameCooker.Build(BuildPlatform, ConfigurationMode, output, Options);
|
||||
GameCooker.Build(BuildPlatform, ConfigurationMode, output, Options, CustomDefines);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -793,7 +796,7 @@ namespace FlaxEditor.Windows
|
||||
_preBuildAction = target.PreBuildAction;
|
||||
_postBuildAction = target.PostBuildAction;
|
||||
|
||||
GameCooker.Build(target.Platform, target.Mode, target.Output, target.Options);
|
||||
GameCooker.Build(target.Platform, target.Mode, target.Output, BuildOptions.None, target.CustomDefines);
|
||||
}
|
||||
else if (_exitOnBuildEnd)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user