diff --git a/Flax.flaxproj b/Flax.flaxproj index d3c343532..79711dbe4 100644 --- a/Flax.flaxproj +++ b/Flax.flaxproj @@ -8,5 +8,8 @@ "Company": "Flax", "Copyright": "Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.", "GameTarget": "FlaxGame", - "EditorTarget": "FlaxEditor" + "EditorTarget": "FlaxEditor", + "Configuration": { + "UseLargeWorlds": false + } } \ No newline at end of file diff --git a/Source/Tools/Flax.Build/Build/EngineTarget.cs b/Source/Tools/Flax.Build/Build/EngineTarget.cs index a2c567c8e..55cc856ea 100644 --- a/Source/Tools/Flax.Build/Build/EngineTarget.cs +++ b/Source/Tools/Flax.Build/Build/EngineTarget.cs @@ -15,6 +15,11 @@ namespace Flax.Build { private static Version _engineVersion; + /// + /// Gets the engine project. + /// + public static ProjectInfo EngineProject => ProjectInfo.Load(Path.Combine(Globals.EngineRoot, "Flax.flaxproj")); + /// /// Gets the engine version. /// @@ -24,7 +29,7 @@ namespace Flax.Build { if (_engineVersion == null) { - _engineVersion = ProjectInfo.Load(Path.Combine(Globals.EngineRoot, "Flax.flaxproj")).Version; + _engineVersion = EngineProject.Version; Log.Verbose(string.Format("Engine build version: {0}", _engineVersion)); } return _engineVersion; diff --git a/Source/Tools/Flax.Build/CommandLine.cs b/Source/Tools/Flax.Build/CommandLine.cs index 69fc1d615..814d302e3 100644 --- a/Source/Tools/Flax.Build/CommandLine.cs +++ b/Source/Tools/Flax.Build/CommandLine.cs @@ -205,6 +205,26 @@ namespace Flax.Build return options; } + /// + /// Gets the options for the given configuration (key=value pairs). + /// + /// The configuration (key=value pairs). + /// The options. + public static Option[] GetOptions(Dictionary configuration) + { + var options = new Option[configuration.Count]; + int i = 0; + foreach (var e in configuration) + { + options[i] = new Option + { + Name = e.Key, + Value = e.Value, + }; + } + return options; + } + /// /// Parses the specified command line. /// @@ -347,14 +367,45 @@ namespace Flax.Build Configure(GetMembers(obj), obj, commandLine); } + /// + /// Configures the members of the specified object using the command line options. + /// + /// The type. + /// The configuration (key=value pairs). + public static void Configure(Type type, Dictionary configuration) + { + Configure(GetMembers(type), null, configuration); + } + + /// + /// Configures the members of the specified object using the command line options. + /// + /// The object. + /// The configuration (key=value pairs). + public static void Configure(object obj, Dictionary configuration) + { + Configure(GetMembers(obj), obj, configuration); + } + private static void Configure(Dictionary members, object instance, string commandLine) { if (commandLine == null) throw new ArgumentNullException(); - - // Process command line var options = GetOptions(commandLine); + Configure(members, instance, options); + } + + private static void Configure(Dictionary members, object instance, Dictionary configuration) + { + if (configuration == null) + throw new ArgumentNullException(); + var options = GetOptions(configuration); + Configure(members, instance, options); + } + + private static void Configure(Dictionary members, object instance, Option[] options) + { foreach (var e in members) { // Get option from command line diff --git a/Source/Tools/Flax.Build/Program.cs b/Source/Tools/Flax.Build/Program.cs index 7f3ff477e..be9d20470 100644 --- a/Source/Tools/Flax.Build/Program.cs +++ b/Source/Tools/Flax.Build/Program.cs @@ -38,7 +38,6 @@ namespace Flax.Build { // Setup CommandLine.Configure(typeof(Configuration)); - CommandLine.Configure(typeof(EngineConfiguration)); foreach (var option in CommandLine.GetOptions()) { if (option.Name.Length > 1 && option.Name[0] == 'D') @@ -78,6 +77,14 @@ namespace Flax.Build Log.Warning("Missing project file."); } + // Configure engine + { + var engineProject = EngineTarget.EngineProject; + if (engineProject != null && engineProject.Configuration != null && engineProject.Configuration.Count != 0) + CommandLine.Configure(typeof(EngineConfiguration), engineProject.Configuration); + CommandLine.Configure(typeof(EngineConfiguration)); + } + // Use mutex if required if (Configuration.Mutex) { diff --git a/Source/Tools/Flax.Build/ProjectInfo.cs b/Source/Tools/Flax.Build/ProjectInfo.cs index b6941da1e..803f8b5dd 100644 --- a/Source/Tools/Flax.Build/ProjectInfo.cs +++ b/Source/Tools/Flax.Build/ProjectInfo.cs @@ -95,6 +95,11 @@ namespace Flax.Build /// public string EngineNickname; + /// + /// The custom build configuration entries loaded from project file. + /// + public Dictionary Configuration; + /// /// True if project is using C#-only and no native toolsets is required to build and use scripts. ///