Files
FlaxEngine/Source/Tools/Flax.Build/Deploy/FlaxBuild.cs
2023-04-18 18:17:47 +02:00

31 lines
1.2 KiB
C#

// Copyright (c) 2012-2023 Flax Engine. All rights reserved.
using System;
using System.IO;
using Flax.Build;
namespace Flax.Deploy
{
/// <summary>
/// Flax.Build environment and tools.
/// </summary>
class FlaxBuild
{
public static void Build(string root, string target, TargetPlatform platform, TargetArchitecture architecture, TargetConfiguration configuration)
{
var buildPlatform = Platform.BuildPlatform.Target;
var flaxBuildTool = Path.Combine(Globals.EngineRoot, buildPlatform == TargetPlatform.Windows ? "Binaries/Tools/Flax.Build.exe" : "Binaries/Tools/Flax.Build");
var format = "-build -buildtargets={0} -log -logfile= -perf -platform={1} -arch={2} -configuration={3}";
var cmdLine = string.Format(format, target, platform, architecture, configuration);
if (!string.IsNullOrEmpty(Configuration.Compiler))
cmdLine += " -compiler=" + Configuration.Compiler;
int result = Utilities.Run(flaxBuildTool, cmdLine, null, root);
if (result != 0)
{
throw new Exception(string.Format("Unable to build target {0}. Flax.Build failed. See log to learn more.", target));
}
}
}
}