diff --git a/Source/Tools/Flax.Build/Deploy/VCEnvironment.cs b/Source/Tools/Flax.Build/Deploy/VCEnvironment.cs
index 98c352829..0ca955324 100644
--- a/Source/Tools/Flax.Build/Deploy/VCEnvironment.cs
+++ b/Source/Tools/Flax.Build/Deploy/VCEnvironment.cs
@@ -1,6 +1,7 @@
// Copyright (c) 2012-2020 Flax Engine. All rights reserved.
using System;
+using System.Collections.Generic;
using System.IO;
using System.Linq;
using Flax.Build;
@@ -219,7 +220,8 @@ namespace Flax.Deploy
/// Path to the solution file
/// Configuration to build.
/// Platform to build.
- public static void BuildSolution(string solutionFile, string buildConfig, string buildPlatform)
+ /// Custom build properties mapping (property=value).
+ public static void BuildSolution(string solutionFile, string buildConfig, string buildPlatform, Dictionary props = null)
{
var msBuild = MSBuildPath;
if (string.IsNullOrEmpty(msBuild))
@@ -233,6 +235,11 @@ namespace Flax.Deploy
}
string cmdLine = string.Format("\"{0}\" /m /t:Build /p:Configuration=\"{1}\" /p:Platform=\"{2}\" {3} /nologo", solutionFile, buildConfig, buildPlatform, Verbosity);
+ if (props != null)
+ {
+ foreach (var e in props)
+ cmdLine += string.Format(" /p:{0}={1}", e.Key, e.Value);
+ }
int result = Utilities.Run(msBuild, cmdLine);
if (result != 0)
{
diff --git a/Source/Tools/Flax.Build/Deps/Dependency.cs b/Source/Tools/Flax.Build/Deps/Dependency.cs
index 4a801b13c..ed4d4731a 100644
--- a/Source/Tools/Flax.Build/Deps/Dependency.cs
+++ b/Source/Tools/Flax.Build/Deps/Dependency.cs
@@ -99,6 +99,18 @@ namespace Flax.Deps
}
}
+ ///
+ /// Clones the directory.
+ ///
+ /// The source folder path.
+ /// The destination folder path.
+ public static void CloneDirectory(string src, string dst)
+ {
+ if (Directory.Exists(dst))
+ Utilities.DirectoryDelete(dst);
+ Utilities.DirectoryCopy(src, dst);
+ }
+
///
/// Clones the git repository from the remote url (full repository).
///
@@ -275,30 +287,76 @@ namespace Flax.Deps
///
/// The path.
/// The workspace folder.
- /// Custom environment variables to pass to the child process.
- public static void RunCygwin(string path, string workspace = null, Dictionary envVars = null)
+ public static void RunCygwin(string path, string workspace = null)
+ {
+ RunBash(path, string.Empty, workspace);
+ }
+
+ ///
+ /// Runs the bash script (executes natively on Unix platforms, uses Cygwin on Windows).
+ ///
+ /// The script or command path.
+ /// The arguments.
+ /// The workspace folder.
+ /// Custom environment variables to pass to the child process.
+ public static void RunBash(string path, string args = null, string workspace = null, Dictionary envVars = null)
{
- string app;
switch (BuildPlatform)
{
case TargetPlatform.Windows:
{
+ // Find Cygwin
var cygwinFolder = Environment.GetEnvironmentVariable("CYGWIN");
if (string.IsNullOrEmpty(cygwinFolder) || !Directory.Exists(cygwinFolder))
{
cygwinFolder = "C:\\cygwin";
if (!Directory.Exists(cygwinFolder))
- throw new Exception("Missing Cygwin. Install Cygwin64 to C:\\cygwin or set CYGWIN env variable to install location folder.");
+ {
+ cygwinFolder = "C:\\cygwin64";
+ if (!Directory.Exists(cygwinFolder))
+ throw new Exception("Missing Cygwin. Install Cygwin64 to C:\\cygwin or set CYGWIN env variable to install location folder.");
+ }
+ }
+ var cygwinBinFolder = Path.Combine(cygwinFolder, "bin");
+
+ // Ensure that Cygwin binaries folder is in a PATH
+ string envPath = null;
+ envVars?.TryGetValue("PATH", out envPath);
+ if (envPath == null || envPath.IndexOf(cygwinBinFolder, StringComparison.OrdinalIgnoreCase) == -1)
+ {
+ if (envVars == null)
+ envVars = new Dictionary();
+ envVars["PATH"] = cygwinBinFolder;
+ if (envPath != null)
+ envVars["PATH"] += ";" + envPath;
+ }
+
+ // Get the executable file path
+ if (path.EndsWith(".sh", StringComparison.OrdinalIgnoreCase))
+ {
+ // Bash script
+ if (args == null)
+ args = path.Replace('\\', '/');
+ else
+ args = path.Replace('\\', '/') + " " + args;
+ path = Path.Combine(cygwinBinFolder, "bash.exe");
+ }
+ else if (File.Exists(Path.Combine(cygwinBinFolder, path + ".exe")))
+ {
+ // Tool (eg. make)
+ path = Path.Combine(cygwinBinFolder, path + ".exe");
+ }
+ else
+ {
+ throw new Exception("Cannot execute command " + path + " with args " + args);
}
- app = Path.Combine(cygwinFolder, "bin\\bash.exe");
break;
}
case TargetPlatform.Linux:
- app = "bash";
- break;
+ case TargetPlatform.Mac: break;
default: throw new InvalidPlatformException(BuildPlatform);
}
- Utilities.Run(app, path, null, workspace, Utilities.RunOptions.None, envVars);
+ Utilities.Run(path, args, null, workspace, Utilities.RunOptions.ThrowExceptionOnError, envVars);
}
}
}