Add support for custom defines for build system via Flax.Build command line

This commit is contained in:
Wojtek Figat
2021-02-16 13:09:50 +01:00
parent a98f867bd8
commit b742d0c326
2 changed files with 17 additions and 0 deletions

View File

@@ -1,5 +1,7 @@
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
using System.Collections.Generic;
namespace Flax.Build
{
/// <summary>
@@ -198,5 +200,10 @@ namespace Flax.Build
/// </summary>
[CommandLine("customProjectFormat", "<type>", "Generates code project files for a custom project format type. Valid only with -genproject option.")]
public static string ProjectFormatCustom = null;
/// <summary>
/// Custom configuration defines provided via command line for the build tool.
/// </summary>
public static List<string> CustomDefines = new List<string>();
}
}

View File

@@ -32,6 +32,16 @@ namespace Flax.Build
{
// Setup
CommandLine.Configure(typeof(Configuration));
foreach (var option in CommandLine.GetOptions())
{
if (option.Name.Length > 1 && option.Name[0] == 'D')
{
var define = option.Name.Substring(1);
if (!string.IsNullOrEmpty(option.Value))
define += "=" + option.Value;
Configuration.CustomDefines.Add(define);
}
}
if (Configuration.CurrentDirectory != null)
Environment.CurrentDirectory = Configuration.CurrentDirectory;
Globals.Root = Directory.GetCurrentDirectory();